i'm trying to figure out the integration point for the clang::TreeTransform.
The goal is to transform the AST before the Code Generation.
Thanks in advance.
One way to do this is to use ASTFrontEndAction, then redefine the method CreateASTConsumer in order to create a SemaConsumer (instead of an ASTConsumer).
Then in handleTopLevelDecl method create a RecursiveASTVisitor by handing it the Sema, which will be necessary for TreeTransform.
Then the Visit method of the RecursiveASTVisitor can create an instance of your TreeTransform, and then call the appropriate transforming method.
PS: Sometimes when tranforming compund statements, function scope might by empty. You can do
SemaRef.PushFunctionScope();
SemaRef.PushCompoundScope();
before you call your tranforming function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With