[cfe-dev] Transforming the AST

Zakkak Foivos zakkak at ics.forth.gr
Tue Jul 6 10:46:32 PDT 2010

On 07/06/2010 08:34 PM, John McCall wrote:
> On Jul 6, 2010, at 8:34 AM, Zakkak Foivos wrote:
>> i need some help with AST transformations. I searched through the api
>> but didn't find anything straight forward except some build*type functions.
>> How can i create a new stmt and insert it in the tree? I don't want to
>> use the Rewriter for the transformations.
> If you're interested in producing transformed source code, you should really
> use the rewriter (and tell us if that's insufficient for some reason).  If you're
> interested in producing transformed machine code, you can either follow one
> of Doug's suggestions or, if the code you want to emit is pretty straightforward,
> you can alter the LLVM IR after CodeGen is done with it.
> John.

Thank you both for your replies.

I am trying to make a source-to-source compiler. The reason i would
prefer to skip the rewriter is that it supports only text. I guess i
will have to use the prettyprinter to produce the final text.
Also is it possible for rewriter to create a new file and write in to
it? Because this is going to be the next step after the transformations.


More information about the cfe-dev mailing list