39using namespace SVFUtil;
63 "not an indirect callsite??");
145 for (
const auto&
item :
other.callinstToCallGraphEdgesMap)
155 newEdge->addDirectCallSite(cs);
235 edge->addInDirectCallSite(cs);
250 for(CallGraphEdge::CallInstSet::const_iterator
cit = (*it)->directCallsBegin(),
255 for(CallGraphEdge::CallInstSet::const_iterator
cit = (*it)->indirectCallsBegin(),
272 for(CallGraphEdge::CallInstSet::const_iterator
cit = (*it)->directCallsBegin(),
289 for(CallGraphEdge::CallInstSet::const_iterator
cit = (*it)->indirectCallsBegin(),
318 writeWrnMsg(
func->getName() +
" has indirect call site but not reachable from main");
330 std::stack<const CallGraphNode*> nodeStack;
335 while (nodeStack.empty() ==
false)
347 nodeStack.push(
edge->getSrcNode());
387 for (
const auto&
item : *
this)
408 edge->addDirectCallSite(cs);
455 return "shape=Mrecord";
458 template<
class EdgeIter>
471 color =
"color=green";
475 color =
"color=blue";
479 color =
"color=black";
481 if (0 !=
edge->getIndirectCalls().size())
488 template<
class EdgeIter>
NodeID getId() const
Get the memory object id.
void addInDirectCallSite(const CallICFGNode *call)
void addDirectCallSite(const CallICFGNode *call)
Add direct and indirect callsite.
CallInstSet indirectCalls
virtual const std::string toString() const
bool isDirectCallEdge() const
Set< const CallICFGNode * > CallInstSet
CallSiteID getCallSiteID() const
Get direct and indirect calls.
const FunObjVar * getFunction() const
Get function of this call node.
const std::string & getName() const
virtual const std::string toString() const
bool isReachableFromProgEntry(Map< NodeID, bool > &reachableFromEntry, NodeBS &visitedNodes) const
Return TRUE if this function can be reached from main.
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
Map a call instruction to its corresponding call edges.
void getAllCallSitesInvokingCallee(const FunObjVar *callee, CallGraphEdge::CallInstSet &csSet)
Get callsites invoking the callee.
void addIndirectCallGraphEdge(const CallICFGNode *cs, const FunObjVar *callerFun, const FunObjVar *calleeFun)
Add indirect call edges.
CallGraphEdge * hasGraphEdge(CallGraphEdge *cgEdge) const
Whether we have already created this call graph edge.
CallEdgeMap indirectCallMap
Indirect call map.
void addCallGraphNode(CallGraphNode *cgNode)
add call graph node from database [only used this function when loading cgNodes from db results]
void addEdge(CallGraphEdge *edge)
Add call graph edge.
const FunObjVar * getCallerOfCallSite(CallSiteID id) const
void getIndCallSitesInvokingCallee(const FunObjVar *callee, CallGraphEdge::CallInstSet &csSet)
static IdToCallSiteMap idToCSMap
Map a callsite ID to a pair of call instruction and callee.
static CallSiteID totalCallSiteNum
CallSiteIDs, start from 1;.
Map< CallSiteID, CallSitePair > IdToCallSiteMap
const CallGraphNode * getCallGraphNode(const std::string &name) const
Get call graph node.
void destroy()
Clean up memory.
CallSiteID addCallSite(const CallICFGNode *cs, const FunObjVar *callee)
Add CallSiteID.
FunToCallGraphNodeMap funToCallGraphNodeMap
Call Graph node map.
CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter
CallGraph(CGEK k=NormCallGraph)
Constructor.
static CallSiteToIdMap csToIdMap
Call site information.
const CallICFGNode * getCallSite(CallSiteID id) const
bool isReachableBetweenFunctions(const FunObjVar *srcFn, const FunObjVar *dstFn) const
Whether its reachable between two functions.
void view()
View the graph from the debugger.
void dump(const std::string &filename)
Dump the graph.
void getDirCallSitesInvokingCallee(const FunObjVar *callee, CallGraphEdge::CallInstSet &csSet)
void verifyCallGraph()
Issue a warning if the function which has indirect call sites can not be reached from program entry.
u32_t numOfResolvedIndCallEdge
CallGraphEdge * getGraphEdge(CallGraphNode *src, CallGraphNode *dst, CallGraphEdge::CEDGEK kind, CallSiteID csId)
Get call graph edge via nodes.
Map< CallSitePair, CallSiteID > CallSiteToIdMap
void addDirectCallGraphEdge(CallGraphEdge *cgEdge)
add direct call graph edge from database [only used this function when loading cgEdges from db result...
Set< const FunObjVar * > FunctionSet
const FunObjVar * getCalledFunction() const
const FunObjVar * getCaller() const
Return callsite.
NodeType * getSrcNode() const
NodeType * getDstNode() const
NodeID getSrcID() const
get methods of the components
void addGNode(NodeID id, NodeType *node)
Add a Node.
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)
static const Option< bool > DisableWarn
NodeID getId() const
Get ID.
virtual const std::string & getName() const
bool isProgEntryFunction(const FunObjVar *)
Program entry function e.g. main.
bool isExtCall(const FunObjVar *fun)
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
DOTGraphTraits(bool isSimple=false)
static std::string getNodeAttributes(CallGraphNode *node, CallGraph *)
static std::string getGraphName(CallGraph *)
Return name of the graph.
static std::string getNodeLabel(CallGraphNode *node, CallGraph *)
Return function name;.
static std::string getEdgeSourceLabel(NodeType *, EdgeIter EI)
static std::string getEdgeAttributes(CallGraphNode *, EdgeIter EI, CallGraph *)
NodeType::iterator ChildIteratorType