Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
SVF::PTACallGraph Class Reference

#include <PTACallGraph.h>

Inheritance diagram for SVF::PTACallGraph:
SVF::GenericGraph< NodeTy, EdgeTy > SVF::ThreadCallGraph

Public Types

enum  CGEK { NormCallGraph , ThdCallGraph }
 
typedef PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet
 
typedef Map< const SVFFunction *, PTACallGraphNode * > FunToCallGraphNodeMap
 
typedef Map< const CallICFGNode *, CallGraphEdgeSetCallInstToCallGraphEdgesMap
 
typedef std::pair< const CallICFGNode *, const SVFFunction * > CallSitePair
 
typedef Map< CallSitePair, CallSiteIDCallSiteToIdMap
 
typedef Map< CallSiteID, CallSitePairIdToCallSiteMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
typedef CallGraphEdgeSet::iterator CallGraphEdgeIter
 
typedef CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter
 
- Public Types inherited from SVF::GenericGraph< NodeTy, EdgeTy >
typedef NodeTy NodeType
 
typedef EdgeTy EdgeType
 
typedef OrderedMap< NodeID, NodeType * > IDToNodeMapTy
 NodeID to GenericNode map.
 
typedef IDToNodeMapTy::iterator iterator
 Node Iterators.
 
typedef IDToNodeMapTy::const_iterator const_iterator
 

Public Member Functions

 PTACallGraph (CGEK k=NormCallGraph)
 Constructor.
 
 PTACallGraph (const CallGraph &other)
 Copy constructor.
 
virtual ~PTACallGraph ()
 Destructor.
 
CGEK getKind () const
 Return type of this callgraph.
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite.
 
bool hasIndCSCallees (const CallICFGNode *cs) const
 
const FunctionSetgetIndCSCallees (const CallICFGNode *cs) const
 
u32_t getTotalCallSiteNumber () const
 
u32_t getNumOfResolvedIndCallEdge () const
 
const CallInstToCallGraphEdgesMapgetCallInstToCallGraphEdgesMap () const
 
void verifyCallGraph ()
 Issue a warning if the function which has indirect call sites can not be reached from program entry.
 
PTACallGraphNodegetCallGraphNode (NodeID id) const
 Get call graph node.
 
PTACallGraphNodegetCallGraphNode (const SVFFunction *fun) const
 
CallSiteID getCallSiteID (const CallICFGNode *cs, const SVFFunction *callee) const
 Get CallSiteID.
 
bool hasCallSiteID (const CallICFGNode *cs, const SVFFunction *callee) const
 
const CallSitePairgetCallSitePair (CallSiteID id) const
 
const CallICFGNodegetCallSite (CallSiteID id) const
 
const SVFFunctiongetCallerOfCallSite (CallSiteID id) const
 
const SVFFunctiongetCalleeOfCallSite (CallSiteID id) const
 
