[cfe-dev] relating preprocessing information to syntax trees

Chris Lattner clattner at apple.com
Thu Apr 9 21:47:33 PDT 2009


On Apr 9, 2009, at 11:42 AM, Dietmar Ebner wrote:

> Hello,
>
> I'm working on a small path that dumps clang ASTs in a prolog term
> representation. The format is closely related to ROSE [1] syntax trees
> (there's a one-to-one correspondence). One of the goals is
> source-to-source translation. Therefore, preprocessing information has
> to be properly annotated at the immediately succeeding declaration.
>
> I'm thus looking for a proper way to relate preprocessing information
> such as define or include directives and pragmas to nodes in the  
> syntax
> tree. A quick hack would be to use the annotated source locations,  
> but I
> don't particularly like this solution. Any advice would be greatly
> appreciated. Sorry if this is a trivial question, I'm fairly new to  
> clang.

Hi Dietmar,

I'm not sure exactly what you are asking for.  Instead of a general  
question, can you ask about a specific feature?  For example, macro  
expansions are tracked explicitly through source locations.  One  
client of this is the diagnostics subsystem.  You can see examples  
that show this working at the bottom of this page:
http://clang.llvm.org/diagnostics.html

-Chris



More information about the cfe-dev mailing list