Ketan Patil via llvm-dev
2017-Jul-13 06:53 UTC
[llvm-dev] CallGraphNode giving incorrect function Name
Hi, 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. Results: 1)The function name is always an empty string. 2)The number of references is always a random number. 3)Also the called functions names are also an empty string. Code: bool runOnModule(llvm::Module &M) override { CallGraph cg = CallGraph(M); cg.dump();// this is correct. It is printing the expected the call graph for ( CallGraph::const_iterator itr = cg.begin(), ie = cg.end() ; itr != ie; itr++) { if (itr->second != nullptr) { itr->second->dump(); errs()<<"-----------CGN---------\n"; CallGraphNode *cgn = itr->second.get(); if(const Function* fptr = cgn->getFunction()) { errs()<<"Number of references are"<<cgn->getNumReferences()<<"\n"; errs()<<fptr->getName()<<"\n"; if(cgn->operator[](0) != nullptr) { if(cgn->operator[](0)->getFunction() != nullptr) { errs()<<cgn->operator[](0)->getFunction()->getName()<<"\n"; } } } } } } Thanks and regards -Ketan Patil -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170713/66bcaaaf/attachment-0001.html>