PTACallGraphEdgehasGraphEdge (PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const
 Whether we have already created this call graph edge.
 
PTACallGraphEdgegetGraphEdge (PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId)
 Get call graph edge via nodes.
 
void getCallees (const CallICFGNode *cs, FunctionSet &callees)
 Get all callees for a callsite.
 
bool hasCallGraphEdge (const CallICFGNode *inst) const
 Get call graph edge via call instruction.
 
CallGraphEdgeSet::const_iterator getCallEdgeBegin (const CallICFGNode *inst) const
 
CallGraphEdgeSet::const_iterator getCallEdgeEnd (const CallICFGNode *inst) const
 
void addIndirectCallGraphEdge (const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
 Add indirect call edges.
 
void getAllCallSitesInvokingCallee (const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
 Get callsites invoking the callee.
 
void getDirCallSitesInvokingCallee (const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
 
void getIndCallSitesInvokingCallee (const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
 
bool isReachableBetweenFunctions (const SVFFunction *srcFn, const SVFFunction *dstFn) const
 Whether its reachable between two functions.
 
void dump (const std::string &filename)
 Dump the graph.
 
void view ()
 View the graph from the debugger.
 
- Public Member Functions inherited from SVF::GenericGraph< NodeTy, EdgeTy >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
NodeTypegetGNode (NodeID id) const
 Get a node.
 
bool hasGNode (NodeID id) const
 Has a node.
 
void removeGNode (NodeType *node)
 Delete a node.
 
u32_t getTotalNodeNum () const
 Get total number of node/edge.
 
u32_t getTotalEdgeNum () const
 
void incNodeNum ()
 Increase number of node/edge.
 
void incEdgeNum ()
 

Protected Member Functions

void destroy ()
 Clean up memory.
 
CallSiteID addCallSite (const CallICFGNode *cs, const SVFFunction *callee)
 Add CallSiteID.
 
void addEdge (PTACallGraphEdge *edge)
 Add call graph edge.
 

Protected Attributes

FunToCallGraphNodeMap funToCallGraphNodeMap
 Call Graph node map.
 
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
 Map a call instruction to its corresponding call edges.
 
NodeID callGraphNodeNum
 
u32_t numOfResolvedIndCallEdge
 
CGEK kind
 
- Protected Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
IDToNodeMapTy IDToNodeMap
 node map
 

Private Attributes

CallEdgeMap indirectCallMap
 Indirect call map.
 

Static Private Attributes

static CallSiteToIdMap csToIdMap
 Call site information.
 
static IdToCallSiteMap idToCSMap
 Map a callsite ID to a pair of call instruction and callee.
 
static CallSiteID totalCallSiteNum =1
 CallSiteIDs, start from 1;.
 

Additional Inherited Members

- Public Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
u32_t edgeNum
 total num of node
 
u32_t nodeNum
 total num of edge
 

Detailed Description

Definition at line 236 of file PTACallGraph.h.

Member Typedef Documentation

◆ CallEdgeMap

Definition at line 247 of file PTACallGraph.h.

◆ CallGraphEdgeConstIter

typedef CallGraphEdgeSet::const_iterator SVF::PTACallGraph::CallGraphEdgeConstIter

Definition at line 249 of file PTACallGraph.h.

◆ CallGraphEdgeIter

typedef CallGraphEdgeSet::iterator SVF::PTACallGraph::CallGraphEdgeIter

Definition at line 248 of file PTACallGraph.h.

◆ CallGraphEdgeSet

Definition at line 240 of file PTACallGraph.h.

◆ CallInstToCallGraphEdgesMap

Definition at line 242 of file PTACallGraph.h.

◆ CallSitePair

Definition at line 243 of file PTACallGraph.h.

◆ CallSiteToIdMap

Definition at line 244 of file PTACallGraph.h.

◆ FunctionSet

Definition at line 246 of file PTACallGraph.h.

◆ FunToCallGraphNodeMap

Definition at line 241 of file PTACallGraph.h.

◆ IdToCallSiteMap

Definition at line 245 of file PTACallGraph.h.

Member Enumeration Documentation

◆ CGEK

Enumerator
NormCallGraph 
ThdCallGraph 

Definition at line 251 of file PTACallGraph.h.

Constructor & Destructor Documentation

◆ PTACallGraph() [1/2]

PTACallGraph::PTACallGraph ( CGEK  k = NormCallGraph)

Constructor.

Definition at line 110 of file PTACallGraph.cpp.

110 : kind(k)
111{
114}
u32_t numOfResolvedIndCallEdge
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ PTACallGraph() [2/2]

PTACallGraph::PTACallGraph ( const CallGraph other)

Copy constructor.

copy call graph nodes

copy edges

Definition at line 117 of file PTACallGraph.cpp.

118{
119 callGraphNodeNum = other.getTotalNodeNum();
122
124 for (const auto& item : other)
125 {
126 const CallGraphNode* cgn = item.second;
127 PTACallGraphNode* callGraphNode = new PTACallGraphNode(cgn->getId(), cgn->getFunction());
128 addGNode(cgn->getId(),callGraphNode);
129 funToCallGraphNodeMap[cgn->getFunction()] = callGraphNode;
130 }
131
133 for (const auto& item : other.callinstToCallGraphEdgesMap)
134 {
135 const CallICFGNode* cs = item.first;
136 for (const CallGraphEdge* edge : item.second)
137 {
138 PTACallGraphNode* src = getCallGraphNode(edge->getSrcID());
139 PTACallGraphNode* dst = getCallGraphNode(edge->getDstID());
140 CallSiteID csId = addCallSite(cs, dst->getFunction());
141
143 newEdge->addDirectCallSite(cs);
146 }
147 }
148
149}
cJSON * item
Definition cJSON.h:222
void addGNode(NodeID id, NodeType *node)
Add a Node.
const SVFFunction * getFunction() const
Get function of this call node.
void addEdge(PTACallGraphEdge *edge)
Add call graph edge.
CallSiteID addCallSite(const CallICFGNode *cs, const SVFFunction *callee)
Add CallSiteID.
FunToCallGraphNodeMap funToCallGraphNodeMap
Call Graph node map.
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
Map a call instruction to its corresponding call edges.
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
unsigned CallSiteID
Definition GeneralType.h:58

◆ ~PTACallGraph()

virtual SVF::PTACallGraph::~PTACallGraph ( )
inlinevirtual

Destructor.

Definition at line 308 of file PTACallGraph.h.

309 {
310 destroy();
311 }
void destroy()
Clean up memory.

Member Function Documentation

◆ addCallSite()

CallSiteID SVF::PTACallGraph::addCallSite ( const CallICFGNode cs,
const SVFFunction callee 
)
inlineprotected

Add CallSiteID.

Definition at line 278 of file PTACallGraph.h.

279 {
280 std::pair<const CallICFGNode*, const SVFFunction*> newCS(std::make_pair(cs, callee));
281 CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
282 //assert(it == csToIdMap.end() && "cannot add a callsite twice");
283 if(it == csToIdMap.end())
284 {
286 csToIdMap.insert(std::make_pair(newCS, id));
287 idToCSMap.insert(std::make_pair(id, newCS));
288 return id;
289 }
290 return it->second;
291 }
static CallSiteID totalCallSiteNum
CallSiteIDs, start from 1;.
static IdToCallSiteMap idToCSMap
Map a callsite ID to a pair of call instruction and callee.
static CallSiteToIdMap csToIdMap
Call site information.

◆ addEdge()

void SVF::PTACallGraph::addEdge ( PTACallGraphEdge edge)
inlineprotected

Add call graph edge.

Definition at line 294 of file PTACallGraph.h.

295 {
296 edge->getDstNode()->addIncomingEdge(edge);
297 edge->getSrcNode()->addOutgoingEdge(edge);
298 }

◆ addIndirectCallGraphEdge()

void PTACallGraph::addIndirectCallGraphEdge ( const CallICFGNode cs,
const SVFFunction callerFun,
const SVFFunction calleeFun 
)

Add indirect call edges.

Add indirect call edge to update call graph

Definition at line 198 of file PTACallGraph.cpp.

199{
200
203
205
206 CallSiteID csId = addCallSite(cs, callee->getFunction());
207
209 {
211 edge->addInDirectCallSite(cs);
212 addEdge(edge);
214 }
215}
PTACallGraphEdge * hasGraphEdge(PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const
Whether we have already created this call graph edge.

◆ destroy()

void PTACallGraph::destroy ( )
protected

Clean up memory.

Memory has been cleaned up at GenericGraph

Definition at line 154 of file PTACallGraph.cpp.

155{
156}

◆ dump()

void PTACallGraph::dump ( const std::string &  filename)

Dump the graph.

Dump call graph into dot file

Definition at line 327 of file PTACallGraph.cpp.

328{
330}
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50

◆ getAllCallSitesInvokingCallee()

void PTACallGraph::getAllCallSitesInvokingCallee ( const SVFFunction callee,
PTACallGraphEdge::CallInstSet csSet 
)

Get callsites invoking the callee.

Get all callsite invoking this callee

Definition at line 220 of file PTACallGraph.cpp.

221{
222 PTACallGraphNode* callGraphNode = getCallGraphNode(callee);
223 for(PTACallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd();
224 it!=eit; ++it)
225 {
226 for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->directCallsBegin(),
227 ecit = (*it)->directCallsEnd(); cit!=ecit; ++cit)
228 {
229 csSet.insert((*cit));
230 }
231 for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->indirectCallsBegin(),
232 ecit = (*it)->indirectCallsEnd(); cit!=ecit; ++cit)
233 {
234 csSet.insert((*cit));
235 }
236 }
237}
GEdgeSetTy::iterator iterator
iterator InEdgeBegin()
iterator InEdgeEnd()

◆ getCallEdgeBegin()

CallGraphEdgeSet::const_iterator SVF::PTACallGraph::getCallEdgeBegin ( const CallICFGNode inst) const
inline

Definition at line 430 of file PTACallGraph.h.

431 {
432 CallInstToCallGraphEdgesMap::const_iterator it = callinstToCallGraphEdgesMap.find(inst);
434 && "call instruction does not have a valid callee");
435 return it->second.begin();
436 }

◆ getCallEdgeEnd()

CallGraphEdgeSet::const_iterator SVF::PTACallGraph::getCallEdgeEnd ( const CallICFGNode inst) const
inline

Definition at line 437 of file PTACallGraph.h.

438 {
439 CallInstToCallGraphEdgesMap::const_iterator it = callinstToCallGraphEdgesMap.find(inst);
441 && "call instruction does not have a valid callee");
442 return it->second.end();
443 }

◆ getCalleeOfCallSite()

const SVFFunction * SVF::PTACallGraph::getCalleeOfCallSite ( CallSiteID  id) const
inline

Definition at line 398 of file PTACallGraph.h.

399 {
400 return getCallSitePair(id).second;
401 }
const CallSitePair & getCallSitePair(CallSiteID id) const

◆ getCallees()

void SVF::PTACallGraph::getCallees ( const CallICFGNode cs,
FunctionSet callees 
)
inline

Get all callees for a callsite.

Definition at line 411 of file PTACallGraph.h.

412 {
413 if(hasCallGraphEdge(cs))
414 {
415 for (CallGraphEdgeSet::const_iterator it = getCallEdgeBegin(cs), eit =
416 getCallEdgeEnd(cs); it != eit; ++it)
417 {
418 callees.insert((*it)->getDstNode()->getFunction());
419 }
420 }
421 }
CallGraphEdgeSet::const_iterator getCallEdgeEnd(const CallICFGNode *inst) const
CallGraphEdgeSet::const_iterator getCallEdgeBegin(const CallICFGNode *inst) const
bool hasCallGraphEdge(const CallICFGNode *inst) const
Get call graph edge via call instruction.

◆ getCallerOfCallSite()

const SVFFunction * SVF::PTACallGraph::getCallerOfCallSite ( CallSiteID  id) const
inline

Definition at line 394 of file PTACallGraph.h.

395 {
396 return getCallSite(id)->getCaller();
397 }
const SVFFunction * getCaller() const
Return callsite.
Definition ICFGNode.h:470
const CallICFGNode * getCallSite(CallSiteID id) const

◆ getCallGraphNode() [1/2]

PTACallGraphNode * SVF::PTACallGraph::getCallGraphNode ( const SVFFunction fun) const
inline

Definition at line 360 of file PTACallGraph.h.

361 {
362 FunToCallGraphNodeMap::const_iterator it = funToCallGraphNodeMap.find(fun);
363 assert(it!=funToCallGraphNodeMap.end() && "call graph node not found!!");
364 return it->second;
365 }

◆ getCallGraphNode() [2/2]

PTACallGraphNode * SVF::PTACallGraph::getCallGraphNode ( NodeID  id) const
inline

Get call graph node.

Definition at line 356 of file PTACallGraph.h.

357 {
358 return getGNode(id);
359 }
NodeType * getGNode(NodeID id) const
Get a node.

◆ getCallInstToCallGraphEdgesMap()

const CallInstToCallGraphEdgesMap & SVF::PTACallGraph::getCallInstToCallGraphEdgesMap ( ) const
inline

Definition at line 346 of file PTACallGraph.h.

347 {
349 }

◆ getCallSite()

const CallICFGNode * SVF::PTACallGraph::getCallSite ( CallSiteID  id) const
inline

Definition at line 390 of file PTACallGraph.h.

391 {
392 return getCallSitePair(id).first;
393 }

◆ getCallSiteID()

CallSiteID SVF::PTACallGraph::getCallSiteID ( const CallICFGNode cs,
const SVFFunction callee 
) const
inline

Get CallSiteID.

Definition at line 371 of file PTACallGraph.h.

372 {
373 CallSitePair newCS(std::make_pair(cs, callee));
374 CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
375 assert(it != csToIdMap.end() && "callsite id not found! This maybe a partially resolved callgraph, please check the indCallEdge limit");
376 return it->second;
377 }
std::pair< const CallICFGNode *, const SVFFunction * > CallSitePair

◆ getCallSitePair()

const CallSitePair & SVF::PTACallGraph::getCallSitePair ( CallSiteID  id) const
inline

Definition at line 384 of file PTACallGraph.h.

385 {
386 IdToCallSiteMap::const_iterator it = idToCSMap.find(id);
387 assert(it != idToCSMap.end() && "cannot find call site for this CallSiteID");
388 return (it->second);
389 }

◆ getDirCallSitesInvokingCallee()

void PTACallGraph::getDirCallSitesInvokingCallee ( const SVFFunction callee,
PTACallGraphEdge::CallInstSet csSet 
)

Get direct callsite invoking this callee

Definition at line 242 of file PTACallGraph.cpp.

243{
244 PTACallGraphNode* callGraphNode = getCallGraphNode(callee);
245 for(PTACallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd();
246 it!=eit; ++it)
247 {
248 for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->directCallsBegin(),
249 ecit = (*it)->directCallsEnd(); cit!=ecit; ++cit)
250 {
251 csSet.insert((*cit));
252 }
253 }
254}

◆ getGraphEdge()

PTACallGraphEdge * PTACallGraph::getGraphEdge ( PTACallGraphNode src,
PTACallGraphNode dst,
PTACallGraphEdge::CEDGEK  kind,
CallSiteID  csId 
)

Get call graph edge via nodes.

get PTACallGraph edge via nodes

Definition at line 180 of file PTACallGraph.cpp.

183{
184 for (PTACallGraphEdge::CallGraphEdgeSet::iterator iter = src->OutEdgeBegin();
185 iter != src->OutEdgeEnd(); ++iter)
186 {
187 PTACallGraphEdge* edge = (*iter);
188 if (edge->getEdgeKind() == kind && edge->getDstID() == dst->getId())
189 return edge;
190 }
191 return nullptr;
192}
iterator OutEdgeEnd()
iterator OutEdgeBegin()
iterators
NodeID getId() const
Get ID.

◆ getIndCallMap()

CallEdgeMap & SVF::PTACallGraph::getIndCallMap ( )
inline

Get callees from an indirect callsite.

Definition at line 321 of file PTACallGraph.h.

322 {
323 return indirectCallMap;
324 }
CallEdgeMap indirectCallMap
Indirect call map.

◆ getIndCallSitesInvokingCallee()

void PTACallGraph::getIndCallSitesInvokingCallee ( const SVFFunction callee,
PTACallGraphEdge::CallInstSet csSet 
)

Get indirect callsite invoking this callee

Definition at line 259 of file PTACallGraph.cpp.

260{
261 PTACallGraphNode* callGraphNode = getCallGraphNode(callee);
262 for(PTACallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd();
263 it!=eit; ++it)
264 {
265 for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->indirectCallsBegin(),
266 ecit = (*it)->indirectCallsEnd(); cit!=ecit; ++cit)
267 {
268 csSet.insert((*cit));
269 }
270 }
271}

