[cfe-dev] AST matcher for C++11 [[attributes]]

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Mon Jan 23 06:14:16 PST 2017


On Mon, Jan 23, 2017 at 6:13 AM, Andrzej Krzemienski via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Hi everyone,
> I am not sure of this is the right list. I have an issue with clang-tidy's
> predefined AST Matchers. The documentation for using clang-tidy
> (http://clang.llvm.org/extra/clang-tidy/) suggests that one should first try
> to use of predefined matchers listed in
> http://clang.llvm.org/docs/LibASTMatchersReference.html.
>
> But there is no matcher for C++11 [[attributes]]. There is matcher hasAttr,
> but it only works for predefined GCC __attribute__((s)).

The hasAttr() matcher works for all attributes based on the Attr::Kind
enumeration. This will not distinguish between different spellings of
the same attribute, but that should (hopefully) be largely irrelevant.
So this matcher should do what you need already.

~Aaron

> Now, I quess, I
> will have to write my own matcher, but don't you think it would be useful to
> have a ready-to-use matcher for c++11 [[attributes]] ?
>
> I need them to implement checks with fewer false positives. For instance one
> of the checks is clang-tidy is "warn upon converting constructors", which is
> not an ideal, because sometimes I do want to implement a conversion.
> Instead, I would like to provide an alternative: "warn upon converting
> constructors not annotated as converting". But I cannot do that easily
> today.
>
> Is there any reason that such matcher should not be included in the
> predefined AST matchers?
>
> Regards,
> &rzej;
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list