<div dir="ltr">I am trying to parse the following in a .cpp file:<div><br></div><div><div>class Foo</div><div>{</div><div>public:</div><div><br></div><div><span class="" style="white-space:pre">        </span>Foo* foo( Foo* ptr )<br>
</div><div><span class="" style="white-space:pre">        </span>{</div><div><span class="" style="white-space:pre">          </span>Foo local = *ptr;<br></div><div><span class="" style="white-space:pre">                </span>return &local;<br></div>
<div><span class="" style="white-space:pre">    </span>}</div><div>};</div><div><br></div><div><br></div><div>int main( int argc, char** argv ) </div><div>{ </div><div><span class="" style="white-space:pre">     </span>Foo f;</div>
<div>        Foo* fPtr = f.foo( &f );</div><div><span class="" style="white-space:pre"> </span>return 0; </div><div>}</div></div><div><br></div><div>I have created a CompilerInstance as follows:</div><div><br></div><div>
<pre style="font-family:Consolas;color:black">    <span style="color:rgb(43,145,175)">CompilerInstance</span> compilerInstance;
 
    <span style="color:rgb(43,145,175)">LangOptions</span> languageOptions;
    languageOptions.CPlusPlus = 1;
 
    <span style="color:rgb(43,145,175)">CompilerInvocation</span> compilerInvocation;
    compilerInvocation.setLangDefaults( languageOptions, <span style="color:rgb(47,79,79)">IK_CXX</span> );
    compilerInstance.setInvocation( &compilerInvocation );
</pre><pre style="font-family:Consolas;color:black"><br></pre><pre style="font-family:Consolas;color:black">In my RecursiveASTVisitor, I have overloaded the following:</pre><pre style="font-family:Consolas;color:black"><pre style="font-family:Consolas">
    <span style="color:blue">bool</span> VisitCXXRecordDecl( <span style="color:rgb(43,145,175)">CXXRecordDecl</span>* <span style="color:gray">recordPtr</span> )
    {
        <span style="color:blue">return</span> <span style="color:blue">true</span>;
    }
 
    <span style="color:blue">bool</span> VisitCXXMethodDecl( <span style="color:rgb(43,145,175)">CXXMethodDecl</span>* <span style="color:gray">methodPtr</span> )
    {
        <span style="color:blue">return</span> <span style="color:blue">true</span>;
    }
 
    <span style="color:blue">bool</span> VisitFunctionDecl( <span style="color:rgb(43,145,175)">FunctionDecl</span> *<span style="color:gray">f</span> ) <pre style="font-family:Consolas">    {
        <span style="color:blue">return</span> <span style="color:blue">true</span>;
    }
</pre><div><pre style="font-family:Consolas">When traversing the AST, VisitFunctionDecl gets called for the main function, but VisitCXXRecordDecl and VisitCXXMethodDecl never get called. Does anyone know why they are not getting called and/or how to get them to be called?</pre>
<pre style="font-family:Consolas"><br></pre><pre style="font-family:Consolas">Thanks,</pre><pre style="font-family:Consolas">Sandra</pre></div><div><br></div>
</pre></pre><pre style="font-family:Consolas;color:black"><br></pre><pre style="font-family:Consolas;color:black"><br></pre></div></div>