<div dir="ltr">Pardis,<div><br></div><div>I believe this is not possible. The ClangTool::run method calls FrontendActionFactory::runInvocation which <a href="https://clang.llvm.org/doxygen/Tooling_8cpp_source.html#l00358">captures the FrontEndAction with a unique_ptr</a>, thus freeing everything before it returns.</div><div><br></div><div>Can you detail further what you intend to do?</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 12, 2018 at 7:43 AM Pardis Pashakhanloo via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">Hi all,</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">Suppose we have created a ClangTool in libtooling.</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">Is there a way to record ASTContexts (say, in the consumer), and access them after clangTool.run(...)?</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">For example:</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">std::vector<ASTContext*> contexts;</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">int main(int argc, char **argv) {</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">
<p class="m_1446812576087383442gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="m_1446812576087383442gmail-s1" style="font-variant-ligatures:no-common-ligatures"> CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);</span></p><p class="m_1446812576087383442gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="m_1446812576087383442gmail-s1" style="font-variant-ligatures:no-common-ligatures"> </span></p><p class="m_1446812576087383442gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="m_1446812576087383442gmail-s1" style="font-variant-ligatures:no-common-ligatures"> ClangTool Tool(OptionsParser.getCompilations(),</span></p><p class="m_1446812576087383442gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="m_1446812576087383442gmail-s1" style="font-variant-ligatures:no-common-ligatures"> </span></p><p class="m_1446812576087383442gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="m_1446812576087383442gmail-s1" style="font-variant-ligatures:no-common-ligatures"> OptionsParser.getSourcePathList());</span></p><p class="m_1446812576087383442gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="m_1446812576087383442gmail-s1" style="font-variant-ligatures:no-common-ligatures"> </span></p><p class="m_1446812576087383442gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="m_1446812576087383442gmail-s1" style="font-variant-ligatures:no-common-ligatures"> Tool.run(newFrontendActionFactory<MyAction>().get());</span></p></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"> // I want to access contexts[i] here and possibly use the rewriter.</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">}</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">Any help is appreciated.</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div><div dir="ltr" class="m_1446812576087383442gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(68,68,68)">Thanks,</span></div><div><span style="color:rgb(68,68,68);font-family:tahoma,sans-serif"><span class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(68,68,68)">Pardis P</span></span></div></div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>João Paulo L. de Carvalho<br>Computer Science | IC-UNICAMP | Campinas , SP - Brazil</div><div><a href="mailto:jaopaulolc@gmail.com" target="_blank">jaopaulolc@gmail.com</a></div><div><a href="mailto:joao.carvalho@ic.unicamp.br" target="_blank">joao.carvalho@ic.unicamp.br</a><br><a href="mailto:j160924@dac.unicamp.br" target="_blank">j160924@dac.unicamp.br</a></div></div></div></div></div>