[cfe-dev] Getting meta-data into Clang's AST

Jan Bierbaum s3306700 at inf.tu-dresden.de
Sun Jul 11 15:24:33 PDT 2010


Sean Hunt meinte am 09.07.2010 09:54:
>> When I just add some custom attributes to the source they are parse
>> without any error but then just discarded. All I need is to have them in
>> the AST besides the built-in ones.
> 
> To do this much, you would need to currently add the attribute to 
> include/clang/Basic/Attr.td, include/clang/AST/Attr.h, 
> include/clang/Parse/AttributeList.h, lib/Parse/AttributeList.cpp, and 
> lib/Sema/SemaDeclAttr.cpp, I believe.

Thanks for the details, but I really want to avoid modifying the Clang
sources. Fortunately searching through the docs I happened to noticed
the annotation attribute. So instead of

__attribute__(foo)

I use

__attribute__((annotate("foo")))

This get's transferred to the AST just fine. It would be great to have
hooks for custom attributes some day, until then this is a nice
workaround IMHO.


Regards, Jan.



More information about the cfe-dev mailing list