Accessing ASTContext after run() invocation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing ASTContext after run() invocation

Oleg Smolsky via cfe-dev
Hi all,

Suppose we have created a ClangTool in libtooling.
Is there a way to record ASTContexts (say, in the consumer), and access them after clangTool.run(...)?

For example:

std::vector<ASTContext*> contexts;
int main(int argc, char **argv) {

  CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);

  ClangTool Tool(OptionsParser.getCompilations(),

    OptionsParser.getSourcePathList());

  Tool.run(newFrontendActionFactory<MyAction>().get());


     // I want to access contexts[i] here and possibly use the rewriter.
}

Any help is appreciated.

Thanks,
Pardis P

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ASTContext after run() invocation

Oleg Smolsky via cfe-dev
Pardis,

I believe this is not possible. The ClangTool::run method calls FrontendActionFactory::runInvocation which captures the FrontEndAction with a unique_ptr, thus freeing everything before it returns.

Can you detail further what you intend to do?

On Mon, Nov 12, 2018 at 7:43 AM Pardis Pashakhanloo via cfe-dev <[hidden email]> wrote:
Hi all,

Suppose we have created a ClangTool in libtooling.
Is there a way to record ASTContexts (say, in the consumer), and access them after clangTool.run(...)?

For example:

std::vector<ASTContext*> contexts;
int main(int argc, char **argv) {

  CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);

  ClangTool Tool(OptionsParser.getCompilations(),

    OptionsParser.getSourcePathList());

  Tool.run(newFrontendActionFactory<MyAction>().get());


     // I want to access contexts[i] here and possibly use the rewriter.
}

Any help is appreciated.

Thanks,
Pardis P
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


--
João Paulo L. de Carvalho
Computer Science |  IC-UNICAMP | Campinas , SP - Brazil

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev