[cfe-users] How to associate metadata with a class that can be picked up in an AST parser?

Zac Hansen via cfe-users cfe-users at lists.llvm.org
Fri Jun 24 04:02:20 PDT 2016


I was hoping to be able to use custom attributes in my source code and be
able to see them in the AST, but even though there are some mentions on the
internet saying this can work, it doesn't seem to.

If I say

class [[random_attribute]] Foo {};

I see nothing in -ast-dump, but if I change it to [[deprecated]], it shows
up.




Assuming this isn't possible, is there another approach with similar
behavior that I can use in a clang plugin to see that I'm "interested" in a
class which doesn't otherwise change its behavior (or require me to modify
and recompile clang)?


Thank you.

--Zac

That said, I did manage to get a plugin working that prints out all the
class names it sees.   After fighting with a lot of boilerplate, the actual
logic part is pretty nice with matchers!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20160624/6261cbf2/attachment.html>


More information about the cfe-users mailing list