Commit 8a57e88d by Martin Liska Committed by Martin Liska

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
parent d211e471
2014-06-04 Martin Liska <mliska@suse.cz> 2014-06-04 Martin Liska <mliska@suse.cz>
* tree.h (private_lookup_attribute_starting): New function.
(lookup_attribute_starting): Likewise.
* tree.c (private_lookup_attribute_starting): Likewise.
2014-06-04 Martin Liska <mliska@suse.cz>
* cgraph.h (expand_thunk): New argument added. * cgraph.h (expand_thunk): New argument added.
(address_taken_from_non_vtable_p): New global function. (address_taken_from_non_vtable_p): New global function.
* ipa-visibility.c (address_taken_from_non_vtable_p): Likewise. * ipa-visibility.c (address_taken_from_non_vtable_p): Likewise.
......
...@@ -5759,6 +5759,44 @@ private_lookup_attribute (const char *attr_name, size_t attr_len, tree list) ...@@ -5759,6 +5759,44 @@ private_lookup_attribute (const char *attr_name, size_t attr_len, tree list)
return 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 /* A variant of lookup_attribute() that can be used with an identifier
as the first argument, and where the identifier can be either as the first argument, and where the identifier can be either
'text' or '__text__'. 'text' or '__text__'.
......
...@@ -3736,6 +3736,10 @@ extern tree merge_type_attributes (tree, tree); ...@@ -3736,6 +3736,10 @@ extern tree merge_type_attributes (tree, tree);
and you should never call it directly. */ and you should never call it directly. */
extern tree private_lookup_attribute (const char *, size_t, tree); extern tree private_lookup_attribute (const char *, size_t, tree);
/* This function is a private implementation detail
of lookup_attribute_by_prefix() and you should never call it directly. */
extern tree private_lookup_attribute_by_prefix (const char *, size_t, tree);
/* Given an attribute name ATTR_NAME and a list of attributes LIST, /* Given an attribute name ATTR_NAME and a list of attributes LIST,
return a pointer to the attribute's list element if the attribute 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 is part of the list, or NULL_TREE if not found. If the attribute
...@@ -3758,6 +3762,24 @@ lookup_attribute (const char *attr_name, tree list) ...@@ -3758,6 +3762,24 @@ lookup_attribute (const char *attr_name, tree list)
return private_lookup_attribute (attr_name, strlen (attr_name), list); return private_lookup_attribute (attr_name, strlen (attr_name), 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__'). */
static inline tree
lookup_attribute_by_prefix (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
return private_lookup_attribute_by_prefix (attr_name, strlen (attr_name),
list);
}
/* This function is a private implementation detail of /* This function is a private implementation detail of
is_attribute_p() and you should never call it directly. */ is_attribute_p() and you should never call it directly. */
extern bool private_is_attribute_p (const char *, size_t, const_tree); extern bool private_is_attribute_p (const char *, size_t, const_tree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment