diff options
author | Martin Liska <mliska@suse.cz> | 2014-06-04 11:44:33 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2014-06-04 09:44:33 +0000 |
commit | 8a57e88dc63d44a2f72781e4732ede00f14205cf (patch) | |
tree | 1470e3aa0e88e7cee9a286e65c00ca02080a9d9a /gcc/tree.c | |
parent | d211e4719264a66f3a310870d7459751c335ce7f (diff) | |
download | gcc-8a57e88dc63d44a2f72781e4732ede00f14205cf.zip gcc-8a57e88dc63d44a2f72781e4732ede00f14205cf.tar.gz gcc-8a57e88dc63d44a2f72781e4732ede00f14205cf.tar.bz2 |
New attribute lookup function addition
* tree.h (private_lookup_attribute_starting): New function.
(lookup_attribute_starting): Likewise.
* tree.c (private_lookup_attribute_starting): Likewise.
From-SVN: r211219
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -5759,6 +5759,44 @@ private_lookup_attribute (const char *attr_name, size_t attr_len, tree list) return list; } +/* Given an attribute name ATTR_NAME and a list of attributes LIST, + return a pointer to the attribute's list first element if the attribute + starts with ATTR_NAME. ATTR_NAME must be in the form 'text' (not + '__text__'). */ + +tree +private_lookup_attribute_by_prefix (const char *attr_name, size_t attr_len, + tree list) +{ + while (list) + { + size_t ident_len = IDENTIFIER_LENGTH (get_attribute_name (list)); + + if (attr_len > ident_len) + { + list = TREE_CHAIN (list); + continue; + } + + const char *p = IDENTIFIER_POINTER (get_attribute_name (list)); + + if (strncmp (attr_name, p, attr_len) == 0) + break; + + /* TODO: If we made sure that attributes were stored in the + canonical form without '__...__' (ie, as in 'text' as opposed + to '__text__') then we could avoid the following case. */ + if (p[0] == '_' && p[1] == '_' && + strncmp (attr_name, p + 2, attr_len) == 0) + break; + + list = TREE_CHAIN (list); + } + + return list; +} + + /* A variant of lookup_attribute() that can be used with an identifier as the first argument, and where the identifier can be either 'text' or '__text__'. |