<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>This looks good to me, I'm not sure what could be the issue. Try implementing FunctionBodyVisitor::VisitStmt() where you just the Stmt visited to see where the traversal stops.<br></div>
<div> </div>
<div>As a side-note, in DummyVisitor::VisitFunctionDecl, you should probably call the parent's VisitFunctionDecl at the end (although I seriously doubt this would make any difference here).<br></div>
<div> </div>
<div id="sig19426269"><div class="signature">---<br></div>
<div class="signature">Best regards,<br></div>
<div class="signature"> </div>
<div class="signature">Gábor 'ShdNx' Kozár<br></div>
<div class="signature"><a href="http://gaborkozar.me">http://gaborkozar.me</a><br></div>
<div class="signature"> </div>
</div>
<div> </div>
<div> </div>
<div>On Fri, Dec 12, 2014, at 10:39, Manasij Mukherjee wrote:<br></div>
<blockquote type="cite"><div>Hi,<br></div>
<div>Here is my code, sorry for the delay.<br></div>
<div> </div>
<div>class FunctionBodyVisitor : public<br></div>
<div>clang::StmtVisitor<FunctionBodyVisitor> {<br></div>
<div>public:<br></div>
<div> void VisitCallExpr(clang::CallExpr* Expr) {<br></div>
<div> llvm::outs() << Expr->getCalleeDecl()->getAsFunction()->getName() <<<br></div>
<div> "\n";<br></div>
<div> //this is never called<br></div>
<div> }<br></div>
<div>};<br></div>
<div> </div>
<div>class DummyVisitor : public clang::RecursiveASTVisitor<DummyVisitor> {<br></div>
<div>public:<br></div>
<div> bool VisitFunctionDecl(clang::FunctionDecl* Decl) {<br></div>
<div> llvm::outs() << Decl->getName() << "\n"; // this part visibly works<br></div>
<div> stmtVisitor.Visit(Decl->getBody());<br></div>
<div> return true;<br></div>
<div> }<br></div>
<div>private:<br></div>
<div> FunctionBodyVisitor stmtVisitor;<br></div>
<div>};<br></div>
<div> </div>
<div>The code on which this is called is:<br></div>
<div>void foo()<br></div>
<div>{<br></div>
<div> </div>
<div>}<br></div>
<div>int main()<br></div>
<div>{<br></div>
<div> foo(); // I want to get to this call expression<br></div>
<div>}<br></div>
<div> </div>
<div>Manasij<br></div>
<div> </div>
<div> </div>
<div>On Sat, Dec 6, 2014 at 8:18 AM, Gabor Kozar <<a defang_rel="noreferrer" href="mailto:kozargabor@gmail.com">kozargabor@gmail.com</a>> wrote:<br></div>
<blockquote><div>Hi,<br></div>
<div> </div>
<div>It should work. Define an StmtVisitor subclass, provide a VisitCallExpr.<br></div>
<div>Then in your Visitor::VisitFunctionDecl, construct an StmtVisitor object,<br></div>
<div>then call its Visit method with the function's body.<br></div>
<div> </div>
<div>In the future, please also provide source code, to allow us to spot any bugs<br></div>
<div>and problems in your code (e.g. you may believe that the code does what you<br></div>
<div>say it does, but you might have a bug, etc.).<br></div>
<div> </div>
<div>---<br></div>
<div>Best regards,<br></div>
<div> </div>
<div>Gábor 'ShdNx' Kozár<br></div>
<div><a defang_rel="noreferrer" href="http://gaborkozar.me">http://gaborkozar.me</a><br></div>
<div> </div>
<div> </div>
<div> </div>
<div>On Wed, Dec 3, 2014, at 07:11, Manasij Mukherjee wrote:<br></div>
<div> </div>
<div>Hi,<br></div>
<div>In a RecursiveASTVisitor implementation, I implement VisitFunctionDecl.<br></div>
<div>Now, from the FunctionDecl I have, I can call getBody and get a Stmt.<br></div>
<div> </div>
<div>How can I visit all the functions this function calls ?<br></div>
<div>I have tried creating a StmtVisitor and ..err..defining VisitCallExpr !<br></div>
<div>That didn't work.<br></div>
<div> </div>
<div>Can anyone point me to what I should be doing ?<br></div>
<div> </div>
<div>Manasij Mukherjee<br></div>
<div><u>_______________________________________________</u><br></div>
<div>cfe-dev mailing list<br></div>
<div><a defang_rel="noreferrer" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br></div>
<div><a defang_rel="noreferrer" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br></div>
<div> </div>
<div> </div>
<div> </div>
<div><u>_______________________________________________</u><br></div>
<div>cfe-dev mailing list<br></div>
<div><a defang_rel="noreferrer" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br></div>
<div><a defang_rel="noreferrer" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br></div>
<div> </div>
</blockquote></blockquote><div> </div>
</body>
</html>