How to use clang :: TreeTransform?

I am trying to figure out an integration point for clang :: TreeTransform.

The goal is to convert the AST before generating the code.

Thanks in advance.

+4
source share
1 answer

One way to do this is to use ASTFrontEndAction , then override the CreateASTConsumer method to create SemaConsumer (instead of ASTConsumer).

Then, in the handleTopLevelDecl method, create a RecursiveASTVisitor, passing it the Sema that will be needed for TreeTransform.

Visit RecursiveASTVisitor TreeTransform, .

PS: scope .

SemaRef.PushFunctionScope();
SemaRef.PushCompoundScope();

.

+2

All Articles