[llvm-dev] Why getFunction() of CallGraphNode return NULL function?

Qiuping Yi via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 19 04:05:06 PST 2016


Hi all,

I want to find all the called functions in each function, thus I iterate
the calledFunctions of each CallGraphNode in CallGraph as follow:

for (CallGraph::iterator it = CG->begin(); it != CG->end(); ++it) {
   CallGraphNode* node = it->second;
   for (CallGraphNode::iterator it2 = node->begin(); it2 != node->end();
++it2) {
      Function* calledFunc = it2->second=>getFunction();
      cerr << ”function: “ << calledFunc->getName().str() <<"\n";  *//
crash some times*
      ... ...
      ... ...
    }
}

I found that some time "calledFunc" is NULL function and thus the output
crash. I don't known why? If the before code is wrong, so what is the
correct method for get all the called functions?

I use LLVM 3.6. Thank you all in advance.

--------------------------------------------
Qiuping Yi
Institute Of Software
Chinese Academy of Sciences
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160119/d2b9d630/attachment.html>


More information about the llvm-dev mailing list