◆ getIndCSCallees()

const FunctionSet & SVF::PTACallGraph::getIndCSCallees ( const CallICFGNode cs) const
inline

Definition at line 329 of file PTACallGraph.h.

330 {
331 CallEdgeMap::const_iterator it = indirectCallMap.find(cs);
332 assert(it!=indirectCallMap.end() && "not an indirect callsite!");
333 return it->second;
334 }

◆ getKind()

CGEK SVF::PTACallGraph::getKind ( ) const
inline

Return type of this callgraph.

Definition at line 314 of file PTACallGraph.h.

315 {
316 return kind;
317 }

◆ getNumOfResolvedIndCallEdge()

u32_t SVF::PTACallGraph::getNumOfResolvedIndCallEdge ( ) const
inline

Definition at line 341 of file PTACallGraph.h.

342 {
344 }

◆ getTotalCallSiteNumber()

u32_t SVF::PTACallGraph::getTotalCallSiteNumber ( ) const
inline

Definition at line 336 of file PTACallGraph.h.

337 {
338 return totalCallSiteNum;
339 }

◆ hasCallGraphEdge()

bool SVF::PTACallGraph::hasCallGraphEdge ( const CallICFGNode inst) const
inline

Get call graph edge via call instruction.

whether this call instruction has a valid call graph edge

