<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=ks_c_5601-1987"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:"¸¼Àº °íµñ";
        panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
        {font-family:"\@¸¼Àº °íµñ";
        panose-1:2 11 5 3 2 0 0 2 0 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        text-autospace:none;
        word-break:break-hangul;
        font-size:10.0pt;
        font-family:"¸¼Àº °íµñ";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"¸¼Àº °íµñ";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"¸¼Àº °íµñ";}
/* Page Definitions */
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:3.0cm 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=KO link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hi all,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I¡¯m trying to use clang libtooling for detecting all return statements.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I used the ¡°VisitReturnStmt¡± function but sometimes it is not working as follow case.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//target code<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>class ExampleFrontendAction : public ASTFrontendAction {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>public:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, StringRef file) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>        return new ExampleASTConsumer(&CI); // pass CI pointer to ASTConsumer<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>};<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>//target code end<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//results<o:p></o:p></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)'<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>|-ParmVarDecl 0x2468b60 <line:107:44, col:62> CI 'int &' invalid<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>|-ParmVarDecl 0x2468bd0 <col:66, col:76> file 'int' invalid<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>`-CompoundStmt 0x2469138 <col:82, line:115:5> invalid<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></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.)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>How can I detect this case? Please help me! <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks in advance.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Additional Question.<o:p></o:p></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()? <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Any ideas?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Brown.<o:p></o:p></span></p></div></body></html>