This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/4] New attribute lookup function addition


On 05/30/14 00:49, Martin Liška wrote:
Hi,
    this patch introduces a new function lookup_attribute_starting that
can find all attributes starting with a specified string. Purpose of the
function is to be able to identify e.g. if a function has any 'omp'
attribute.

Bootstrapped and tested on x86_64-linux.
OK for trunk?

Thanks,
Martin

2014-05-29  Martin Liska  <mliska@suse.cz>

     * tree.h (private_lookup_attribute_starting): New function.
     (lookup_attribute_starting): Likewise.
     * tree.c (private_lookup_attribute_starting): Likewise.
private_lookup_attribute_starting needs a block comment.


+tree
+private_lookup_attribute_starting (const char *attr_name, size_t
attr_len, tree list)
Long line needs to be wrapped? Please review the patch for lines that need wrapping at 80 columns.

So it's really a lookup by prefix, so I'd probably use a name like
lookup_attribute_by_prefix.  Why "private_" in the function name?


It appears it just returns the first attribute from LIST with the given prefix. Presumably you use it iteratively.

+/* Given an attribute name ATTR_NAME and a list of attributes LIST,
+   return a pointer to the attribute's list element if the attribute
+   starts with ATTR_NAME. ATTR_NAME must be in the form 'text' (not
+   '__text__').  */
+
+static inline tree
+lookup_attribute_starting (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_starting (attr_name, strlen
(attr_name), list);
+}
So again, I prefer "prefix" rather than "starting". Similarly this is meant to be called iteratively since you only get the first attribute with the given prefix, right?

OK with the nit fixes mentioned above.


Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]