39using namespace SVFUtil;
56 "not an indirect callsite??");
84 std::stack<const PTACallGraphNode*> nodeStack;
89 while (nodeStack.empty() ==
false)
101 nodeStack.push(
edge->getSrcNode());
133 for (
const auto&
item :
other.callinstToCallGraphEdgesMap)
143 newEdge->addDirectCallSite(cs);
184 for (PTACallGraphEdge::CallGraphEdgeSet::iterator
iter = src->
OutEdgeBegin();
211 edge->addInDirectCallSite(cs);
226 for(PTACallGraphEdge::CallInstSet::const_iterator
cit = (*it)->directCallsBegin(),
231 for(PTACallGraphEdge::CallInstSet::const_iterator
cit = (*it)->indirectCallsBegin(),
248 for(PTACallGraphEdge::CallInstSet::const_iterator
cit = (*it)->directCallsBegin(),
265 for(PTACallGraphEdge::CallInstSet::const_iterator
cit = (*it)->indirectCallsBegin(),
300 std::stack<const PTACallGraphNode*> nodeStack;
305 while (nodeStack.empty() ==
false)
317 nodeStack.push(
edge->getSrcNode());
373 return "shape=Mrecord";
376 template<
class EdgeIter>
389 color =
"color=green";
393 color =
"color=blue";
397 color =
"color=black";
399 if (0 !=
edge->getIndirectCalls().size())
406 template<
class EdgeIter>
const SVFFunction * getCalledFunction() const
const SVFFunction * getCaller() const
Return callsite.
NodeID getSrcID() const
get methods of the components
void addGNode(NodeID id, NodeType *node)
Add a Node.
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
GEdgeSetTy::iterator iterator
iterator OutEdgeBegin()
iterators
GEdgeSetTy::const_iterator const_iterator
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
virtual const std::string toString() const
CallInstSet indirectCalls
bool isDirectCallEdge() const
void addDirectCallSite(const CallICFGNode *call)
Add direct and indirect callsite.
void addInDirectCallSite(const CallICFGNode *call)
Set< const CallICFGNode * > CallInstSet
CallSiteID getCallSiteID() const
Get direct and indirect calls.
const SVFFunction * getFunction() const
Get function of this call node.
virtual const std::string toString() const
bool isReachableFromProgEntry() const
Return TRUE if this function can be reached from main.
void getDirCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
PTACallGraphEdge * getGraphEdge(PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId)
Get call graph edge via nodes.
static CallSiteID totalCallSiteNum
CallSiteIDs, start from 1;.
void addEdge(PTACallGraphEdge *edge)
Add call graph edge.
void addIndirectCallGraphEdge(const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
Add indirect call edges.
static IdToCallSiteMap idToCSMap
Map a callsite ID to a pair of call instruction and callee.
Set< const SVFFunction * > FunctionSet
Map< CallSiteID, CallSitePair > IdToCallSiteMap
PTACallGraph(CGEK k=NormCallGraph)
Constructor.
void destroy()
Clean up memory.
PTACallGraphEdge * hasGraphEdge(PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const
Whether we have already created this call graph edge.
static CallSiteToIdMap csToIdMap
Call site information.
void view()
View the graph from the debugger.
void getAllCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
Get callsites invoking the callee.
void dump(const std::string &filename)
Dump the graph.
CallSiteID addCallSite(const CallICFGNode *cs, const SVFFunction *callee)
Add CallSiteID.
FunToCallGraphNodeMap funToCallGraphNodeMap
Call Graph node map.
void getIndCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter
bool isReachableBetweenFunctions(const SVFFunction *srcFn, const SVFFunction *dstFn) const
Whether its reachable between two functions.
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
Map a call instruction to its corresponding call edges.
void verifyCallGraph()
Issue a warning if the function which has indirect call sites can not be reached from program entry.
CallEdgeMap indirectCallMap
Indirect call map.
u32_t numOfResolvedIndCallEdge
Map< CallSitePair, CallSiteID > CallSiteToIdMap
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
NodeID getId() const
Get ID.
const std::string & getName() const
bool isExtCall(const SVFFunction *fun)
bool isProgEntryFunction(const SVFFunction *fun)
Program entry function e.g. main.
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
const ValVar * getForkedFun(const CallICFGNode *inst)
Return thread fork function.
std::ostream & outs()
Overwrite llvm::outs()
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)
llvm::IRBuilder IRBuilder
static std::string getEdgeSourceLabel(NodeType *, EdgeIter EI)
static std::string getEdgeAttributes(PTACallGraphNode *, EdgeIter EI, PTACallGraph *)
PTACallGraphNode NodeType
static std::string getGraphName(PTACallGraph *)
Return name of the graph.
DOTGraphTraits(bool isSimple=false)
static std::string getNodeLabel(PTACallGraphNode *node, PTACallGraph *)
Return function name;.
NodeType::iterator ChildIteratorType
static std::string getNodeAttributes(PTACallGraphNode *node, PTACallGraph *)