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

#include <CallGraph.h>

Inheritance diagram for SVF::CallGraph:
SVF::GenericGraph< NodeTy, EdgeTy >

Public Types

typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet
 
typedef Map< const SVFFunction *, CallGraphNode * > FunToCallGraphNodeMap
 
typedef Map< const CallICFGNode *, CallGraphEdgeSetCallInstToCallGraphEdgesMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
- 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

 CallGraph ()
 Constructor.
 
void addCallGraphNode (const SVFFunction *fun)
 
const CallGraphNodegetCallGraphNode (const std::string &name)
 
virtual ~CallGraph ()
 Destructor.
 
CallGraphNodegetCallGraphNode (NodeID id) const
 Get call graph node.
 
CallGraphNodegetCallGraphNode (const SVFFunction *fun) const
 
CallGraphEdgehasGraphEdge (CallGraphNode *src, CallGraphNode *dst, const CallICFGNode *callIcfgNode) const
 Whether we have already created this call graph edge.
 
void addDirectCallGraphEdge (const CallICFGNode *call, const SVFFunction *callerFun, const SVFFunction *calleeFun)
 Add direct call edges.
 
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.
 
void addEdge (CallGraphEdge *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
 
- Protected Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
IDToNodeMapTy IDToNodeMap
 node map
 

Friends

class PTACallGraph
 

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 171 of file CallGraph.h.

Member Typedef Documentation

◆ CallEdgeMap

Definition at line 180 of file CallGraph.h.

◆ CallGraphEdgeSet

Definition at line 176 of file CallGraph.h.

◆ CallInstToCallGraphEdgesMap

Definition at line 178 of file CallGraph.h.

◆ FunctionSet

Definition at line 179 of file CallGraph.h.

◆ FunToCallGraphNodeMap

Definition at line 177 of file CallGraph.h.

Constructor & Destructor Documentation

◆ CallGraph()

CallGraph::CallGraph ( )

Constructor.

Definition at line 70 of file CallGraph.cpp.

71{
73}
NodeID callGraphNodeNum
Definition CallGraph.h:186

◆ ~CallGraph()

virtual SVF::CallGraph::~CallGraph ( )
inlinevirtual

Destructor.

Definition at line 208 of file CallGraph.h.

209 {
210 destroy();
211 }
void destroy()
Clean up memory.
Definition CallGraph.cpp:79

Member Function Documentation

◆ addCallGraphNode()

void CallGraph::addCallGraphNode ( const SVFFunction fun)

Add call graph node

Definition at line 86 of file CallGraph.cpp.

87{
89 CallGraphNode*callGraphNode = new CallGraphNode(id, fun);
90 addGNode(id, callGraphNode);
91 funToCallGraphNodeMap[callGraphNode->getFunction()] = callGraphNode;
93}
const SVFFunction * getFunction() const
Get function of this call node.
Definition CallGraph.h:131
FunToCallGraphNodeMap funToCallGraphNodeMap
Call Graph node map.
Definition CallGraph.h:183
void addGNode(NodeID id, NodeType *node)
Add a Node.
u32_t NodeID
Definition GeneralType.h:55

◆ addDirectCallGraphEdge()

void CallGraph::addDirectCallGraphEdge ( const CallICFGNode cs,
const SVFFunction callerFun,
const SVFFunction calleeFun 
)

Add direct call edges.

Add direct call edges

Definition at line 117 of file CallGraph.cpp.

118{
119
122
123
124 if(!hasGraphEdge(caller,callee, cs))
125 {
127 edge->addDirectCallSite(cs);
128 addEdge(edge);
130 }
131}
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
Map a call instruction to its corresponding call edges.
Definition CallGraph.h:184
void addEdge(CallGraphEdge *edge)
Add call graph edge.
Definition CallGraph.h:192
CallGraphEdge * hasGraphEdge(CallGraphNode *src, CallGraphNode *dst, const CallICFGNode *callIcfgNode) const
Whether we have already created this call graph edge.
Definition CallGraph.cpp:98
const CallGraphNode * getCallGraphNode(const std::string &name)
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ addEdge()

void SVF::CallGraph::addEdge ( CallGraphEdge edge)
inlineprotected

Add call graph edge.

Definition at line 192 of file CallGraph.h.

193 {
194 edge->getDstNode()->addIncomingEdge(edge);
195 edge->getSrcNode()->addOutgoingEdge(edge);
196 }

◆ destroy()

void CallGraph::destroy ( )
protected

Clean up memory.

Memory has been cleaned up at GenericGraph

Definition at line 79 of file CallGraph.cpp.

80{
81}

◆ dump()

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

Dump the graph.

Dump call graph into dot file

Definition at line 136 of file CallGraph.cpp.

137{
139}
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

◆ getCallGraphNode() [1/3]

const CallGraphNode * CallGraph::getCallGraphNode ( const std::string &  name)

Definition at line 146 of file CallGraph.cpp.

147{
148 for (const auto& item : *this)
149 {
150 if (item.second->getName() == name)
151 return item.second;
152 }
153 return nullptr;
154}
const char *const name
Definition cJSON.h:264
cJSON * item
Definition cJSON.h:222

◆ getCallGraphNode() [2/3]

CallGraphNode * SVF::CallGraph::getCallGraphNode ( const SVFFunction fun) const
inline

Definition at line 219 of file CallGraph.h.

220 {
221 FunToCallGraphNodeMap::const_iterator it = funToCallGraphNodeMap.find(fun);
222 assert(it!=funToCallGraphNodeMap.end() && "call graph node not found!!");
223 return it->second;
224 }

◆ getCallGraphNode() [3/3]

CallGraphNode * SVF::CallGraph::getCallGraphNode ( NodeID  id) const
inline

Get call graph node.

Definition at line 215 of file CallGraph.h.

216 {
217 return getGNode(id);
218 }
NodeType * getGNode(NodeID id) const
Get a node.

◆ hasGraphEdge()

CallGraphEdge * CallGraph::hasGraphEdge ( CallGraphNode src,
CallGraphNode dst,
const CallICFGNode callIcfgNode 
) const

Whether we have already created this call graph edge.

Whether we have already created this call graph edge

Definition at line 98 of file CallGraph.cpp.

101{
105 if (outEdge && inEdge)
106 {
107 assert(outEdge == inEdge && "edges not match");
108 return outEdge;
109 }
110 else
111 return nullptr;
112}
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const

◆ view()

void CallGraph::view ( )

View the graph from the debugger.

Definition at line 141 of file CallGraph.cpp.

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

Friends And Related Symbol Documentation

◆ PTACallGraph

Definition at line 173 of file CallGraph.h.

Member Data Documentation

◆ callGraphNodeNum

NodeID SVF::CallGraph::callGraphNodeNum
protected

Definition at line 186 of file CallGraph.h.

◆ callinstToCallGraphEdgesMap

CallInstToCallGraphEdgesMap SVF::CallGraph::callinstToCallGraphEdgesMap
protected

Map a call instruction to its corresponding call edges.

Definition at line 184 of file CallGraph.h.

◆ funToCallGraphNodeMap

FunToCallGraphNodeMap SVF::CallGraph::funToCallGraphNodeMap
protected

Call Graph node map.

Definition at line 183 of file CallGraph.h.


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