30 #ifndef PTACALLGRAPH_H_
31 #define PTACALLGRAPH_H_
41 class PTACallGraphNode;
179 typedef PTACallGraphEdge::CallGraphEdgeSet::iterator
iterator;
248 typedef std::pair<const CallICFGNode*, const SVFFunction*>
CallSitePair;
356 std::pair<const CallICFGNode*, const SVFFunction*> newCS(std::make_pair(cs, callee));
357 CallSiteToIdMap::const_iterator it =
csToIdMap.find(newCS);
362 csToIdMap.insert(std::make_pair(newCS,
id));
363 idToCSMap.insert(std::make_pair(
id, newCS));
371 CallSiteToIdMap::const_iterator it =
csToIdMap.find(newCS);
372 assert(it !=
csToIdMap.end() &&
"callsite id not found! This maybe a partially resolved callgraph, please check the indCallEdge limit");
378 CallSiteToIdMap::const_iterator it =
csToIdMap.find(newCS);
383 IdToCallSiteMap::const_iterator it =
idToCSMap.find(
id);
384 assert(it !=
idToCSMap.end() &&
"cannot find call site for this CallSiteID");
415 callees.insert((*it)->getDstNode()->getFunction());
431 &&
"call instruction does not have a valid callee");
432 return it->second.begin();
438 &&
"call instruction does not have a valid callee");
439 return it->second.end();
451 void addDirectCallGraphEdge(
const CallICFGNode* call,
const SVFFunction* callerFun,
const SVFFunction* calleeFun);
const SVFFunction * getCaller() const
Return callsite.
NodeType * getSrcNode() const
GEdgeKind getEdgeKind() const
NodeType * getDstNode() const
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
NodeType * getGNode(NodeID id) const
Get a node.
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
virtual const std::string toString() const
friend OutStream & operator<<(OutStream &o, const PTACallGraphEdge &edge)
Overloading operator << for dumping ICFG node ID.
CallInstSet::const_iterator indirectCallsEnd() const
static GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
Compute the unique edgeFlag value from edge kind and CallSiteID.
const CallInstSet & getIndirectCalls() const
const CallInstSet & getDirectCalls() const
CallInstSet indirectCalls
bool isIndirectCallEdge() const
CallInstSet::const_iterator directCallsBegin() const
Iterators for direct and indirect callsites.
CallInstSet & getIndirectCalls()
GenericNode< PTACallGraphNode, PTACallGraphEdge >::GEdgeSetTy CallGraphEdgeSet
bool isDirectCallEdge() const
void addDirectCallSite(const CallICFGNode *call)
Add direct and indirect callsite.
PTACallGraphEdge(PTACallGraphNode *s, PTACallGraphNode *d, CEDGEK kind, CallSiteID cs)
Constructor.
CallInstSet::const_iterator directCallsEnd() const
void addInDirectCallSite(const CallICFGNode *call)
static bool classof(const PTACallGraphEdge *)
ClassOf.
Set< const CallICFGNode * > CallInstSet
CallInstSet & getDirectCalls()
virtual ~PTACallGraphEdge()
Destructor.
CallSiteID getCallSiteID() const
Get direct and indirect calls.
static bool classof(const GenericCallGraphEdgeTy *edge)
CallInstSet::const_iterator indirectCallsBegin() const
static bool classof(const SVFBaseNode *node)
friend OutStream & operator<<(OutStream &o, const PTACallGraphNode &node)
Overloading operator << for dumping ICFG node ID.
const std::string & getName() const
virtual const std::string toString() const
PTACallGraphEdge::CallGraphEdgeSet::iterator iterator
static bool classof(const GenericICFGNodeTy *node)
const SVFFunction * getFunction() const
Get function of this call node.
PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet
static bool classof(const PTACallGraphNode *)
Methods for support type inquiry through isa, cast, and dyn_cast:
PTACallGraphEdge::CallGraphEdgeSet::const_iterator const_iterator
bool isReachableFromProgEntry() const
Return TRUE if this function can be reached from main.
PTACallGraphNode(NodeID i, const SVFFunction *f)
Constructor.
Map< const CallICFGNode *, CallGraphEdgeSet > CallInstToCallGraphEdgesMap
void getDirCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
u32_t getNumOfResolvedIndCallEdge() const
const CallICFGNode * getCallSite(CallSiteID id) const
CallGraphEdgeSet::const_iterator getCallEdgeEnd(const CallICFGNode *inst) const
std::pair< const CallICFGNode *, const SVFFunction * > CallSitePair
PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet
PTACallGraphEdge * getGraphEdge(PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId)
Get call graph edge via nodes.
static CallSiteID totalCallSiteNum
CallSiteIDs, start from 1;.
CallGraphEdgeSet::iterator CallGraphEdgeIter
void addEdge(PTACallGraphEdge *edge)
Add call graph edge.
void getCallees(const CallICFGNode *cs, FunctionSet &callees)
Get all callees for a callsite.
const CallInstToCallGraphEdgesMap & getCallInstToCallGraphEdgesMap() const
const SVFFunction * getCallerOfCallSite(CallSiteID id) const
void addIndirectCallGraphEdge(const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
CallGraphEdgeSet::const_iterator getCallEdgeBegin(const CallICFGNode *inst) const
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 addDirectCallGraphEdge(const CallICFGNode *call, const SVFFunction *callerFun, const SVFFunction *calleeFun)
Add direct/indirect call edges.
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.
CallSiteID getCallSiteID(const CallICFGNode *cs, const SVFFunction *callee) const
bool hasIndCSCallees(const CallICFGNode *cs) const
static CallSiteToIdMap csToIdMap
Call site information.
void view()
View the graph from the debugger.
virtual ~PTACallGraph()
Destructor.
void getAllCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
Get callsites invoking the callee.
void dump(const std::string &filename)
Dump the graph.
void addCallGraphNode(const SVFFunction *fun)
const CallSitePair & getCallSitePair(CallSiteID id) const
CallSiteID addCallSite(const CallICFGNode *cs, const SVFFunction *callee)
Add/Get CallSiteID.
FunToCallGraphNodeMap funToCallGraphNodeMap
Call Graph node map.
void getIndCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter
Map< const SVFFunction *, PTACallGraphNode * > FunToCallGraphNodeMap
bool isReachableBetweenFunctions(const SVFFunction *srcFn, const SVFFunction *dstFn) const
Whether its reachable between two functions.
bool hasCallSiteID(const CallICFGNode *cs, const SVFFunction *callee) const
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
u32_t getTotalCallSiteNumber() const
const SVFFunction * getCalleeOfCallSite(CallSiteID id) const
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
Map a call instruction to its corresponding call edges.
const FunctionSet & getIndCSCallees(const CallICFGNode *cs) const
void verifyCallGraph()
Issue a warning if the function which has indirect call sites can not be reached from program entry.
CGEK getKind() const
Return type of this callgraph.
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
CallEdgeMap indirectCallMap
Indirect call map.
u32_t numOfResolvedIndCallEdge
PTACallGraphNode * getCallGraphNode(const SVFFunction *fun) const
Map< CallSitePair, CallSiteID > CallSiteToIdMap
bool hasCallGraphEdge(const CallICFGNode *inst) const
Get call graph edge via call instruction.
GNodeK getNodeKind() const
Get node kind.
const std::string & getName() const
GenericNode< PTACallGraphNode, PTACallGraphEdge > GenericCallGraphNodeTy
GenericGraph< PTACallGraphNode, PTACallGraphEdge > GenericCallGraphTy
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
GenericEdge< PTACallGraphNode > GenericCallGraphEdgeTy
std::map< Key, Value, Compare, Allocator > OrderedMap
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
SVF::PTACallGraphNode * NodeRef