<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 6, 2014 at 8:49 AM, 조명진 <span dir="ltr"><<a href="mailto:happybrown@naver.com" target="_blank">happybrown@naver.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="KO" link="#0563C1" vlink="#954F72"><div><p class="MsoNormal"><span lang="EN-US">Hi all,<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">I’m trying to use clang libtooling for detecting all return statements.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">I used the “VisitReturnStmt” function but sometimes it is not working as follow case.<u></u><u></u></span></p><p class="MsoNormal">
<span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">//target code<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">class ExampleFrontendAction : public ASTFrontendAction {<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">public:<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, StringRef file) {<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> return new ExampleASTConsumer(&CI); // pass CI pointer to ASTConsumer<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> }<u></u><u></u></span></p><p class="MsoNormal">
<span lang="EN-US">};<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">//target code end<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">//results<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">CXXMethodDecl 0x2468cb0 </project/llvm/Debug+Asserts/bin/a.cpp:107:5, line:115:5> CreateASTConsumer 'int *(int &, int)'<u></u><u></u></span></p><p class="MsoNormal">
<span lang="EN-US">|-ParmVarDecl 0x2468b60 <line:107:44, col:62> CI 'int &' invalid<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">|-ParmVarDecl 0x2468bd0 <col:66, col:76> file 'int' invalid<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">`-CompoundStmt 0x2469138 <col:82, line:115:5> invalid<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">As you can see, we cannot find any ReturnStmt. (It is included in CompoundStmt. Also the CompoundStmt is a leaf statement.)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">How can I detect this case? Please help me! <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks in advance.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Additional Question.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Why does clang return “int *” instead of “ASTConsumer *” in the case of CreateASTConsumer method when I use getReturnType() in VisitFunctionDecl()?</span></p></div></div></blockquote>
<div><br></div><div>My guess is that the headers are not correctly found; are you sure you're using a compilation database that works?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="KO" link="#0563C1" vlink="#954F72"><div><p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Any ideas?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Brown.<u></u><u></u></span></p></div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>