[cfe-dev] Parsing VCC annotations with clang

Chris Lattner clattner at apple.com
Tue May 31 09:23:54 PDT 2011


On May 31, 2011, at 4:48 AM, Florian Merz wrote:

> Hey Chris,
> 
> thank you for your response and the information you provided.
> 
> If I used a macro such as
> 
>  #define _(x) // x
> 
> so that x is not removed but turned into a comment instead.

As Frits points out, the C preprocessor doesn't work this way.  You could use:

#define _(x)

which will just strip them out, allowing the non-annotations to be parsed.

> Can this comment 
> be accessed in clang and can I determine the corresponding 
> function/struct/loop with this? It seems like clang::CommentHandler is able to 
> handle comments and determine the range of the comment in the source file. From 
> there I'd expect to be able to determine the surrounding object easily. Am I 
> on the right track with this?

The right track to implementing this doesn't involve a macro, or involves a macro along the lines of what frits says where you turn "_" into an attribute.  You'll still have to implement the parser logic either way though.

-Chris



More information about the cfe-dev mailing list