<div dir="ltr"><div><div><div><div><div>Hi,<br></div>I am trying to traverse the call
graph. Once I get a node in the call graph, I am trying to print the
function name corresponding to that call graph node as well as the
number of references.<br></div><div><br>Results: <br></div>1)The function name is always an empty string. <br></div>2)The number of references is always a random number. <br></div><div>3)Also the called functions names are also an empty string.<br> <br></div><div> <br></div>Code:<br>bool runOnModule(llvm::Module &M) override<br>{<br><br><br> CallGraph cg = CallGraph(M);<br> cg.dump();// this is correct. It is printing the expected the call graph<br> <br> for ( CallGraph::const_iterator itr = cg.begin(), ie = cg.end() ; itr != ie; itr++)<br> {<br> if (itr->second != nullptr)<br> {<br> itr->second->dump();<br> errs()<<"-----------CGN---------\n";<br> CallGraphNode *cgn = itr->second.get();<br><br><br><br> if(const Function* fptr = cgn->getFunction())<br> {<br> errs()<<"Number of references are"<<cgn->getNumReferences()<<"\n";<br> <br> errs()<<fptr->getName()<<"\n";<br><br><br> if(cgn->operator[](0) != nullptr)<br> {<br> <br> if(cgn->operator[](0)->getFunction() != nullptr)<br> {<br> errs()<<cgn->operator[](0)->getFunction()->getName()<<"\n";<br> }<br><br> }<br> }<br> }<br> }<br>}<br></div><br><br clear="all"><br><div><div class="gmail_signature"><div dir="ltr"><span>Thanks and regards<div>-Ketan Patil</div></span></div></div></div>
</div>