Definition at line 426 of file PTACallGraph.h.

427 {
429 }

◆ hasCallSiteID()

bool SVF::PTACallGraph::hasCallSiteID ( const CallICFGNode cs,
const SVFFunction callee 
) const
inline

Definition at line 378 of file PTACallGraph.h.

379 {
380 CallSitePair newCS(std::make_pair(cs, callee));
381 CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
382 return it != csToIdMap.end();
383 }

◆ hasGraphEdge()

PTACallGraphEdge * PTACallGraph::hasGraphEdge ( PTACallGraphNode src,
PTACallGraphNode dst,
PTACallGraphEdge::CEDGEK  kind,
CallSiteID  csId 
) const

Whether we have already created this call graph edge.

Whether we have already created this call graph edge

Definition at line 161 of file PTACallGraph.cpp.

164{
165 PTACallGraphEdge edge(src,dst,kind,csId);
168 if (outEdge && inEdge)
169 {
170 assert(outEdge == inEdge && "edges not match");
171 return outEdge;
172 }
173 else
174 return nullptr;
175}
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const

◆ hasIndCSCallees()

bool SVF::PTACallGraph::hasIndCSCallees ( const CallICFGNode cs) const
inline

Definition at line 325 of file PTACallGraph.h.

326 {
327 return (indirectCallMap.find(cs) != indirectCallMap.end());
328 }

