[cfe-dev] AST transformations

Vassil Vassilev vasil.georgiev.vasilev at cern.ch
Thu Mar 10 11:43:05 PST 2011


Hi,
On 10.3.2011 г. 18:07, Reid Kleckner wrote:
>
> True.  I've been assured that mutating the AST is very difficult to do
> correctly, but I don't fully understand why.  Perhaps it would be a
> good idea to write up an FAQ explaining why clang doesn't support it,
> with an example of why a simple local modification can break other
> parts of the AST (ie switching the cmp condition).
>> RewriteObjC class uses ASTConsumer; however, looking at the source
>> it's not immediately clear to me whether it is transforming the AST or
>> just inserting extra declarations/statements/etc. at the source level.
> The recommended approach for transforming the program source is to
> analyze the AST and use the source locations in the AST to make
> textual, source-level edits.
This part I didn't understand. You mean finding the source location of 
the AST nodes, inserting and reparsing?

Cheers,
Vassil



More information about the cfe-dev mailing list