<div dir="ltr"><div>I want to do the DFS traversal on the call graph starting from the main method or the root node present in the CallGraph.<br>I have written the following module pass. <br>I
am constructing the call graph for the module. And then dumping it onto
the console, it shows the correct Call graph onto the console. It gives
me the root of the call graph. And all the called functions from the
root are the nodes in the next level. And so on. <br>But now I want to traverse it. There is no way to get the root of the CallGraph because it is the private member. <br>In
the following code, I am first obtaining the node corresponding to the
'main' method by 3rd and 4th line of code. But then I am unable to
traverse further. There is nothing to obtain the nodes which are the
successor of the node corresponding to main method. <br><br>bool runOnModule(Module &M) override<br>{<br> <br> CallGraph cg = CallGraph(M); //generate the call graph of the module M <br> cg.dump(); //print the call graph on the console <br> Function *f = M.getFunction("main"); <br> CallGraphNode &cgn = *cg.operator[](f);<br> for(CallGraphNode::iterator itr = cgn->begin(); itr!= cgn->end();++itr)<br> {<br> <br> //the following 2 statements always gives the segmentation fault<br> const Value * V = itr->first;<br> CallGraphNode* calleeNode = itr->second;<br></div><div><div><div><div><div><div> <br></div><div> //how to traverse further???? <br></div><div> }<br><br>}<br><br><br><div><div class="gmail_signature"><div dir="ltr"><span>Thanks and regards<div>-Ketan Patil</div></span></div></div></div>
</div></div></div></div></div></div></div>