◆ isReachableBetweenFunctions()

bool PTACallGraph::isReachableBetweenFunctions ( const SVFFunction srcFn,
const SVFFunction dstFn 
) const

Whether its reachable between two functions.

Whether its reachable between two functions

Definition at line 296 of file PTACallGraph.cpp.

297{
299
300 std::stack<const PTACallGraphNode*> nodeStack;
302 nodeStack.push(dstNode);
303 visitedNodes.set(dstNode->getId());
304
305 while (nodeStack.empty() == false)
306 {
307 PTACallGraphNode* node = const_cast<PTACallGraphNode*>(nodeStack.top());
308 nodeStack.pop();
309
310 if (node->getFunction() == srcFn)
311 return true;
312
313 for (CallGraphEdgeConstIter it = node->InEdgeBegin(), eit = node->InEdgeEnd(); it != eit; ++it)
314 {
316 if (visitedNodes.test_and_set(edge->getSrcID()))
317 nodeStack.push(edge->getSrcNode());
318 }
319 }
320
321 return false;
322}
CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter
void set(unsigned Idx)

◆ verifyCallGraph()

void PTACallGraph::verifyCallGraph ( )

Issue a warning if the function which has indirect call sites can not be reached from program entry.

Issue a warning if the function which has indirect call sites can not be reached from program entry.

