svf-tools 1.0.993 → 1.0.995
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/package.json +1 -1
- package/svf/include/Graphs/CDG.h +18 -1
- package/svf/include/Graphs/CFLGraph.h +19 -1
- package/svf/include/Graphs/CHG.h +19 -1
- package/svf/include/Graphs/CallGraph.h +19 -1
- package/svf/include/Graphs/ConsGNode.h +19 -1
- package/svf/include/Graphs/GenericGraph.h +243 -17
- package/svf/include/Graphs/ICFG.h +0 -96
- package/svf/include/Graphs/ICFGNode.h +55 -22
- package/svf/include/Graphs/SVFG.h +2 -2
- package/svf/include/Graphs/SVFGNode.h +5 -17
- package/svf/include/Graphs/SVFGOPT.h +2 -1
- package/svf/include/Graphs/ThreadCallGraph.h +5 -4
- package/svf/include/Graphs/VFG.h +2 -2
- package/svf/include/Graphs/VFGNode.h +99 -26
- package/svf/include/MTA/TCT.h +19 -1
- package/svf/include/MemoryModel/PointerAnalysis.h +1 -1
- package/svf/include/MemoryModel/PointerAnalysisImpl.h +4 -0
- package/svf/include/SABER/SaberCondAllocator.h +2 -2
- package/svf/include/SVFIR/SVFFileSystem.h +1 -1
- package/svf/include/SVFIR/SVFIR.h +2 -2
- package/svf/include/SVFIR/SVFVariables.h +68 -38
- package/svf/include/SVFIR/SymbolTableInfo.h +11 -1
- package/svf/include/Util/SVFUtil.h +1 -1
- package/svf/include/Util/ThreadAPI.h +8 -2
- package/svf/include/WPA/Andersen.h +26 -13
- package/svf/include/WPA/Steensgaard.h +10 -20
- package/svf/include/WPA/TypeAnalysis.h +10 -3
- package/svf/lib/AE/Svfexe/AEDetector.cpp +4 -2
- package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +10 -12
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +2 -0
- package/svf/lib/DDA/ContextDDA.cpp +12 -8
- package/svf/lib/Graphs/ICFG.cpp +9 -93
- package/svf/lib/Graphs/SVFG.cpp +1 -1
- package/svf/lib/Graphs/ThreadCallGraph.cpp +10 -2
- package/svf/lib/Graphs/VFG.cpp +2 -4
- package/svf/lib/MSSA/MemRegion.cpp +2 -2
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +37 -0
- package/svf/lib/SABER/LeakChecker.cpp +1 -2
- package/svf/lib/SABER/SaberCondAllocator.cpp +13 -16
- package/svf/lib/SABER/SaberSVFGBuilder.cpp +2 -2
- package/svf/lib/SVFIR/SVFFileSystem.cpp +0 -6
- package/svf/lib/SVFIR/SVFVariables.cpp +3 -0
- package/svf/lib/SVFIR/SymbolTableInfo.cpp +3 -2
- package/svf/lib/Util/ThreadAPI.cpp +15 -5
- package/svf/lib/WPA/Andersen.cpp +205 -151
- package/svf/lib/WPA/Steensgaard.cpp +1 -163
- package/svf-llvm/include/SVF-LLVM/DCHG.h +1 -1
- package/svf-llvm/include/SVF-LLVM/ICFGBuilder.h +93 -23
- package/svf-llvm/include/SVF-LLVM/LLVMModule.h +84 -0
- package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +15 -0
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +19 -12
- package/svf-llvm/lib/ICFGBuilder.cpp +125 -54
- package/svf-llvm/lib/LLVMLoopAnalysis.cpp +6 -11
- package/svf-llvm/lib/LLVMModule.cpp +54 -0
- package/svf-llvm/lib/LLVMUtil.cpp +15 -0
- package/svf-llvm/lib/SVFIRBuilder.cpp +92 -76
- package/svf-llvm/lib/SVFIRExtAPI.cpp +5 -5
- package/svf-llvm/lib/SymbolTableBuilder.cpp +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.995",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/svf/include/Graphs/CDG.h
CHANGED
|
@@ -96,7 +96,7 @@ public:
|
|
|
96
96
|
|
|
97
97
|
public:
|
|
98
98
|
/// Constructor
|
|
99
|
-
CDGNode(const ICFGNode *icfgNode) : GenericCDGNodeTy(icfgNode->getId(),
|
|
99
|
+
CDGNode(const ICFGNode *icfgNode) : GenericCDGNodeTy(icfgNode->getId(), CDNodeKd), _icfgNode(icfgNode)
|
|
100
100
|
{
|
|
101
101
|
|
|
102
102
|
}
|
|
@@ -114,6 +114,23 @@ public:
|
|
|
114
114
|
return _icfgNode;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
118
|
+
//@{
|
|
119
|
+
static inline bool classof(const CDGNode *)
|
|
120
|
+
{
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static inline bool classof(const GenericICFGNodeTy* node)
|
|
125
|
+
{
|
|
126
|
+
return node->getNodeKind() == CDNodeKd;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
130
|
+
{
|
|
131
|
+
return node->getNodeKind() == CDNodeKd;
|
|
132
|
+
}
|
|
133
|
+
//@}
|
|
117
134
|
|
|
118
135
|
private:
|
|
119
136
|
const ICFGNode *_icfgNode;
|
|
@@ -76,7 +76,7 @@ typedef GenericNode<CFLNode,CFLEdge> GenericCFLNodeTy;
|
|
|
76
76
|
class CFLNode: public GenericCFLNodeTy
|
|
77
77
|
{
|
|
78
78
|
public:
|
|
79
|
-
CFLNode (NodeID i = 0, GNodeK k =
|
|
79
|
+
CFLNode (NodeID i = 0, GNodeK k = CFLNodeKd):
|
|
80
80
|
GenericCFLNodeTy(i, k)
|
|
81
81
|
{
|
|
82
82
|
}
|
|
@@ -148,6 +148,24 @@ public:
|
|
|
148
148
|
|
|
149
149
|
return num1 && num2;
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
153
|
+
//@{
|
|
154
|
+
static inline bool classof(const CFLNode *)
|
|
155
|
+
{
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static inline bool classof(const GenericICFGNodeTy* node)
|
|
160
|
+
{
|
|
161
|
+
return node->getNodeKind() == CFLNodeKd;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
165
|
+
{
|
|
166
|
+
return node->getNodeKind() == CFLNodeKd;
|
|
167
|
+
}
|
|
168
|
+
//@}
|
|
151
169
|
};
|
|
152
170
|
|
|
153
171
|
/// Edge-labeled graph for CFL Reachability analysis
|
package/svf/include/Graphs/CHG.h
CHANGED
|
@@ -120,7 +120,7 @@ public:
|
|
|
120
120
|
|
|
121
121
|
typedef std::vector<const SVFFunction*> FuncVector;
|
|
122
122
|
|
|
123
|
-
CHNode (const std::string& name, NodeID i = 0, GNodeK k =
|
|
123
|
+
CHNode (const std::string& name, NodeID i = 0, GNodeK k = CHNodeKd):
|
|
124
124
|
GenericCHNodeTy(i, k), vtable(nullptr), className(name), flags(0)
|
|
125
125
|
{
|
|
126
126
|
}
|
|
@@ -191,6 +191,24 @@ public:
|
|
|
191
191
|
vtable = vtbl;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
195
|
+
//@{
|
|
196
|
+
static inline bool classof(const CHNode *)
|
|
197
|
+
{
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
static inline bool classof(const GenericCHNodeTy * node)
|
|
202
|
+
{
|
|
203
|
+
return node->getNodeKind() == CHNodeKd;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
207
|
+
{
|
|
208
|
+
return node->getNodeKind() == CHNodeKd;
|
|
209
|
+
}
|
|
210
|
+
//@}
|
|
211
|
+
|
|
194
212
|
private:
|
|
195
213
|
const SVFGlobalValue* vtable;
|
|
196
214
|
std::string className;
|
|
@@ -184,7 +184,7 @@ private:
|
|
|
184
184
|
|
|
185
185
|
public:
|
|
186
186
|
/// Constructor
|
|
187
|
-
CallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,
|
|
187
|
+
CallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,CallNodeKd), fun(f)
|
|
188
188
|
{
|
|
189
189
|
|
|
190
190
|
}
|
|
@@ -209,6 +209,24 @@ public:
|
|
|
209
209
|
//@}
|
|
210
210
|
|
|
211
211
|
virtual const std::string toString() const;
|
|
212
|
+
|
|
213
|
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
214
|
+
//@{
|
|
215
|
+
static inline bool classof(const CallGraphNode *)
|
|
216
|
+
{
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
static inline bool classof(const GenericICFGNodeTy* node)
|
|
221
|
+
{
|
|
222
|
+
return node->getNodeKind() == CallNodeKd;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
226
|
+
{
|
|
227
|
+
return node->getNodeKind() == CallNodeKd;
|
|
228
|
+
}
|
|
229
|
+
//@}
|
|
212
230
|
};
|
|
213
231
|
|
|
214
232
|
/*!
|
|
@@ -71,7 +71,7 @@ public:
|
|
|
71
71
|
NodeBS strides;
|
|
72
72
|
NodeBS baseIds;
|
|
73
73
|
|
|
74
|
-
ConstraintNode(NodeID i) : GenericConsNodeTy(i,
|
|
74
|
+
ConstraintNode(NodeID i) : GenericConsNodeTy(i, ConstraintNodeKd), _isPWCNode(false)
|
|
75
75
|
{
|
|
76
76
|
|
|
77
77
|
}
|
|
@@ -393,6 +393,24 @@ public:
|
|
|
393
393
|
return o;
|
|
394
394
|
}
|
|
395
395
|
//@}
|
|
396
|
+
|
|
397
|
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
398
|
+
//@{
|
|
399
|
+
static inline bool classof(const ConstraintNode *)
|
|
400
|
+
{
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
static inline bool classof(const GenericICFGNodeTy* node)
|
|
405
|
+
{
|
|
406
|
+
return node->getNodeKind() == ConstraintNodeKd;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
410
|
+
{
|
|
411
|
+
return node->getNodeKind() == ConstraintNodeKd;
|
|
412
|
+
}
|
|
413
|
+
//@}
|
|
396
414
|
};
|
|
397
415
|
|
|
398
416
|
} // End namespace SVF
|
|
@@ -134,11 +134,242 @@ protected:
|
|
|
134
134
|
};
|
|
135
135
|
|
|
136
136
|
|
|
137
|
+
class SVFBaseNode
|
|
138
|
+
{
|
|
139
|
+
|
|
140
|
+
public:
|
|
141
|
+
|
|
142
|
+
enum GNodeK
|
|
143
|
+
{
|
|
144
|
+
// ┌── ICFGNodeKinds: Combines inter-procedural and intra-procedural control flow graph nodes
|
|
145
|
+
// │ ├── Represents a node within a single procedure
|
|
146
|
+
IntraBlock,
|
|
147
|
+
// │ └── Represents a global-level block
|
|
148
|
+
GlobalBlock,
|
|
149
|
+
// │ └─ InterICFGNodeKinds: Types of inter-procedural control flow graph nodes
|
|
150
|
+
// │ ├── Entry point of a function
|
|
151
|
+
FunEntryBlock,
|
|
152
|
+
// │ ├── Exit point of a function
|
|
153
|
+
FunExitBlock,
|
|
154
|
+
// │ ├── Call site in the function
|
|
155
|
+
FunCallBlock,
|
|
156
|
+
// │ └── Return site in the function
|
|
157
|
+
FunRetBlock,
|
|
158
|
+
// └────────
|
|
159
|
+
|
|
160
|
+
// ┌── SVFVarKinds: Combines ValVarKinds and ObjVarKinds for variable nodes
|
|
161
|
+
// │ ┌── ValVarKinds: Types of value variable nodes
|
|
162
|
+
// │ │ ├── Represents a standard value variable
|
|
163
|
+
ValNode,
|
|
164
|
+
// │ │ ├── Represents a GEP value variable
|
|
165
|
+
GepValNode,
|
|
166
|
+
// │ │ ├── Represents a return value node
|
|
167
|
+
RetNode,
|
|
168
|
+
// │ │ ├── Represents a variadic argument node
|
|
169
|
+
VarargNode,
|
|
170
|
+
// │ │ └── Dummy node for uninitialized values
|
|
171
|
+
DummyValNode,
|
|
172
|
+
// │ └── ObjVarKinds: Types of object variable nodes
|
|
173
|
+
// │ ├── Represents an object variable
|
|
174
|
+
ObjNode,
|
|
175
|
+
// │ ├── GepObjNode: Represents a GEP object variable
|
|
176
|
+
GepObjNode,
|
|
177
|
+
// │ ├── FIObjNode: Represents a flow-insensitive object node
|
|
178
|
+
FIObjNode,
|
|
179
|
+
// │ └── DummyObjNode: Dummy node for uninitialized objects
|
|
180
|
+
DummyObjNode,
|
|
181
|
+
// └────────
|
|
182
|
+
|
|
183
|
+
// ┌── VFGNodeKinds: Various Value Flow Graph (VFG) node kinds with operations
|
|
184
|
+
// │ ├── Represents a comparison operation
|
|
185
|
+
Cmp,
|
|
186
|
+
// │ ├── Represents a binary operation
|
|
187
|
+
BinaryOp,
|
|
188
|
+
// │ ├── Represents a unary operation
|
|
189
|
+
UnaryOp,
|
|
190
|
+
// │ ├── Represents a branch operation
|
|
191
|
+
Branch,
|
|
192
|
+
// │ ├── Dummy node for value propagation
|
|
193
|
+
DummyVProp,
|
|
194
|
+
// │ └── Represents a null pointer operation
|
|
195
|
+
NPtr,
|
|
196
|
+
// │ └── ArgumentVFGNodeKinds: Types of argument nodes in VFG
|
|
197
|
+
// │ ├── Represents a function return value
|
|
198
|
+
FRet,
|
|
199
|
+
// │ ├── Represents an argument return value
|
|
200
|
+
ARet,
|
|
201
|
+
// │ ├── Represents an argument parameter
|
|
202
|
+
AParm,
|
|
203
|
+
// │ └── FParm: Represents a function parameter
|
|
204
|
+
FParm,
|
|
205
|
+
// │ └── StmtVFGNodeKinds: Types of statement nodes in VFG
|
|
206
|
+
// │ ├── Represents an address operation
|
|
207
|
+
Addr,
|
|
208
|
+
// │ ├── Represents a copy operation
|
|
209
|
+
Copy,
|
|
210
|
+
// │ ├── Represents a GEP operation
|
|
211
|
+
Gep,
|
|
212
|
+
// │ ├── Represents a store operation
|
|
213
|
+
Store,
|
|
214
|
+
// │ └── Represents a load operation
|
|
215
|
+
Load,
|
|
216
|
+
// │ └── PHIVFGNodeKinds: Types of PHI nodes in VFG
|
|
217
|
+
// │ ├── Represents a type-based PHI node
|
|
218
|
+
TPhi,
|
|
219
|
+
// │ ├── Represents an intra-procedural PHI node
|
|
220
|
+
TIntraPhi,
|
|
221
|
+
// │ └── Represents an inter-procedural PHI node
|
|
222
|
+
TInterPhi,
|
|
223
|
+
// │ └── MRSVFGNodeKinds: Memory-related SVFG nodes
|
|
224
|
+
// │ ├── Function parameter input
|
|
225
|
+
FPIN,
|
|
226
|
+
// │ ├── Function parameter output
|
|
227
|
+
FPOUT,
|
|
228
|
+
// │ ├── Argument parameter input
|
|
229
|
+
APIN,
|
|
230
|
+
// │ └── Argument parameter output
|
|
231
|
+
APOUT,
|
|
232
|
+
// │ └── MSSAPHISVFGNodeKinds: Mem SSA PHI nodes for SVFG
|
|
233
|
+
// │ ├── Memory PHI node
|
|
234
|
+
MPhi,
|
|
235
|
+
// │ ├── Intra-procedural memory PHI node
|
|
236
|
+
MIntraPhi,
|
|
237
|
+
// │ └── MInterPhi: Inter-procedural memory PHI node
|
|
238
|
+
MInterPhi,
|
|
239
|
+
// └────────
|
|
240
|
+
|
|
241
|
+
// Additional specific graph node types
|
|
242
|
+
CallNodeKd, // Callgraph node
|
|
243
|
+
CDNodeKd, // Control dependence graph node
|
|
244
|
+
CFLNodeKd, // CFL graph node
|
|
245
|
+
CHNodeKd, // Class hierarchy graph node
|
|
246
|
+
ConstraintNodeKd, // Constraint graph node
|
|
247
|
+
TCTNodeKd, // Thread creation tree node
|
|
248
|
+
DCHNodeKd, // DCHG node
|
|
249
|
+
OtherKd // Other node kind
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
SVFBaseNode(NodeID i, GNodeK k): id(i), nodeKind(k)
|
|
255
|
+
{
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/// Get ID
|
|
260
|
+
inline NodeID getId() const
|
|
261
|
+
{
|
|
262
|
+
return id;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/// Get node kind
|
|
266
|
+
inline GNodeK getNodeKind() const
|
|
267
|
+
{
|
|
268
|
+
return nodeKind;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
protected:
|
|
272
|
+
NodeID id; ///< Node ID
|
|
273
|
+
GNodeK nodeKind; ///< Node kind
|
|
274
|
+
|
|
275
|
+
/// Helper functions to check node kinds
|
|
276
|
+
//{@ Check node kind
|
|
277
|
+
static inline bool isICFGNodeKinds(GNodeK n)
|
|
278
|
+
{
|
|
279
|
+
static_assert(FunRetBlock - IntraBlock == 5,
|
|
280
|
+
"the number of ICFGNodeKinds has changed, make sure "
|
|
281
|
+
"the range is correct");
|
|
282
|
+
return n <= FunRetBlock && n >= IntraBlock;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
static inline bool isInterICFGNodeKind(GNodeK n)
|
|
286
|
+
{
|
|
287
|
+
static_assert(FunRetBlock - FunEntryBlock == 3,
|
|
288
|
+
"the number of InterICFGNodeKind has changed, make sure "
|
|
289
|
+
"the range is correct");
|
|
290
|
+
return n <= FunRetBlock && n >= FunEntryBlock;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
static inline bool isSVFVarKind(GNodeK n)
|
|
294
|
+
{
|
|
295
|
+
static_assert(DummyObjNode - ValNode == 8,
|
|
296
|
+
"The number of SVFVarKinds has changed, make sure the "
|
|
297
|
+
"range is correct");
|
|
298
|
+
|
|
299
|
+
return n <= DummyObjNode && n >= ValNode;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
static inline bool isValVarKinds(GNodeK n)
|
|
303
|
+
{
|
|
304
|
+
static_assert(DummyValNode - ValNode == 4,
|
|
305
|
+
"The number of ValVarKinds has changed, make sure the "
|
|
306
|
+
"range is correct");
|
|
307
|
+
return n <= DummyValNode && n >= ValNode;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
static inline bool isObjVarKinds(GNodeK n)
|
|
311
|
+
{
|
|
312
|
+
static_assert(DummyObjNode - ObjNode == 3,
|
|
313
|
+
"The number of ObjVarKinds has changed, make sure the "
|
|
314
|
+
"range is correct");
|
|
315
|
+
return n <= DummyObjNode && n >= ObjNode;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
static inline bool isVFGNodeKinds(GNodeK n)
|
|
319
|
+
{
|
|
320
|
+
static_assert(MInterPhi - Cmp == 24,
|
|
321
|
+
"The number of VFGNodeKinds has changed, make sure the "
|
|
322
|
+
"range is correct");
|
|
323
|
+
return n <= MInterPhi && n >= Cmp;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
static inline bool isArgumentVFGNodeKinds(GNodeK n)
|
|
327
|
+
{
|
|
328
|
+
static_assert(FParm - FRet == 3,
|
|
329
|
+
"The number of ArgumentVFGNodeKinds has changed, make "
|
|
330
|
+
"sure the range is correct");
|
|
331
|
+
return n <= FParm && n >= FRet;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
static inline bool isStmtVFGNodeKinds(GNodeK n)
|
|
335
|
+
{
|
|
336
|
+
static_assert(Load - Addr == 4,
|
|
337
|
+
"The number of StmtVFGNodeKinds has changed, make sure "
|
|
338
|
+
"the range is correct");
|
|
339
|
+
return n <= Load && n >= Addr;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
static inline bool isPHIVFGNodeKinds(GNodeK n)
|
|
343
|
+
{
|
|
344
|
+
static_assert(TInterPhi - TPhi == 2,
|
|
345
|
+
"The number of PHIVFGNodeKinds has changed, make sure "
|
|
346
|
+
"the range is correct");
|
|
347
|
+
return n <= TInterPhi && n >= TPhi;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
static inline bool isMRSVFGNodeKinds(GNodeK n)
|
|
351
|
+
{
|
|
352
|
+
static_assert(MInterPhi - FPIN == 6,
|
|
353
|
+
"The number of MRSVFGNodeKinds has changed, make sure "
|
|
354
|
+
"the range is correct");
|
|
355
|
+
return n <= MInterPhi && n >= FPIN;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
static inline bool isMSSAPHISVFGNodeKinds(GNodeK n)
|
|
359
|
+
{
|
|
360
|
+
static_assert(MInterPhi - MPhi == 2,
|
|
361
|
+
"The number of MSSAPHISVFGNodeKinds has changed, make "
|
|
362
|
+
"sure the range is correct");
|
|
363
|
+
return n <= MInterPhi && n >= MPhi;
|
|
364
|
+
}
|
|
365
|
+
//@}
|
|
366
|
+
};
|
|
367
|
+
|
|
137
368
|
/*!
|
|
138
369
|
* Generic node on the graph as base class
|
|
139
370
|
*/
|
|
140
371
|
template<class NodeTy,class EdgeTy>
|
|
141
|
-
class GenericNode
|
|
372
|
+
class GenericNode: public SVFBaseNode
|
|
142
373
|
{
|
|
143
374
|
friend class SVFIRWriter;
|
|
144
375
|
friend class SVFIRReader;
|
|
@@ -147,7 +378,6 @@ public:
|
|
|
147
378
|
typedef NodeTy NodeType;
|
|
148
379
|
typedef EdgeTy EdgeType;
|
|
149
380
|
/// Edge kind
|
|
150
|
-
typedef s64_t GNodeK;
|
|
151
381
|
typedef OrderedSet<EdgeType*, typename EdgeType::equalGEdge> GEdgeSetTy;
|
|
152
382
|
/// Edge iterator
|
|
153
383
|
///@{
|
|
@@ -156,15 +386,13 @@ public:
|
|
|
156
386
|
///@}
|
|
157
387
|
|
|
158
388
|
private:
|
|
159
|
-
NodeID id; ///< Node ID
|
|
160
|
-
GNodeK nodeKind; ///< Node kind
|
|
161
389
|
|
|
162
390
|
GEdgeSetTy InEdges; ///< all incoming edge of this node
|
|
163
391
|
GEdgeSetTy OutEdges; ///< all outgoing edge of this node
|
|
164
392
|
|
|
165
393
|
public:
|
|
166
394
|
/// Constructor
|
|
167
|
-
GenericNode(NodeID i, GNodeK k):
|
|
395
|
+
GenericNode(NodeID i, GNodeK k): SVFBaseNode(i, k)
|
|
168
396
|
{
|
|
169
397
|
|
|
170
398
|
}
|
|
@@ -176,18 +404,6 @@ public:
|
|
|
176
404
|
delete edge;
|
|
177
405
|
}
|
|
178
406
|
|
|
179
|
-
/// Get ID
|
|
180
|
-
inline NodeID getId() const
|
|
181
|
-
{
|
|
182
|
-
return id;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/// Get node kind
|
|
186
|
-
inline GNodeK getNodeKind() const
|
|
187
|
-
{
|
|
188
|
-
return nodeKind;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
407
|
/// Get incoming/outgoing edge set
|
|
192
408
|
///@{
|
|
193
409
|
inline const GEdgeSetTy& getOutEdges() const
|
|
@@ -334,6 +550,16 @@ public:
|
|
|
334
550
|
return nullptr;
|
|
335
551
|
}
|
|
336
552
|
//@}
|
|
553
|
+
|
|
554
|
+
static inline bool classof(const GenericNode<NodeTy, EdgeTy>*)
|
|
555
|
+
{
|
|
556
|
+
return true;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
static inline bool classof(const SVFBaseNode*)
|
|
560
|
+
{
|
|
561
|
+
return true;
|
|
562
|
+
}
|
|
337
563
|
};
|
|
338
564
|
|
|
339
565
|
/*
|
|
@@ -60,9 +60,6 @@ public:
|
|
|
60
60
|
|
|
61
61
|
typedef Map<const SVFFunction*, FunEntryICFGNode *> FunToFunEntryNodeMapTy;
|
|
62
62
|
typedef Map<const SVFFunction*, FunExitICFGNode *> FunToFunExitNodeMapTy;
|
|
63
|
-
typedef Map<const SVFInstruction*, CallICFGNode *> CSToCallNodeMapTy;
|
|
64
|
-
typedef Map<const SVFInstruction*, RetICFGNode *> CSToRetNodeMapTy;
|
|
65
|
-
typedef Map<const SVFInstruction*, IntraICFGNode *> InstToBlockNodeMapTy;
|
|
66
63
|
typedef std::vector<const SVFLoop *> SVFLoopVec;
|
|
67
64
|
typedef Map<const ICFGNode *, SVFLoopVec> ICFGNodeToSVFLoopVec;
|
|
68
65
|
|
|
@@ -71,9 +68,6 @@ public:
|
|
|
71
68
|
private:
|
|
72
69
|
FunToFunEntryNodeMapTy FunToFunEntryNodeMap; ///< map a function to its FunExitICFGNode
|
|
73
70
|
FunToFunExitNodeMapTy FunToFunExitNodeMap; ///< map a function to its FunEntryICFGNode
|
|
74
|
-
CSToCallNodeMapTy CSToCallNodeMap; ///< map a callsite to its CallICFGNode
|
|
75
|
-
CSToRetNodeMapTy CSToRetNodeMap; ///< map a callsite to its RetICFGNode
|
|
76
|
-
InstToBlockNodeMapTy InstToBlockNodeMap; ///< map a basic block to its ICFGNode
|
|
77
71
|
GlobalICFGNode* globalBlockNode; ///< unique basic block for all globals
|
|
78
72
|
ICFGNodeToSVFLoopVec icfgNodeToSVFLoopVec; ///< map ICFG node to the SVF loops where it resides
|
|
79
73
|
|
|
@@ -126,12 +120,6 @@ public:
|
|
|
126
120
|
return it != icfgNodeToSVFLoopVec.end();
|
|
127
121
|
}
|
|
128
122
|
|
|
129
|
-
/// Whether node is in a loop
|
|
130
|
-
inline bool isInLoop(const SVFInstruction* inst)
|
|
131
|
-
{
|
|
132
|
-
return isInLoop(getICFGNode(inst));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
123
|
/// Insert (node, loop) to icfgNodeToSVFLoopVec
|
|
136
124
|
inline void addNodeToSVFLoop(const ICFGNode *node, const SVFLoop* loop)
|
|
137
125
|
{
|
|
@@ -196,22 +184,7 @@ public:
|
|
|
196
184
|
/// Get a basic block ICFGNode
|
|
197
185
|
/// TODO:: need to fix the assertions
|
|
198
186
|
//@{
|
|
199
|
-
ICFGNode* getICFGNode(const SVFInstruction* inst);
|
|
200
|
-
|
|
201
|
-
/// Whether has the ICFGNode
|
|
202
|
-
bool hasICFGNode(const SVFInstruction* inst);
|
|
203
|
-
|
|
204
|
-
CallICFGNode* getCallICFGNode(const SVFInstruction* inst);
|
|
205
|
-
|
|
206
|
-
CallICFGNode* addCallICFGNode(const SVFInstruction* inst);
|
|
207
|
-
|
|
208
|
-
RetICFGNode* getRetICFGNode(const SVFInstruction* inst);
|
|
209
|
-
|
|
210
|
-
RetICFGNode* addRetICFGNode(const SVFInstruction* inst);
|
|
211
187
|
|
|
212
|
-
IntraICFGNode* getIntraICFGNode(const SVFInstruction* inst);
|
|
213
|
-
|
|
214
|
-
IntraICFGNode* addIntraICFGNode(const SVFInstruction* inst);
|
|
215
188
|
|
|
216
189
|
FunEntryICFGNode* getFunEntryICFGNode(const SVFFunction* fun);
|
|
217
190
|
|
|
@@ -221,11 +194,6 @@ public:
|
|
|
221
194
|
{
|
|
222
195
|
return globalBlockNode;
|
|
223
196
|
}
|
|
224
|
-
inline void addGlobalICFGNode()
|
|
225
|
-
{
|
|
226
|
-
globalBlockNode = new GlobalICFGNode(totalICFGNode++);
|
|
227
|
-
addICFGNode(globalBlockNode);
|
|
228
|
-
}
|
|
229
197
|
|
|
230
198
|
const std::vector<const ICFGNode*>& getSubNodes(const ICFGNode* node) const
|
|
231
199
|
{
|
|
@@ -272,22 +240,6 @@ private:
|
|
|
272
240
|
return all_added;
|
|
273
241
|
}
|
|
274
242
|
|
|
275
|
-
/// Get/Add IntraBlock ICFGNode
|
|
276
|
-
inline IntraICFGNode* getIntraBlock(const SVFInstruction* inst)
|
|
277
|
-
{
|
|
278
|
-
InstToBlockNodeMapTy::const_iterator it = InstToBlockNodeMap.find(inst);
|
|
279
|
-
if (it == InstToBlockNodeMap.end())
|
|
280
|
-
return nullptr;
|
|
281
|
-
return it->second;
|
|
282
|
-
}
|
|
283
|
-
inline IntraICFGNode* addIntraBlock(const SVFInstruction* inst)
|
|
284
|
-
{
|
|
285
|
-
IntraICFGNode* sNode = new IntraICFGNode(totalICFGNode++,inst);
|
|
286
|
-
addICFGNode(sNode);
|
|
287
|
-
InstToBlockNodeMap[inst] = sNode;
|
|
288
|
-
return sNode;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
243
|
/// Get/Add a function entry node
|
|
292
244
|
inline FunEntryICFGNode* getFunEntryBlock(const SVFFunction* fun)
|
|
293
245
|
{
|
|
@@ -296,13 +248,6 @@ private:
|
|
|
296
248
|
return nullptr;
|
|
297
249
|
return it->second;
|
|
298
250
|
}
|
|
299
|
-
inline FunEntryICFGNode* addFunEntryBlock(const SVFFunction* fun)
|
|
300
|
-
{
|
|
301
|
-
FunEntryICFGNode* sNode = new FunEntryICFGNode(totalICFGNode++,fun);
|
|
302
|
-
addICFGNode(sNode);
|
|
303
|
-
FunToFunEntryNodeMap[fun] = sNode;
|
|
304
|
-
return sNode;
|
|
305
|
-
}
|
|
306
251
|
|
|
307
252
|
/// Get/Add a function exit node
|
|
308
253
|
inline FunExitICFGNode* getFunExitBlock(const SVFFunction* fun)
|
|
@@ -312,47 +257,6 @@ private:
|
|
|
312
257
|
return nullptr;
|
|
313
258
|
return it->second;
|
|
314
259
|
}
|
|
315
|
-
inline FunExitICFGNode* addFunExitBlock(const SVFFunction* fun)
|
|
316
|
-
{
|
|
317
|
-
FunExitICFGNode* sNode = new FunExitICFGNode(totalICFGNode++, fun);
|
|
318
|
-
addICFGNode(sNode);
|
|
319
|
-
FunToFunExitNodeMap[fun] = sNode;
|
|
320
|
-
return sNode;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/// Get/Add a call node
|
|
324
|
-
inline CallICFGNode* addCallBlock(const SVFInstruction* cs)
|
|
325
|
-
{
|
|
326
|
-
CallICFGNode* sNode = new CallICFGNode(totalICFGNode++, cs);
|
|
327
|
-
addICFGNode(sNode);
|
|
328
|
-
CSToCallNodeMap[cs] = sNode;
|
|
329
|
-
return sNode;
|
|
330
|
-
}
|
|
331
|
-
inline CallICFGNode* getCallBlock(const SVFInstruction* cs)
|
|
332
|
-
{
|
|
333
|
-
CSToCallNodeMapTy::const_iterator it = CSToCallNodeMap.find(cs);
|
|
334
|
-
if (it == CSToCallNodeMap.end())
|
|
335
|
-
return nullptr;
|
|
336
|
-
return it->second;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/// Get/Add a return node
|
|
340
|
-
inline RetICFGNode* getRetBlock(const SVFInstruction* cs)
|
|
341
|
-
{
|
|
342
|
-
CSToRetNodeMapTy::const_iterator it = CSToRetNodeMap.find(cs);
|
|
343
|
-
if (it == CSToRetNodeMap.end())
|
|
344
|
-
return nullptr;
|
|
345
|
-
return it->second;
|
|
346
|
-
}
|
|
347
|
-
inline RetICFGNode* addRetBlock(const SVFInstruction* cs)
|
|
348
|
-
{
|
|
349
|
-
CallICFGNode* callBlockNode = getCallICFGNode(cs);
|
|
350
|
-
RetICFGNode* sNode = new RetICFGNode(totalICFGNode++, cs, callBlockNode);
|
|
351
|
-
callBlockNode->setRetICFGNode(sNode);
|
|
352
|
-
addICFGNode(sNode);
|
|
353
|
-
CSToRetNodeMap[cs] = sNode;
|
|
354
|
-
return sNode;
|
|
355
|
-
}
|
|
356
260
|
|
|
357
261
|
};
|
|
358
262
|
|