svf-lib 1.0.2205 → 1.0.2207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-linux/Release-build/bin/ae +0 -0
- package/SVF-linux/Release-build/bin/cfl +0 -0
- package/SVF-linux/Release-build/bin/dvf +0 -0
- package/SVF-linux/Release-build/bin/mta +0 -0
- package/SVF-linux/Release-build/bin/saber +0 -0
- package/SVF-linux/Release-build/bin/svf-ex +0 -0
- package/SVF-linux/Release-build/bin/wpa +0 -0
- package/SVF-linux/Release-build/include/Graphs/SCC.h +7 -2
- package/SVF-linux/Release-build/include/MSSA/MemRegion.h +0 -2
- package/SVF-linux/Release-build/include/WPA/WPAFSSolver.h +2 -2
- package/SVF-linux/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/bin/ae +0 -0
- package/SVF-osx/Release-build/bin/cfl +0 -0
- package/SVF-osx/Release-build/bin/dvf +0 -0
- package/SVF-osx/Release-build/bin/llvm2svf +0 -0
- package/SVF-osx/Release-build/bin/mta +0 -0
- package/SVF-osx/Release-build/bin/saber +0 -0
- package/SVF-osx/Release-build/bin/svf-ex +0 -0
- package/SVF-osx/Release-build/bin/wpa +0 -0
- package/SVF-osx/Release-build/include/AE/Svfexe/AbstractInterpretation.h +2 -2
- package/SVF-osx/Release-build/include/Graphs/PTACallGraph.h +9 -1
- package/SVF-osx/Release-build/include/Graphs/ThreadCallGraph.h +1 -1
- package/SVF-osx/Release-build/include/SVF-LLVM/LLVMModule.h +1 -12
- package/SVF-osx/Release-build/include/SVFIR/SVFIR.h +11 -12
- package/SVF-osx/Release-build/include/SVFIR/SVFValue.h +0 -10
- package/SVF-osx/Release-build/include/SVFIR/SVFVariables.h +13 -13
- package/SVF-osx/Release-build/include/Util/CallGraphBuilder.h +1 -1
- package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
- package/package.json +1 -1
- package/SVF-osx/Release-build/include/Graphs/CallGraph.h +0 -266
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -130,12 +130,17 @@ public:
|
|
|
130
130
|
return _T;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
inline const GNodeStack& topoNodeStack() const
|
|
134
|
+
{
|
|
135
|
+
return _T;
|
|
136
|
+
}
|
|
137
|
+
|
|
133
138
|
/// Return a handle to the stack of nodes in reverse topological
|
|
134
139
|
/// order. This will be used to seed the initial solution
|
|
135
140
|
/// and improve efficiency.
|
|
136
|
-
inline
|
|
141
|
+
inline FIFOWorkList<NodeID> revTopoNodeStack() const
|
|
137
142
|
{
|
|
138
|
-
|
|
143
|
+
FIFOWorkList<NodeID> revTopoOrder;
|
|
139
144
|
GNodeStack topoOrder = topoNodeStack();
|
|
140
145
|
while(!topoOrder.empty())
|
|
141
146
|
{
|
|
@@ -268,8 +268,6 @@ private:
|
|
|
268
268
|
/// Get all the objects in callee's modref escaped via global objects (the chain pts of globals)
|
|
269
269
|
void getEscapObjviaGlobals(NodeBS& globs, const NodeBS& pts);
|
|
270
270
|
|
|
271
|
-
/// Get reverse topo call graph scc
|
|
272
|
-
void getCallGraphSCCRevTopoOrder(WorkList& worklist);
|
|
273
271
|
|
|
274
272
|
protected:
|
|
275
273
|
MRGenerator(BVDataPTAImpl* p, bool ptrOnly);
|
|
@@ -73,10 +73,10 @@ protected:
|
|
|
73
73
|
|
|
74
74
|
/// Both rep and sub nodes need to be processed later.
|
|
75
75
|
/// Collect sub nodes from SCCDetector.
|
|
76
|
-
|
|
76
|
+
FIFOWorkList<NodeID> revTopoStack = this->getSCCDetector()->revTopoNodeStack();
|
|
77
77
|
while (!revTopoStack.empty())
|
|
78
78
|
{
|
|
79
|
-
NodeID nodeId = revTopoStack.
|
|
79
|
+
NodeID nodeId = revTopoStack.front();
|
|
80
80
|
revTopoStack.pop();
|
|
81
81
|
const NodeBS& subNodes = this->getSCCDetector()->subNodes(nodeId);
|
|
82
82
|
for (NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it != eit; ++it)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -251,8 +251,8 @@ private:
|
|
|
251
251
|
AEStat* stat;
|
|
252
252
|
|
|
253
253
|
std::vector<const CallICFGNode*> callSiteStack;
|
|
254
|
-
Map<const
|
|
255
|
-
Set<const
|
|
254
|
+
Map<const SVFFunction*, ICFGWTO*> funcToWTO;
|
|
255
|
+
Set<const SVFFunction*> recursiveFuns;
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
AbstractState& getAbsStateFromTrace(const ICFGNode* node)
|
|
@@ -302,7 +302,7 @@ public:
|
|
|
302
302
|
PTACallGraph(CGEK k = NormCallGraph);
|
|
303
303
|
|
|
304
304
|
/// Copy constructor
|
|
305
|
-
PTACallGraph(const
|
|
305
|
+
PTACallGraph(const PTACallGraph& other);
|
|
306
306
|
|
|
307
307
|
/// Destructor
|
|
308
308
|
virtual ~PTACallGraph()
|
|
@@ -351,8 +351,16 @@ public:
|
|
|
351
351
|
/// Issue a warning if the function which has indirect call sites can not be reached from program entry.
|
|
352
352
|
void verifyCallGraph();
|
|
353
353
|
|
|
354
|
+
/// Add direct call edges
|
|
355
|
+
void addDirectCallGraphEdge(const CallICFGNode* call, const SVFFunction* callerFun, const SVFFunction* calleeFun);
|
|
356
|
+
|
|
357
|
+
void addCallGraphNode(const SVFFunction* fun);
|
|
358
|
+
|
|
354
359
|
/// Get call graph node
|
|
355
360
|
//@{
|
|
361
|
+
|
|
362
|
+
const PTACallGraphNode* getCallGraphNode(const std::string& name);
|
|
363
|
+
|
|
356
364
|
inline PTACallGraphNode* getCallGraphNode(NodeID id) const
|
|
357
365
|
{
|
|
358
366
|
return getGNode(id);
|
|
@@ -172,7 +172,7 @@ public:
|
|
|
172
172
|
typedef Map<const CallICFGNode*, ParForEdgeSet> CallInstToParForEdgesMap;
|
|
173
173
|
|
|
174
174
|
/// Constructor
|
|
175
|
-
ThreadCallGraph(const
|
|
175
|
+
ThreadCallGraph(const PTACallGraph& cg);
|
|
176
176
|
|
|
177
177
|
ThreadCallGraph(ThreadCallGraph& cg) = delete;
|
|
178
178
|
|
|
@@ -55,7 +55,6 @@ public:
|
|
|
55
55
|
typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
|
|
56
56
|
|
|
57
57
|
typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
|
|
58
|
-
typedef Map<const Function*, CallGraphNode*> LLVMFun2CallGraphNodeMap;
|
|
59
58
|
typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
|
|
60
59
|
typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
|
|
61
60
|
typedef Map<const Argument*, SVFArgument*> LLVMArgument2SVFArgumentMap;
|
|
@@ -95,7 +94,6 @@ private:
|
|
|
95
94
|
GlobalDefToRepMapTy GlobalDefToRepMap;
|
|
96
95
|
|
|
97
96
|
LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
|
|
98
|
-
LLVMFun2CallGraphNodeMap LLVMFunc2CallGraphNode; ///< Map an LLVM Function to an CallGraph Node
|
|
99
97
|
LLVMBB2SVFBBMap LLVMBB2SVFBB;
|
|
100
98
|
LLVMInst2SVFInstMap LLVMInst2SVFInst;
|
|
101
99
|
LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
|
|
@@ -112,7 +110,7 @@ private:
|
|
|
112
110
|
InstToBlockNodeMapTy InstToBlockNodeMap; ///< map a basic block to its ICFGNode
|
|
113
111
|
FunToFunEntryNodeMapTy FunToFunEntryNodeMap; ///< map a function to its FunExitICFGNode
|
|
114
112
|
FunToFunExitNodeMapTy FunToFunExitNodeMap; ///< map a function to its FunEntryICFGNode
|
|
115
|
-
|
|
113
|
+
PTACallGraph* callgraph;
|
|
116
114
|
|
|
117
115
|
Map<const Function*, DominatorTree> FunToDominatorTree;
|
|
118
116
|
|
|
@@ -218,8 +216,6 @@ public:
|
|
|
218
216
|
setValueAttr(func,svfFunc);
|
|
219
217
|
}
|
|
220
218
|
|
|
221
|
-
void addFunctionMap(const Function* func, CallGraphNode* svfFunc);
|
|
222
|
-
|
|
223
219
|
// create a SVFBasicBlock according to LLVM BasicBlock, then add it to SVFFunction's BasicBlockGraph
|
|
224
220
|
inline void addBasicBlock(SVFFunction* fun, const BasicBlock* bb)
|
|
225
221
|
{
|
|
@@ -296,13 +292,6 @@ public:
|
|
|
296
292
|
return it->second;
|
|
297
293
|
}
|
|
298
294
|
|
|
299
|
-
inline CallGraphNode* getCallGraphNode(const Function* fun) const
|
|
300
|
-
{
|
|
301
|
-
LLVMFun2CallGraphNodeMap::const_iterator it = LLVMFunc2CallGraphNode.find(fun);
|
|
302
|
-
assert(it!=LLVMFunc2CallGraphNode.end() && "SVF Function not found!");
|
|
303
|
-
return it->second;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
295
|
inline SVFFunction* getSVFFunction(const Function* fun) const
|
|
307
296
|
{
|
|
308
297
|
LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
namespace SVF
|
|
36
36
|
{
|
|
37
37
|
class CommonCHGraph;
|
|
38
|
-
class CallGraph;
|
|
39
38
|
/*!
|
|
40
39
|
* SVF Intermediate representation, representing variables and statements as a Program Assignment Graph (PAG)
|
|
41
40
|
* Variables as nodes and statements as edges.
|
|
@@ -62,7 +61,7 @@ public:
|
|
|
62
61
|
typedef Map<const CallICFGNode*,SVFVarList> CSToArgsListMap;
|
|
63
62
|
typedef Map<const RetICFGNode*,const SVFVar*> CSToRetMap;
|
|
64
63
|
typedef Map<const SVFFunction*,const SVFVar*> FunToRetMap;
|
|
65
|
-
typedef Map<const
|
|
64
|
+
typedef Map<const SVFFunction*,const FunObjVar *> FunToFunObjVarMap;
|
|
66
65
|
typedef Map<const SVFFunction*,SVFStmtSet> FunToPAGEdgeSetMap;
|
|
67
66
|
typedef Map<const ICFGNode*,SVFStmtList> ICFGNode2SVFStmtsMap;
|
|
68
67
|
typedef Map<NodeID, NodeID> NodeToNodeMap;
|
|
@@ -100,7 +99,7 @@ private:
|
|
|
100
99
|
ICFG* icfg; // ICFG
|
|
101
100
|
CommonCHGraph* chgraph; // class hierarchy graph
|
|
102
101
|
CallSiteSet callSiteSet; /// all the callsites of a program
|
|
103
|
-
|
|
102
|
+
PTACallGraph* callGraph; /// call graph
|
|
104
103
|
|
|
105
104
|
static std::unique_ptr<SVFIR> pag; ///< Singleton pattern here to enable instance of SVFIR can only be created once.
|
|
106
105
|
|
|
@@ -187,11 +186,11 @@ public:
|
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
/// Set/Get CG
|
|
190
|
-
inline void setCallGraph(
|
|
189
|
+
inline void setCallGraph(PTACallGraph* c)
|
|
191
190
|
{
|
|
192
191
|
callGraph = c;
|
|
193
192
|
}
|
|
194
|
-
inline
|
|
193
|
+
inline PTACallGraph* getCallGraph()
|
|
195
194
|
{
|
|
196
195
|
assert(callGraph && "empty CallGraph! Build SVF IR first!");
|
|
197
196
|
return callGraph;
|
|
@@ -331,7 +330,7 @@ public:
|
|
|
331
330
|
}
|
|
332
331
|
//@}
|
|
333
332
|
|
|
334
|
-
inline const FunObjVar* getFunObjVar(const
|
|
333
|
+
inline const FunObjVar* getFunObjVar(const SVFFunction* node) const
|
|
335
334
|
{
|
|
336
335
|
FunToFunObjVarMap::const_iterator it = funToFunObjvarMap.find(node);
|
|
337
336
|
assert(it != funToFunObjvarMap.end() && "this function doesn't have funobjvar");
|
|
@@ -547,13 +546,13 @@ private:
|
|
|
547
546
|
return addValNode(node);
|
|
548
547
|
}
|
|
549
548
|
|
|
550
|
-
NodeID addFunValNode(NodeID i, const ICFGNode* icfgNode, const
|
|
549
|
+
NodeID addFunValNode(NodeID i, const ICFGNode* icfgNode, const SVFFunction* callGraphNode, const SVFType* type)
|
|
551
550
|
{
|
|
552
551
|
FunValVar* node = new FunValVar(i, icfgNode, callGraphNode, type);
|
|
553
552
|
return addValNode(node);
|
|
554
553
|
}
|
|
555
554
|
|
|
556
|
-
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const
|
|
555
|
+
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const SVFFunction* callGraphNode, const SVFType* type)
|
|
557
556
|
{
|
|
558
557
|
ArgValVar* node =
|
|
559
558
|
new ArgValVar(i, argNo, icfgNode, callGraphNode, type);
|
|
@@ -625,7 +624,7 @@ private:
|
|
|
625
624
|
return addObjNode(stackObj);
|
|
626
625
|
}
|
|
627
626
|
|
|
628
|
-
NodeID addFunObjNode(NodeID id, ObjTypeInfo* ti, const
|
|
627
|
+
NodeID addFunObjNode(NodeID id, ObjTypeInfo* ti, const SVFFunction* callGraphNode, const SVFType* type, const ICFGNode* node)
|
|
629
628
|
{
|
|
630
629
|
memToFieldsMap[id].set(id);
|
|
631
630
|
FunObjVar* funObj = new FunObjVar(id, ti, callGraphNode, type, node);
|
|
@@ -678,13 +677,13 @@ private:
|
|
|
678
677
|
}
|
|
679
678
|
|
|
680
679
|
/// Add a unique return node for a procedure
|
|
681
|
-
inline NodeID addRetNode(NodeID i, const
|
|
680
|
+
inline NodeID addRetNode(NodeID i, const SVFFunction* callGraphNode, const SVFType* type, const ICFGNode* icn)
|
|
682
681
|
{
|
|
683
682
|
SVFVar *node = new RetValPN(i, callGraphNode, type, icn);
|
|
684
683
|
return addRetNode(callGraphNode, node);
|
|
685
684
|
}
|
|
686
685
|
/// Add a unique vararg node for a procedure
|
|
687
|
-
inline NodeID addVarargNode(NodeID i, const
|
|
686
|
+
inline NodeID addVarargNode(NodeID i, const SVFFunction* val, const SVFType* type, const ICFGNode* n)
|
|
688
687
|
{
|
|
689
688
|
SVFVar *node = new VarArgValPN(i, val, type, n);
|
|
690
689
|
return addNode(node);
|
|
@@ -758,7 +757,7 @@ private:
|
|
|
758
757
|
return addNode(node);
|
|
759
758
|
}
|
|
760
759
|
/// Add a unique return node for a procedure
|
|
761
|
-
inline NodeID addRetNode(const
|
|
760
|
+
inline NodeID addRetNode(const SVFFunction*, SVFVar *node)
|
|
762
761
|
{
|
|
763
762
|
return addNode(node);
|
|
764
763
|
}
|
|
@@ -320,14 +320,9 @@ private:
|
|
|
320
320
|
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
|
|
321
321
|
std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
|
|
322
322
|
SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
|
|
323
|
-
const CallGraphNode *callGraphNode; /// call graph node for this function
|
|
324
323
|
BasicBlockGraph* bbGraph; /// the basic block graph of this function
|
|
325
324
|
|
|
326
325
|
protected:
|
|
327
|
-
inline void setCallGraphNode(CallGraphNode *cgn)
|
|
328
|
-
{
|
|
329
|
-
callGraphNode = cgn;
|
|
330
|
-
}
|
|
331
326
|
|
|
332
327
|
inline void addArgument(const ArgValVar* arg)
|
|
333
328
|
{
|
|
@@ -355,11 +350,6 @@ public:
|
|
|
355
350
|
SVFFunction(void) = delete;
|
|
356
351
|
virtual ~SVFFunction();
|
|
357
352
|
|
|
358
|
-
inline const CallGraphNode* getCallGraphNode() const
|
|
359
|
-
{
|
|
360
|
-
return callGraphNode;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
353
|
static inline bool classof(const SVFValue *node)
|
|
364
354
|
{
|
|
365
355
|
return node->getKind() == SVFFunc;
|
|
@@ -366,7 +366,7 @@ class ArgValVar: public ValVar
|
|
|
366
366
|
friend class SVFIRReader;
|
|
367
367
|
|
|
368
368
|
private:
|
|
369
|
-
const
|
|
369
|
+
const SVFFunction* cgNode;
|
|
370
370
|
u32_t argNo;
|
|
371
371
|
|
|
372
372
|
protected:
|
|
@@ -399,7 +399,7 @@ public:
|
|
|
399
399
|
//@}
|
|
400
400
|
|
|
401
401
|
/// Constructor
|
|
402
|
-
ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const
|
|
402
|
+
ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const SVFFunction* callGraphNode,
|
|
403
403
|
const SVFType* svfType);
|
|
404
404
|
|
|
405
405
|
/// Return name of a LLVM value
|
|
@@ -968,7 +968,7 @@ class FunValVar : public ValVar
|
|
|
968
968
|
friend class SVFIRWriter;
|
|
969
969
|
friend class SVFIRReader;
|
|
970
970
|
private:
|
|
971
|
-
const
|
|
971
|
+
const SVFFunction* callGraphNode;
|
|
972
972
|
|
|
973
973
|
public:
|
|
974
974
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
@@ -995,13 +995,13 @@ public:
|
|
|
995
995
|
}
|
|
996
996
|
//@}
|
|
997
997
|
|
|
998
|
-
inline const
|
|
998
|
+
inline virtual const SVFFunction* getFunction() const
|
|
999
999
|
{
|
|
1000
1000
|
return callGraphNode;
|
|
1001
1001
|
}
|
|
1002
1002
|
|
|
1003
1003
|
/// Constructor
|
|
1004
|
-
FunValVar(NodeID i, const ICFGNode* icn, const
|
|
1004
|
+
FunValVar(NodeID i, const ICFGNode* icn, const SVFFunction* cgn, const SVFType* svfType);
|
|
1005
1005
|
|
|
1006
1006
|
|
|
1007
1007
|
virtual bool isPointer() const
|
|
@@ -1018,7 +1018,7 @@ class FunObjVar : public BaseObjVar
|
|
|
1018
1018
|
friend class SVFIRReader;
|
|
1019
1019
|
|
|
1020
1020
|
private:
|
|
1021
|
-
const
|
|
1021
|
+
const SVFFunction* callGraphNode;
|
|
1022
1022
|
|
|
1023
1023
|
private:
|
|
1024
1024
|
/// Constructor to create empty ObjVar (for SVFIRReader/deserialization)
|
|
@@ -1054,9 +1054,9 @@ public:
|
|
|
1054
1054
|
//@}
|
|
1055
1055
|
|
|
1056
1056
|
/// Constructor
|
|
1057
|
-
FunObjVar(NodeID i, ObjTypeInfo* ti, const
|
|
1057
|
+
FunObjVar(NodeID i, ObjTypeInfo* ti, const SVFFunction* cgNode, const SVFType* svfType, const ICFGNode* node);
|
|
1058
1058
|
|
|
1059
|
-
inline const
|
|
1059
|
+
inline const SVFFunction* getCallGraphNode() const
|
|
1060
1060
|
{
|
|
1061
1061
|
return callGraphNode;
|
|
1062
1062
|
}
|
|
@@ -1782,7 +1782,7 @@ class RetValPN : public ValVar
|
|
|
1782
1782
|
friend class SVFIRReader;
|
|
1783
1783
|
|
|
1784
1784
|
private:
|
|
1785
|
-
const
|
|
1785
|
+
const SVFFunction* callGraphNode;
|
|
1786
1786
|
private:
|
|
1787
1787
|
/// Constructor to create empty RetValPN (for SVFIRReader/deserialization)
|
|
1788
1788
|
RetValPN(NodeID i) : ValVar(i, RetValNode) {}
|
|
@@ -1813,9 +1813,9 @@ public:
|
|
|
1813
1813
|
|
|
1814
1814
|
|
|
1815
1815
|
/// Constructor
|
|
1816
|
-
RetValPN(NodeID i, const
|
|
1816
|
+
RetValPN(NodeID i, const SVFFunction* node, const SVFType* svfType, const ICFGNode* icn);
|
|
1817
1817
|
|
|
1818
|
-
inline const
|
|
1818
|
+
inline const SVFFunction* getCallGraphNode() const
|
|
1819
1819
|
{
|
|
1820
1820
|
return callGraphNode;
|
|
1821
1821
|
}
|
|
@@ -1838,7 +1838,7 @@ class VarArgValPN : public ValVar
|
|
|
1838
1838
|
friend class SVFIRWriter;
|
|
1839
1839
|
friend class SVFIRReader;
|
|
1840
1840
|
private:
|
|
1841
|
-
const
|
|
1841
|
+
const SVFFunction* callGraphNode;
|
|
1842
1842
|
|
|
1843
1843
|
private:
|
|
1844
1844
|
/// Constructor to create empty VarArgValPN (for SVFIRReader/deserialization)
|
|
@@ -1869,7 +1869,7 @@ public:
|
|
|
1869
1869
|
//@}
|
|
1870
1870
|
|
|
1871
1871
|
/// Constructor
|
|
1872
|
-
VarArgValPN(NodeID i, const
|
|
1872
|
+
VarArgValPN(NodeID i, const SVFFunction* node, const SVFType* svfType, const ICFGNode* icn)
|
|
1873
1873
|
: ValVar(i, svfType, icn, VarargValNode), callGraphNode(node)
|
|
1874
1874
|
{
|
|
1875
1875
|
}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
//===- CallGraph.h -- Call graph representation----------------------------//
|
|
2
|
-
//
|
|
3
|
-
// SVF: Static Value-Flow Analysis
|
|
4
|
-
//
|
|
5
|
-
// Copyright (C) <2013-2017> <Yulei Sui>
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
// This program is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU Affero General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
|
|
13
|
-
// This program is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU Affero General Public License for more details.
|
|
17
|
-
|
|
18
|
-
// You should have received a copy of the GNU Affero General Public License
|
|
19
|
-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
//
|
|
21
|
-
//===----------------------------------------------------------------------===//
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
* CallGraph.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: Nov 7, 2013
|
|
27
|
-
* Author: Yulei Sui
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef CALLGRAPH_H_
|
|
31
|
-
#define CALLGRAPH_H_
|
|
32
|
-
|
|
33
|
-
#include "Graphs/GenericGraph.h"
|
|
34
|
-
#include "SVFIR/SVFValue.h"
|
|
35
|
-
#include "Graphs/ICFG.h"
|
|
36
|
-
#include <set>
|
|
37
|
-
|
|
38
|
-
namespace SVF
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
class CallGraphNode;
|
|
42
|
-
class SVFModule;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/*
|
|
46
|
-
* Call Graph edge representing a calling relation between two functions
|
|
47
|
-
* Multiple calls from function A to B are merged into one call edge
|
|
48
|
-
* Each call edge has a set of direct callsites and a set of indirect callsites
|
|
49
|
-
*/
|
|
50
|
-
typedef GenericEdge<CallGraphNode> GenericCallGraphEdgeTy;
|
|
51
|
-
class CallGraphEdge : public GenericCallGraphEdgeTy
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
public:
|
|
55
|
-
typedef Set<const CallICFGNode*> CallInstSet;
|
|
56
|
-
|
|
57
|
-
private:
|
|
58
|
-
CallInstSet directCalls;
|
|
59
|
-
public:
|
|
60
|
-
/// Constructor
|
|
61
|
-
CallGraphEdge(CallGraphNode* s, CallGraphNode* d, const CallICFGNode* icfgNode) :
|
|
62
|
-
GenericCallGraphEdgeTy(s, d, icfgNode->getId())
|
|
63
|
-
{
|
|
64
|
-
}
|
|
65
|
-
/// Destructor
|
|
66
|
-
virtual ~CallGraphEdge()
|
|
67
|
-
{
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/// Add direct callsite
|
|
71
|
-
//@{
|
|
72
|
-
void addDirectCallSite(const CallICFGNode* call);
|
|
73
|
-
//@}
|
|
74
|
-
|
|
75
|
-
/// Iterators for direct and indirect callsites
|
|
76
|
-
//@{
|
|
77
|
-
inline CallInstSet::const_iterator directCallsBegin() const
|
|
78
|
-
{
|
|
79
|
-
return directCalls.begin();
|
|
80
|
-
}
|
|
81
|
-
inline CallInstSet::const_iterator directCallsEnd() const
|
|
82
|
-
{
|
|
83
|
-
return directCalls.end();
|
|
84
|
-
}
|
|
85
|
-
//@}
|
|
86
|
-
|
|
87
|
-
/// ClassOf
|
|
88
|
-
//@{
|
|
89
|
-
static inline bool classof(const CallGraphEdge*)
|
|
90
|
-
{
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
//@}
|
|
94
|
-
|
|
95
|
-
/// Overloading operator << for dumping ICFG node ID
|
|
96
|
-
//@{
|
|
97
|
-
friend OutStream& operator<< (OutStream &o, const CallGraphEdge&edge)
|
|
98
|
-
{
|
|
99
|
-
o << edge.toString();
|
|
100
|
-
return o;
|
|
101
|
-
}
|
|
102
|
-
//@}
|
|
103
|
-
|
|
104
|
-
virtual const std::string toString() const;
|
|
105
|
-
|
|
106
|
-
typedef GenericNode<CallGraphNode, CallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;
|
|
107
|
-
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/*
|
|
111
|
-
* Call Graph node representing a function
|
|
112
|
-
*/
|
|
113
|
-
typedef GenericNode<CallGraphNode, CallGraphEdge> GenericCallGraphNodeTy;
|
|
114
|
-
class CallGraphNode : public GenericCallGraphNodeTy
|
|
115
|
-
{
|
|
116
|
-
private:
|
|
117
|
-
const SVFFunction* fun;
|
|
118
|
-
|
|
119
|
-
public:
|
|
120
|
-
/// Constructor
|
|
121
|
-
CallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,CallNodeKd), fun(f)
|
|
122
|
-
{
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
inline const std::string &getName() const
|
|
126
|
-
{
|
|
127
|
-
return fun->getName();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/// Get function of this call node
|
|
131
|
-
inline const SVFFunction* getFunction() const
|
|
132
|
-
{
|
|
133
|
-
return fun;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/// Overloading operator << for dumping ICFG node ID
|
|
138
|
-
//@{
|
|
139
|
-
friend OutStream& operator<< (OutStream &o, const CallGraphNode&node)
|
|
140
|
-
{
|
|
141
|
-
o << node.toString();
|
|
142
|
-
return o;
|
|
143
|
-
}
|
|
144
|
-
//@}
|
|
145
|
-
|
|
146
|
-
virtual const std::string toString() const;
|
|
147
|
-
|
|
148
|
-
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
149
|
-
//@{
|
|
150
|
-
static inline bool classof(const CallGraphNode*)
|
|
151
|
-
{
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
static inline bool classof(const GenericICFGNodeTy* node)
|
|
156
|
-
{
|
|
157
|
-
return node->getNodeKind() == CallNodeKd;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
static inline bool classof(const SVFBaseNode* node)
|
|
161
|
-
{
|
|
162
|
-
return node->getNodeKind() == CallNodeKd;
|
|
163
|
-
}
|
|
164
|
-
//@}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/*!
|
|
168
|
-
* Pointer Analysis Call Graph used internally for various pointer analysis
|
|
169
|
-
*/
|
|
170
|
-
typedef GenericGraph<CallGraphNode, CallGraphEdge> GenericCallGraphTy;
|
|
171
|
-
class CallGraph : public GenericCallGraphTy
|
|
172
|
-
{
|
|
173
|
-
friend class PTACallGraph;
|
|
174
|
-
|
|
175
|
-
public:
|
|
176
|
-
typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
|
|
177
|
-
typedef Map<const SVFFunction*, CallGraphNode*> FunToCallGraphNodeMap;
|
|
178
|
-
typedef Map<const CallICFGNode*, CallGraphEdgeSet> CallInstToCallGraphEdgesMap;
|
|
179
|
-
typedef Set<const SVFFunction*> FunctionSet;
|
|
180
|
-
typedef OrderedMap<const CallICFGNode*, FunctionSet> CallEdgeMap;
|
|
181
|
-
|
|
182
|
-
protected:
|
|
183
|
-
FunToCallGraphNodeMap funToCallGraphNodeMap; ///< Call Graph node map
|
|
184
|
-
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap; ///< Map a call instruction to its corresponding call edges
|
|
185
|
-
|
|
186
|
-
NodeID callGraphNodeNum;
|
|
187
|
-
|
|
188
|
-
/// Clean up memory
|
|
189
|
-
void destroy();
|
|
190
|
-
|
|
191
|
-
/// Add call graph edge
|
|
192
|
-
inline void addEdge(CallGraphEdge* edge)
|
|
193
|
-
{
|
|
194
|
-
edge->getDstNode()->addIncomingEdge(edge);
|
|
195
|
-
edge->getSrcNode()->addOutgoingEdge(edge);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
public:
|
|
200
|
-
/// Constructor
|
|
201
|
-
CallGraph();
|
|
202
|
-
|
|
203
|
-
void addCallGraphNode(const SVFFunction* fun);
|
|
204
|
-
|
|
205
|
-
const CallGraphNode* getCallGraphNode(const std::string& name);
|
|
206
|
-
|
|
207
|
-
/// Destructor
|
|
208
|
-
virtual ~CallGraph()
|
|
209
|
-
{
|
|
210
|
-
destroy();
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/// Get call graph node
|
|
214
|
-
//@{
|
|
215
|
-
inline CallGraphNode* getCallGraphNode(NodeID id) const
|
|
216
|
-
{
|
|
217
|
-
return getGNode(id);
|
|
218
|
-
}
|
|
219
|
-
inline CallGraphNode* getCallGraphNode(const SVFFunction* fun) const
|
|
220
|
-
{
|
|
221
|
-
FunToCallGraphNodeMap::const_iterator it = funToCallGraphNodeMap.find(fun);
|
|
222
|
-
assert(it!=funToCallGraphNodeMap.end() && "call graph node not found!!");
|
|
223
|
-
return it->second;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
//@}
|
|
227
|
-
|
|
228
|
-
/// Whether we have already created this call graph edge
|
|
229
|
-
CallGraphEdge* hasGraphEdge(CallGraphNode* src, CallGraphNode* dst,
|
|
230
|
-
const CallICFGNode* callIcfgNode) const;
|
|
231
|
-
|
|
232
|
-
/// Add direct call edges
|
|
233
|
-
void addDirectCallGraphEdge(const CallICFGNode* call, const SVFFunction* callerFun, const SVFFunction* calleeFun);
|
|
234
|
-
/// Dump the graph
|
|
235
|
-
void dump(const std::string& filename);
|
|
236
|
-
|
|
237
|
-
/// View the graph from the debugger
|
|
238
|
-
void view();
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
} // End namespace SVF
|
|
242
|
-
|
|
243
|
-
namespace SVF
|
|
244
|
-
{
|
|
245
|
-
/* !
|
|
246
|
-
* GenericGraphTraits specializations for generic graph algorithms.
|
|
247
|
-
* Provide graph traits for traversing from a constraint node using standard graph traversals.
|
|
248
|
-
*/
|
|
249
|
-
template<> struct GenericGraphTraits<SVF::CallGraphNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* >
|
|
250
|
-
{
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
/// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal.
|
|
254
|
-
template<>
|
|
255
|
-
struct GenericGraphTraits<Inverse<SVF::CallGraphNode*> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* > >
|
|
256
|
-
{
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
template<> struct GenericGraphTraits<SVF::CallGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::CallGraphNode,SVF::CallGraphEdge>* >
|
|
260
|
-
{
|
|
261
|
-
typedef SVF::CallGraphNode*NodeRef;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
} // End namespace llvm
|
|
265
|
-
|
|
266
|
-
#endif /* CALLGRAPH_H_ */
|