[cfe-dev] Accessing ASTContext after run() invocation

João Paulo Labegalini de Carvalho via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 12 02:02:32 PST 2018


Pardis,

I believe this is not possible. The ClangTool::run method calls
FrontendActionFactory::runInvocation which captures the FrontEndAction with
a unique_ptr
<https://clang.llvm.org/doxygen/Tooling_8cpp_source.html#l00358>, 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 <
cfe-dev at lists.llvm.org> 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
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>


-- 
João Paulo L. de Carvalho
Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
jaopaulolc at gmail.com
joao.carvalho at ic.unicamp.br
j160924 at dac.unicamp.br
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181112/1c09d104/attachment.html>


More information about the cfe-dev mailing list