[cfe-dev] Getting meta-data into Clang's AST
rideau3 at gmail.com
Fri Jul 9 00:54:25 PDT 2010
On 07/08/2010 03:01 AM, Jan Bierbaum wrote:
> But to make use of the C++0x style attributes you have to use the
> -std=c++0x option, correct?
Currently, yes. Also note that the implementation is a little outdated;
there were changes to the way attributes are parsed in the most recent
draft and those are not reflected in the source.
> Is it possible to add custom attributes to Clang without changing it's
> code? Are there any hooks? I'm trying to build on top of the binary
> distribution of LLVM and Clang just using their libs. Up to now I found
> hooks in the preprocessor to add pragma and comment handlers but nothing
> for attributes.
No. Adding custom attribute hooks is a good idea, and I'll consider it
after I finish my current attribute rewrite.
> 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/Parse/AttributeList.h, lib/Parse/AttributeList.cpp, and
lib/Sema/SemaDeclAttr.cpp, I believe. If you want them to use the C++0x
syntax, you would additionally need to look at
lib/Parse/ParseDeclCXX.cpp, near the bottom.
My project is to simplify this process somewhat, but it's currently
somewhat stuck awaiting reply from the GCC devs about their attribute
More information about the cfe-dev