tree.c (is_attribute_p): Split out to ..

2004-12-02  Andrew Pinski  <pinskia@physics.uc.edu>

        * tree.c (is_attribute_p): Split out to ..
        (is_attribute_with_length_p): Here.  Use IDENTIFIER_LENGTH instead
        of strlen and compare the string lengths before calling strcmp.
        (lookup_attribute): Call is_attribute_with_length_p instead of
        is_attribute_p.

From-SVN: r91654
This commit is contained in:
Andrew Pinski 2004-12-02 19:25:55 +00:00 committed by Andrew Pinski
parent 910fbc166c
commit e5410ba71b
2 changed files with 31 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2004-12-02 Andrew Pinski <pinskia@physics.uc.edu>
* tree.c (is_attribute_p): Split out to ..
(is_attribute_with_length_p): Here. Use IDENTIFIER_LENGTH instead
of strlen and compare the string lengths before calling strcmp.
(lookup_attribute): Call is_attribute_with_length_p instead of
is_attribute_p.
2004-12-02 Devang Patel <dpatel@apple.com> 2004-12-02 Devang Patel <dpatel@apple.com>
* config/darwin.h (TARGET_OPTION_TRANSLATE_TABLE): Add -gfull and -gused. * config/darwin.h (TARGET_OPTION_TRANSLATE_TABLE): Add -gfull and -gused.

View File

@ -3026,6 +3026,7 @@ build_type_attribute_variant (tree ttype, tree attribute)
return ttype; return ttype;
} }
/* Return nonzero if IDENT is a valid name for attribute ATTR, /* Return nonzero if IDENT is a valid name for attribute ATTR,
or zero if not. or zero if not.
@ -3034,21 +3035,21 @@ build_type_attribute_variant (tree ttype, tree attribute)
`text'. One might then also require attribute lists to be stored in `text'. One might then also require attribute lists to be stored in
their canonicalized form. */ their canonicalized form. */
int static int
is_attribute_p (const char *attr, tree ident) is_attribute_with_length_p (const char *attr, int attr_len, tree ident)
{ {
int ident_len, attr_len; int ident_len;
const char *p; const char *p;
if (TREE_CODE (ident) != IDENTIFIER_NODE) if (TREE_CODE (ident) != IDENTIFIER_NODE)
return 0; return 0;
if (strcmp (attr, IDENTIFIER_POINTER (ident)) == 0)
return 1;
p = IDENTIFIER_POINTER (ident); p = IDENTIFIER_POINTER (ident);
ident_len = strlen (p); ident_len = IDENTIFIER_LENGTH (ident);
attr_len = strlen (attr);
if (ident_len == attr_len
&& strcmp (attr, p) == 0)
return 1;
/* If ATTR is `__text__', IDENT must be `text'; and vice versa. */ /* If ATTR is `__text__', IDENT must be `text'; and vice versa. */
if (attr[0] == '_') if (attr[0] == '_')
@ -3073,6 +3074,17 @@ is_attribute_p (const char *attr, tree ident)
return 0; return 0;
} }
/* Return nonzero if IDENT is a valid name for attribute ATTR,
or zero if not.
We try both `text' and `__text__', ATTR may be either one. */
int
is_attribute_p (const char *attr, tree ident)
{
return is_attribute_with_length_p (attr, strlen (attr), ident);
}
/* Given an attribute name and a list of attributes, return a pointer to the /* Given an attribute name and a list of attributes, return a pointer to the
attribute's list element if the attribute is part of the list, or NULL_TREE attribute's list element if the attribute is part of the list, or NULL_TREE
if not found. If the attribute appears more than once, this only if not found. If the attribute appears more than once, this only
@ -3083,11 +3095,12 @@ tree
lookup_attribute (const char *attr_name, tree list) lookup_attribute (const char *attr_name, tree list)
{ {
tree l; tree l;
size_t attr_len = strlen (attr_name);
for (l = list; l; l = TREE_CHAIN (l)) for (l = list; l; l = TREE_CHAIN (l))
{ {
gcc_assert (TREE_CODE (TREE_PURPOSE (l)) == IDENTIFIER_NODE); gcc_assert (TREE_CODE (TREE_PURPOSE (l)) == IDENTIFIER_NODE);
if (is_attribute_p (attr_name, TREE_PURPOSE (l))) if (is_attribute_with_length_p (attr_name, attr_len, TREE_PURPOSE (l)))
return l; return l;
} }