<div dir="ltr">Hello,<div><br></div><div>I have a piece of C code like so: </div><div><br></div><div>==========================================</div><div>void foo(); // just a declaration (sometimes in a header file instead)</div>
<div><br></div><div>void bar() {</div><div> // definition here</div><div>}</div><div><br></div><div>int main() {</div><div> bar(); // this one is fine</div><div> foo(); // this one doesn't work</div><div>}</div>
<div><br></div><div>void foo() {</div><div> // definition here<br>}</div><div>============================================</div><div><br></div><div>I'm using VisitStmt and looking at the CallExprs in main(). For the "bar()" function above, I can get the FunctionDecl* using CallExpr::getDirectCallee(). However, that doesn't work for the "foo()" function -- calling getDirectCallee() gives me the function prototype, not the definition of "foo()"...</div>
<div><br></div><div>So I tried using the Redeclarable class's "redecl_iterator" to dump each redeclaration starting from getDirectCallee()->redecls_begin. However, it only iterates once for the function prototype and doesn't include the actual definition of "foo()." </div>
<div><br></div><div>How can I get the real definition of foo() at the bottom of the code above? I know it's probably something easy, but I just can't seem to get there. </div><div><br></div><div>Thanks in advance,<br>
Kevin Boos</div><div><br></div></div>