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

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Mon May 8 01:06:11 PDT 2017


On Mon, May 8, 2017 at 2:06 AM Rachel HaCohen (rahacohe) via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> 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?
>

Can you read the file from disk, attach your function at the end
(textually), and parse the result with runToolOnCode?


>
>
> Thanks,
>
> Rachel.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170508/d7330ecc/attachment.html>


More information about the cfe-dev mailing list