[cfe-dev] AST transformations
Chris Lattner
clattner at apple.com
Thu Apr 24 09:17:50 PDT 2008
On Apr 24, 2008, at 3:29 AM, Stephan Creutz wrote:
> for a project of mine I need to do a lot of AST transformations
> (inserting new nodes and changing existing ones), thus using the
> Rewriter for this task seems not suitable to me because after each
> transformation step I would need to rebuild the whole AST.
>
> Transformation of ASTs seems not to be trivial because AST nodes are
> not
> changeable and recreating all nodes from scratch is not practical. I'm
> curious why it is not possible to change AST nodes, is there any
> specific reason? Or isn't it just done yet because there is no
> interest
> in that right now?
I'm not sure what you mean here. The ObjC rewriter does certainly
replace subexpressions and rebuilds the AST as it goes. For a simple
example, see how it handles the @encode (ObjCEncodeExpr) expression.
The objc rewriter also correctly handles recursively nested
expressions. See test/Rewriter/objc-ivar-receiver-1.m for an example.
-Chris
More information about the cfe-dev
mailing list