[cfe-dev] Inserting a high level transformation pass that uses TreeTransform

Béatrice Creusillet bac at silkan.com
Wed Mar 6 13:08:13 PST 2013


Hi John,


JohnH wrote
>  Moreover, how should I use TreeTransform? I construct it with a Sema, but
> how do I start it? With
> the root AST of a translation unit or a function?

I have just finished a small toy tool, which merely duplicate declarations.
I used LibTooling, which may not be exactly what you want, but I guess that
part of what I did can be re-used in another context. 

I defined a sub-class of ASTFrontEndAction, to redefine CreateASTConsumer in
order to create a SemaConsumer instead of an ASTConsumer. My
handleTopLevelDecl method creates a RecursiveASTVisitor by handing it the
Sema, which will be necessary for TreeTransform. Then the VisitStmt method
of my RecursiveASTVisitor creates an instance of my subclass of
TreeTransform, and then calls the transforming method.

Hope this helps.
Regards,

Béatrice.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Inserting-a-high-level-transformation-pass-that-uses-TreeTransform-tp4030773p4030841.html
Sent from the Clang Developers mailing list archive at Nabble.com.




More information about the cfe-dev mailing list