<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 2, 2017 at 5:54 AM, Aaron Ballman via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Feb 2, 2017 at 7:33 AM, Andrzej Krzemienski via cfe-dev<br>
<div><div class="h5"><<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
><br>
> 2017-01-23 15:14 GMT+01:00 Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>>:<br>
>><br>
>> On Mon, Jan 23, 2017 at 6:13 AM, Andrzej Krzemienski via cfe-dev<br>
>> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
>> > Hi everyone,<br>
>> > I am not sure of this is the right list. I have an issue with<br>
>> > clang-tidy's<br>
>> > predefined AST Matchers. The documentation for using clang-tidy<br>
>> > (<a href="http://clang.llvm.org/extra/clang-tidy/" rel="noreferrer" target="_blank">http://clang.llvm.org/extra/<wbr>clang-tidy/</a>) suggests that one should first<br>
>> > try<br>
>> > to use of predefined matchers listed in<br>
>> > <a href="http://clang.llvm.org/docs/LibASTMatchersReference.html" rel="noreferrer" target="_blank">http://clang.llvm.org/docs/<wbr>LibASTMatchersReference.html</a>.<br>
>> ><br>
>> > But there is no matcher for C++11 [[attributes]]. There is matcher<br>
>> > hasAttr,<br>
>> > but it only works for predefined GCC __attribute__((s)).<br>
>><br>
>> The hasAttr() matcher works for all attributes based on the Attr::Kind<br>
>> enumeration. This will not distinguish between different spellings of<br>
>> the same attribute, but that should (hopefully) be largely irrelevant.<br>
>> So this matcher should do what you need already.<br>
><br>
><br>
> Aaron, thanks for the reply. However it seams I phrased my question<br>
> incorrectly. I would like to check the existence of my own unique attribute,<br>
> say [[ab::cd::my_attribute]]. It is not in the list of any known attributes.<br>
> hasAttr() appears to only detect the known attributes that are already<br>
> listed in the long attribute enum. But will not see a new attribute.<br>
><br>
> So my question is, in clang-tidy is it possible to inspect custom<br>
> attributes, like [[ab::cd::my_attribute]] ?<br>
<br>
</div></div>If your custom attribute is implemented by adding the attribute to<br>
Attr.td, then it should work fine (depending on your attribute<br>
definition). The list of known attributes used by hasAttr() is<br>
automatically generated from the attributes listed in Attr.td, and the<br>
only attributes that don't get enumerated are ones which do not have<br>
an AST node associated with them.<br>
<br>
If your attribute is not added to Attr.td, then you are correct,<br>
clang-tidy has no knowledge of it.<br></blockquote><div><br></div><div>It might be useful to add a facility to Clang's AST to hold on to unrecognized attributes (and to have an AST node type for that).  Not every application wants to recompile the guts of Clang just to handle users' attributes, and might not be able to if it wants to handle attributes in some generic way (so that the users aren't the people who are building the tools).</div><div><br></div><div>-- James </div></div></div></div>