Hi!

On Mon, Dec 19, 2016 at 11:51:29AM -0500, David Malcolm wrote:
> +/* Look for near matches for the scoped attribute with namespace NS and
> +   name NAME.
> +   Return the best matching attribute name, or NULL if none is found.
> +   If it returns non-NULL then *UNDERSCORES is written to, with true
> +   iff leading and trailing underscores were stripped from NAME
> +   before the match.  */
> +
> +static const char *
> +fuzzy_lookup_scoped_attribute_spec (const_tree ns, const_tree name,
> +                                 bool *underscores)
> +{
> +  struct substring attr;
> +  scoped_attributes *attrs;
> +
> +  const char *ns_str = (ns != NULL_TREE) ? IDENTIFIER_POINTER (ns): NULL;
> +
> +  attrs = find_attribute_namespace (ns_str);
> +
> +  if (attrs == NULL)
> +    return NULL;
> +
> +  attr.str = IDENTIFIER_POINTER (name);
> +  attr.length = IDENTIFIER_LENGTH (name);
> +  *underscores = extract_attribute_substring (&attr);
> +
> +  best_match <struct substring *, const char *> bm (&attr);
> +
> +  hash_table<attribute_hasher> *h = attrs->attribute_hash;
> +  for (hash_table<attribute_hasher>::iterator iter = h->begin ();
> +       iter != h->end (); ++iter)
> +    bm.consider ((*iter)->name);
> +  return bm.get_best_meaningful_candidate ();

Does this consider the decl_req, type_req and fn_type_req flags in the
attribute tables (i.e. that for attribute on a VAR_DECL it doesn't suggest
attributes that apply to functions only, on FUNCTION_DECL suggest attributes
that apply only to non-function decls, etc.)?
Does it ignore internal only attributes (i.e. attributes containing spaces
or * characters in their names)?
Say
void foo (void) __attribute ((omp_declare_target));
should not suggest the omp declare target attribute, since users can't type
it in.

        Jakub

Reply via email to