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

dan.sanduleac sanduleac.dan at gmail.com
Wed Apr 3 06:21:45 PDT 2013

Hi BĂ©atrice,

This is really helpful, but I got stuck somewhere.

I tried to create a similar setup, getting ahold of the Sema in my
ASTFrontendAction, and then trying to transform function bodies.
My VisitFunctionDecl runs TransformStmt (ultimately TransformCompoundStmt)
on the function's body, but it crashes because at this point
Sema::FunctionScopes is an empty vector, and the first thing
Sema::TransformCompoundStmt tries to do (via
Sema::ActOnStartOfCompoundStmt() -> Sema::PushCompoundScope()) is to push
the new CompoundScope onto the current FunctionScope .. which of course
doesn't exist since FunctionScopes is empty.

When exactly do you start traversing with the RecursiveASTVisitor? Is it
after semantic analysis, after the Parser had already populated the entire
AST, or somehow during?

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

More information about the cfe-dev mailing list