<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Oct 12, 2015 at 2:37 PM Frank Redeker 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">Hello all,<br>
<br>
I'm writing a tool to analyze the call hierarchy of functions (methods)<br>
using ClangTool.<br>
<br>
My idea is to collect the TranslationUnitDecls given to my own<br>
ASTCosumer's HandleTranslationUnit method and traverse them later when<br>
ClangTool.run() has finished.<br>
<br>
But it seems that the AST nodes are no longer valid after<br>
ClangTool.run() has returned. (e.g. If I call getQualifiedNameAsString()<br>
on a FunctionDecl object retrieved from the TranslationUnitDecl, I get<br>
`Assertion failed: DC && "This decl is not contained in a translation<br>
unit!"`)<br>
<br>
So I wonder if there is any trick to extend the life time for the AST or<br>
should I use ClangTool.buildAST() rather then ClangTool.run() to get the<br>
ASTs ?<br></blockquote><div><br></div><div>The idea is to do the reverse:</div><div>Store any information about the AST you want later in some data structure in the callback.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Frank<br>
_______________________________________________<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></div>