Definition at line 276 of file PTACallGraph.cpp.

277{
278 CallEdgeMap::const_iterator it = indirectCallMap.begin();
279 CallEdgeMap::const_iterator eit = indirectCallMap.end();
280 for (; it != eit; ++it)
281 {
282 const FunctionSet& targets = it->second;
283 if (targets.empty() == false)
284 {
285 const CallICFGNode* cs = it->first;
286 const SVFFunction* func = cs->getCaller();
287 if (getCallGraphNode(func)->isReachableFromProgEntry() == false)
288 writeWrnMsg(func->getName() + " has indirect call site but not reachable from main");
289 }
290 }
291}
Set< const SVFFunction * > FunctionSet
const std::string & getName() const
Definition SVFValue.h:243
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:67

◆ view()

void PTACallGraph::view ( )

View the graph from the debugger.

Definition at line 332 of file PTACallGraph.cpp.

333{
334 SVF::ViewGraph(this, "Call Graph");
335}
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)

Member Data Documentation

◆ callGraphNodeNum

NodeID SVF::PTACallGraph::callGraphNodeNum
protected

Definition at line 269 of file PTACallGraph.h.

◆ callinstToCallGraphEdgesMap

CallInstToCallGraphEdgesMap SVF::PTACallGraph::callinstToCallGraphEdgesMap
protected

Map a call instruction to its corresponding call edges.

Definition at line 267 of file PTACallGraph.h.

◆ csToIdMap

PTACallGraph::CallSiteToIdMap PTACallGraph::csToIdMap
staticprivate

Call site information.

Map a pair of call instruction and callee to a callsite ID

Definition at line 261 of file PTACallGraph.h.

◆ funToCallGraphNodeMap

FunToCallGraphNodeMap SVF::PTACallGraph::funToCallGraphNodeMap
protected

Call Graph node map.

Definition at line 266 of file PTACallGraph.h.

◆ idToCSMap

PTACallGraph::IdToCallSiteMap PTACallGraph::idToCSMap
staticprivate

Map a callsite ID to a pair of call instruction and callee.

Definition at line 262 of file PTACallGraph.h.

◆ indirectCallMap

CallEdgeMap SVF::PTACallGraph::indirectCallMap
private

Indirect call map.

Definition at line 258 of file PTACallGraph.h.

◆ kind

CGEK SVF::PTACallGraph::kind
protected

Definition at line 271 of file PTACallGraph.h.

◆ numOfResolvedIndCallEdge

u32_t SVF::PTACallGraph::numOfResolvedIndCallEdge
protected

Definition at line 270 of file PTACallGraph.h.

◆ totalCallSiteNum

CallSiteID PTACallGraph::totalCallSiteNum =1
staticprivate

CallSiteIDs, start from 1;.

Definition at line 263 of file PTACallGraph.h.


The documentation for this class was generated from the following files: