30#ifndef PTACALLGRAPH_H_
31#define PTACALLGRAPH_H_
41class PTACallGraphNode;
160 o <<
edge.toString();
165 virtual const std::string
toString()
const;
211 virtual const std::string
toString()
const;
243 typedef std::pair<const CallICFGNode*, const SVFFunction*>
CallSitePair;
280 std::pair<const CallICFGNode*, const SVFFunction*>
newCS(std::make_pair(cs,
callee));
296 edge->getDstNode()->addIncomingEdge(
edge);
297 edge->getSrcNode()->addOutgoingEdge(
edge);
375 assert(
it !=
csToIdMap.end() &&
"callsite id not found! This maybe a partially resolved callgraph, please check the indCallEdge limit");
386 IdToCallSiteMap::const_iterator
it =
idToCSMap.find(
id);
418 callees.insert((*it)->getDstNode()->getFunction());
434 &&
"call instruction does not have a valid callee");
435 return it->second.begin();
441 &&
"call instruction does not have a valid callee");
442 return it->second.end();
const SVFFunction * getCaller() const
Return callsite.
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.
CallInstSet & getIndirectCalls()
virtual const std::string toString() const
CallInstSet::const_iterator indirectCallsEnd() const
static GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
Compute the unique edgeFlag value from edge kind and CallSiteID.
CallInstSet indirectCalls
const CallInstSet & getIndirectCalls() const
bool isIndirectCallEdge() const
CallInstSet::const_iterator directCallsBegin() const
Iterators for direct and indirect callsites.
CallInstSet & getDirectCalls()
friend OutStream & operator<<(OutStream &o, const PTACallGraphEdge &edge)
Overloading operator << for dumping ICFG node ID.
bool isDirectCallEdge() const
void addDirectCallSite(const CallICFGNode *call)
Add direct and indirect callsite.
PTACallGraphEdge(PTACallGraphNode *s, PTACallGraphNode *d, CEDGEK kind, CallSiteID cs)
Constructor.
GenericNode< PTACallGraphNode, PTACallGraphEdge >::GEdgeSetTy CallGraphEdgeSet
const CallInstSet & getDirectCalls() const
CallInstSet::const_iterator directCallsEnd() const
void addInDirectCallSite(const CallICFGNode *call)
static bool classof(const PTACallGraphEdge *)
ClassOf.
Set< const CallICFGNode * > CallInstSet
static bool classof(const GenericPTACallGraphEdgeTy *edge)
virtual ~PTACallGraphEdge()
Destructor.
CallSiteID getCallSiteID() const
Get direct and indirect calls.
CallInstSet::const_iterator indirectCallsBegin() const
const SVFFunction * getFunction() const
Get function of this call node.
static bool classof(const SVFBaseNode *node)
friend OutStream & operator<<(OutStream &o, const PTACallGraphNode &node)
Overloading operator << for dumping ICFG node ID.
virtual const std::string toString() const
static bool classof(const GenericICFGNodeTy *node)
const std::string & getName() const
static bool classof(const PTACallGraphNode *)
Methods for support type inquiry through isa, cast, and dyn_cast:
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)
const CallICFGNode * getCallSite(CallSiteID id) const
u32_t getNumOfResolvedIndCallEdge() 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.
const FunctionSet & getIndCSCallees(const CallICFGNode *cs) const
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.
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
const CallInstToCallGraphEdgesMap & getCallInstToCallGraphEdgesMap() const
void addIndirectCallGraphEdge(const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
Add indirect call edges.
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
const SVFFunction * getCallerOfCallSite(CallSiteID id) const
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
void destroy()
Clean up memory.
const CallSitePair & getCallSitePair(CallSiteID id) const
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
Get CallSiteID.
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.
CallSiteID addCallSite(const CallICFGNode *cs, const SVFFunction *callee)
Add CallSiteID.
FunToCallGraphNodeMap funToCallGraphNodeMap
Call Graph node map.
PTACallGraphNode * getCallGraphNode(const SVFFunction *fun) const
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.
const SVFFunction * getCalleeOfCallSite(CallSiteID id) const
bool hasCallSiteID(const CallICFGNode *cs, const SVFFunction *callee) const
u32_t getTotalCallSiteNumber() const
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.
CGEK getKind() const
Return type of this callgraph.
CallEdgeMap indirectCallMap
Indirect call map.
u32_t numOfResolvedIndCallEdge
Map< CallSitePair, CallSiteID > CallSiteToIdMap
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
bool hasCallGraphEdge(const CallICFGNode *inst) const
Get call graph edge via call instruction.
GNodeK getNodeKind() const
Get node kind.
const std::string & getName() const
GenericEdge< PTACallGraphNode > GenericPTACallGraphEdgeTy
GenericGraph< PTACallGraphNode, PTACallGraphEdge > GenericPTACallGraphTy
GenericNode< PTACallGraphNode, PTACallGraphEdge > GenericPTACallGraphNodeTy
llvm::IRBuilder IRBuilder
SVF::PTACallGraphNode * NodeRef