From 70e41a6a27a6aad0abbe5598497b4b17ef3feb48 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Wed, 22 Jun 2011 09:52:55 +0000 Subject: In gcc/: 2011-06-21 Nicola Pero In gcc/: 2011-06-21 Nicola Pero * attribs.c (register_attribute): Added assert to check that all attribute specs are registered with a name that is not empty and does not start with '_'. (decl_attributes): Avoid the lookup of the "naked" attribute spec if the function has no attributes. * tree.c (is_attribute_with_length_p): Removed. (is_attribute_p): Removed. (private_is_attribute_p): New. (private_lookup_attribute): New. (lookup_attribute): Removed. (lookup_ident_attribute): New. (remove_attribute): Require the first argument to be in the form 'text', not '__text__'. Updated asserts. (merge_attributes): Use lookup_ident_attributes instead of lookup_attribute. (merge_dllimport_decl_attributes): Use remove_attribute. (attribute_list_contained): Likewise. (attribute_list_equal): Immediately return 1 if the arguments are identical pointers. * tree.h (is_attribute_p): Made inline. Return a 'bool', not an 'int'. Require the first argument to be in the form 'text', not '__text__'. Require the second argument to be an identifier. (lookup_attribute): Made inline. Require the first argument to be in the form 'text', not '__text__'. (private_is_attribute_p, private_lookup_attribute): New. Updated comments. From-SVN: r175286 --- gcc/tree.h | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'gcc/tree.h') diff --git a/gcc/tree.h b/gcc/tree.h index f55574d..3840fed 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4498,18 +4498,54 @@ enum attribute_flags extern tree merge_decl_attributes (tree, tree); extern tree merge_type_attributes (tree, tree); -/* Given a tree node and a string, return nonzero if the tree node is - a valid attribute name for the string. */ +/* This function is a private implementation detail of lookup_attribute() + and you should never call it directly. */ +extern tree private_lookup_attribute (const char *, size_t, tree); + +/* Given an attribute name ATTR_NAME and a list of attributes LIST, + return a pointer to the 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 returns the first occurrence; the + TREE_CHAIN of the return value should be passed back in if further + occurrences are wanted. ATTR_NAME must be in the form 'text' (not + '__text__'). */ -extern int is_attribute_p (const char *, const_tree); +static inline tree +lookup_attribute (const char *attr_name, tree list) +{ + gcc_checking_assert (attr_name[0] != '_'); + /* In most cases, list is NULL_TREE. */ + if (list == NULL_TREE) + return NULL_TREE; + else + /* Do the strlen() before calling the out-of-line implementation. + In most cases attr_name is a string constant, and the compiler + will optimize the strlen() away. */ + return private_lookup_attribute (attr_name, strlen (attr_name), list); +} -/* Given an attribute name and a list of attributes, return the list element - of the attribute or NULL_TREE if not found. */ +/* This function is a private implementation detail of + is_attribute_p() and you should never call it directly. */ +extern bool private_is_attribute_p (const char *, size_t, const_tree); -extern tree lookup_attribute (const char *, tree); +/* Given an identifier node IDENT and a string ATTR_NAME, return true + if the identifier node is a valid attribute name for the string. + ATTR_NAME must be in the form 'text' (not '__text__'). IDENT could + be the identifier for 'text' or for '__text__'. */ + +static inline bool +is_attribute_p (const char *attr_name, const_tree ident) +{ + gcc_checking_assert (attr_name[0] != '_'); + /* Do the strlen() before calling the out-of-line implementation. + In most cases attr_name is a string constant, and the compiler + will optimize the strlen() away. */ + return private_is_attribute_p (attr_name, strlen (attr_name), ident); +} /* Remove any instances of attribute ATTR_NAME in LIST and return the - modified list. */ + modified list. ATTR_NAME must be in the form 'text' (not + '__text__'). */ extern tree remove_attribute (const char *, tree); -- cgit v1.1