[cfe-dev] Getting access to two different AST's

Rachel HaCohen (rahacohe) via cfe-dev cfe-dev at lists.llvm.org
Sun May 7 03:32:51 PDT 2017


Hi all,
I'm new to clang and having a little trouble. Would be happy to get some help.

I'm trying to build a tool that (among other things) combines two code parts: The first one is a c file that is given by the user and the second is a fixed c function.
I want to have access to the AST nodes of both code parts, extract the relevant stmts from each, and build from them a new compoundStmt node (initiated with a vector<Stmt*>), which will be transformed back to c code.

I'm having trouble with getting access to both AST's simultaneously.
I tried to access the input code with libTooling by running the following command from main:
Tool.run(newFrontendActionFactory<clang::MyAction>().get());
And access to the fixed code using runToolOnCode and then pass the compoundStmt pointer of the function body to the main:

clang::tooling::runToolOnCode(new MyOtherAction, MyFixedText);

but it seems like both tools are running independently with no ability to pass information from one to the other.

Can anyone give me a hint on this or give me a link to a code that does something similar?

Thanks,
Rachel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170507/2708f1a4/attachment.html>


More information about the cfe-dev mailing list