[cfe-dev] How to match clang::attr::Annotate with specific value?
Andi-Bogdan Postelnicu via cfe-dev
cfe-dev at lists.llvm.org
Sun Jul 5 01:39:07 PDT 2020
Hello,
Yes of course you can do that, you can first interrogate Decl::hasAttrs [1], and if that’s true you can get the AttrVec [2].
I would suggest to wrapp this in a custom matcher.
Hope this helps!
[1] https://clang.llvm.org/doxygen/classclang_1_1Decl.html#a1e0b6223e2547ac65ddbf4802117998b <https://clang.llvm.org/doxygen/classclang_1_1Decl.html#a1e0b6223e2547ac65ddbf4802117998b>
[2] https://clang.llvm.org/doxygen/classclang_1_1Decl.html#a59463d45ab90b696a368b58d23eb49aa
> On 5 Jul 2020, at 11:25, Yafei Liu via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> For example I have a struct:
> struct [[clang::annotate("example")]] ExampleStruct {
> int i;
> float f;
> double d;
> int* ip;
> uint32_t ii;
> };
> Currently I use the matcher like this:
> clang::ast_matchers::cxxRecordDecl(clang::ast_matchers::hasDefinition(),
> clang::ast_matchers::hasAttr(clang::attr::Annotate)).bind("example_struct");
>
> Can I go further by making the matcher check if the annotate is "example"?
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200705/f7bca47d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200705/f7bca47d/attachment.sig>
More information about the cfe-dev
mailing list