svf-lib 1.0.2212 → 1.0.2213
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-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/DDA/DDAClient.h +6 -11
- package/SVF-osx/Release-build/include/DDA/DDAPass.h +1 -1
- package/SVF-osx/Release-build/include/Graphs/CHG.h +2 -3
- package/SVF-osx/Release-build/include/Graphs/GenericGraph.h +1 -286
- package/SVF-osx/Release-build/include/MTA/MTA.h +2 -2
- package/SVF-osx/Release-build/include/MTA/TCT.h +0 -6
- package/SVF-osx/Release-build/include/MemoryModel/PointerAnalysis.h +1 -7
- package/SVF-osx/Release-build/include/SABER/DoubleFreeChecker.h +1 -1
- package/SVF-osx/Release-build/include/SABER/FileChecker.h +1 -1
- package/SVF-osx/Release-build/include/SABER/LeakChecker.h +1 -1
- package/SVF-osx/Release-build/include/SABER/SaberCondAllocator.h +1 -2
- package/SVF-osx/Release-build/include/SABER/SrcSnkDDA.h +2 -2
- package/SVF-osx/Release-build/include/SVF-LLVM/BreakConstantExpr.h +1 -1
- package/SVF-osx/Release-build/include/SVF-LLVM/CppUtil.h +1 -1
- package/SVF-osx/Release-build/include/SVF-LLVM/DCHG.h +1 -1
- package/SVF-osx/Release-build/include/SVF-LLVM/LLVMLoopAnalysis.h +1 -1
- package/SVF-osx/Release-build/include/SVF-LLVM/LLVMModule.h +2 -2
- package/SVF-osx/Release-build/include/SVF-LLVM/LLVMUtil.h +1 -1
- package/SVF-osx/Release-build/include/SVF-LLVM/ObjTypeInference.h +1 -1
- package/SVF-osx/Release-build/include/{SVFIR → SVF-LLVM}/SVFModule.h +1 -36
- package/SVF-osx/Release-build/include/SVF-LLVM/SVFValue.h +805 -0
- package/SVF-osx/Release-build/include/SVFIR/ObjTypeInfo.h +0 -1
- package/SVF-osx/Release-build/include/SVFIR/SVFIR.h +38 -11
- package/SVF-osx/Release-build/include/SVFIR/SVFStatements.h +1 -0
- package/SVF-osx/Release-build/include/SVFIR/SVFValue.h +202 -799
- package/SVF-osx/Release-build/include/Util/CDGBuilder.h +1 -1
- package/SVF-osx/Release-build/include/Util/GeneralType.h +1 -0
- package/SVF-osx/Release-build/include/Util/SVFLoopAndDomInfo.h +169 -0
- package/SVF-osx/Release-build/include/Util/SVFUtil.h +3 -1
- package/SVF-osx/Release-build/include/Util/ThreadAPI.h +2 -1
- package/SVF-osx/Release-build/include/WPA/FlowSensitive.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
|
@@ -32,897 +32,300 @@
|
|
|
32
32
|
|
|
33
33
|
#include "SVFIR/SVFType.h"
|
|
34
34
|
#include "Graphs/GraphPrinter.h"
|
|
35
|
-
|
|
36
|
-
#include "Graphs/BasicBlockG.h"
|
|
35
|
+
|
|
37
36
|
|
|
38
37
|
namespace SVF
|
|
39
38
|
{
|
|
40
39
|
|
|
41
|
-
/// LLVM Aliases and constants
|
|
42
|
-
typedef SVF::GraphPrinter GraphPrinter;
|
|
43
|
-
|
|
44
|
-
class CallGraphNode;
|
|
45
|
-
class SVFInstruction;
|
|
46
|
-
class SVFBasicBlock;
|
|
47
|
-
class SVFArgument;
|
|
48
|
-
class SVFFunction;
|
|
49
|
-
class SVFType;
|
|
50
40
|
|
|
51
|
-
class
|
|
41
|
+
class SVFBaseNode
|
|
52
42
|
{
|
|
53
|
-
friend class SVFIRWriter;
|
|
54
|
-
friend class SVFIRReader;
|
|
55
|
-
public:
|
|
56
|
-
typedef Set<const SVFBasicBlock*> BBSet;
|
|
57
|
-
typedef std::vector<const SVFBasicBlock*> BBList;
|
|
58
|
-
typedef BBList LoopBBs;
|
|
59
|
-
|
|
60
|
-
private:
|
|
61
|
-
BBList reachableBBs; ///< reachable BasicBlocks from the function entry.
|
|
62
|
-
Map<const SVFBasicBlock*,BBSet> dtBBsMap; ///< map a BasicBlock to BasicBlocks it Dominates
|
|
63
|
-
Map<const SVFBasicBlock*,BBSet> pdtBBsMap; ///< map a BasicBlock to BasicBlocks it PostDominates
|
|
64
|
-
Map<const SVFBasicBlock*,BBSet> dfBBsMap; ///< map a BasicBlock to its Dominate Frontier BasicBlocks
|
|
65
|
-
Map<const SVFBasicBlock*, LoopBBs> bb2LoopMap; ///< map a BasicBlock (if it is in a loop) to all the BasicBlocks in this loop
|
|
66
|
-
Map<const SVFBasicBlock*, u32_t> bb2PdomLevel; ///< map a BasicBlock to its level in pdom tree, used in findNearestCommonPDominator
|
|
67
|
-
Map<const SVFBasicBlock*, const SVFBasicBlock*> bb2PIdom; ///< map a BasicBlock to its immediate dominator in pdom tree, used in findNearestCommonPDominator
|
|
68
43
|
|
|
69
44
|
public:
|
|
70
|
-
SVFLoopAndDomInfo()
|
|
71
|
-
{
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
virtual ~SVFLoopAndDomInfo() {}
|
|
75
|
-
|
|
76
|
-
inline const Map<const SVFBasicBlock*,BBSet>& getDomFrontierMap() const
|
|
77
|
-
{
|
|
78
|
-
return dfBBsMap;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
inline Map<const SVFBasicBlock*,BBSet>& getDomFrontierMap()
|
|
82
|
-
{
|
|
83
|
-
return dfBBsMap;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
inline bool hasLoopInfo(const SVFBasicBlock* bb) const
|
|
87
|
-
{
|
|
88
|
-
return bb2LoopMap.find(bb) != bb2LoopMap.end();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const;
|
|
92
|
-
|
|
93
|
-
inline const SVFBasicBlock* getLoopHeader(const LoopBBs& lp) const
|
|
94
|
-
{
|
|
95
|
-
assert(!lp.empty() && "this is not a loop, empty basic block");
|
|
96
|
-
return lp.front();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
inline bool loopContainsBB(const LoopBBs& lp, const SVFBasicBlock* bb) const
|
|
100
|
-
{
|
|
101
|
-
return std::find(lp.begin(), lp.end(), bb) != lp.end();
|
|
102
|
-
}
|
|
103
45
|
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
46
|
+
enum GNodeK
|
|
47
|
+
{
|
|
48
|
+
// ┌─────────────────────────────────────────────────────────────────────────┐
|
|
49
|
+
// │ ICFGNode: Classes of inter-procedural and intra-procedural control flow │
|
|
50
|
+
// │ graph nodes (Parent class: ICFGNode) │
|
|
51
|
+
// └─────────────────────────────────────────────────────────────────────────┘
|
|
52
|
+
IntraBlock, // ├── Represents a node within a single procedure
|
|
53
|
+
GlobalBlock, // ├── Represents a global-level block
|
|
54
|
+
// │ └─ Subclass: InterICFGNode
|
|
55
|
+
FunEntryBlock, // │ ├── Entry point of a function
|
|
56
|
+
FunExitBlock, // │ ├── Exit point of a function
|
|
57
|
+
FunCallBlock, // │ ├── Call site in the function
|
|
58
|
+
FunRetBlock, // │ └── Return site in the function
|
|
59
|
+
|
|
60
|
+
// ┌─────────────────────────────────────────────────────────────────────────┐
|
|
61
|
+
// │ SVFVar: Classes of variable nodes (Parent class: SVFVar) │
|
|
62
|
+
// │ Includes two main subclasses: ValVar and ObjVar │
|
|
63
|
+
// └─────────────────────────────────────────────────────────────────────────┘
|
|
64
|
+
// └─ Subclass: ValVar (Top-level variable nodes)
|
|
65
|
+
ValNode, // ├── Represents a standard value variable
|
|
66
|
+
ArgValNode, // ├── Represents an argument value variable
|
|
67
|
+
FunValNode, // ├── Represents a function value variable
|
|
68
|
+
GepValNode, // ├── Represents a GEP value variable
|
|
69
|
+
RetValNode, // ├── Represents a return value node
|
|
70
|
+
VarargValNode, // ├── Represents a variadic argument node
|
|
71
|
+
GlobalValNode, // ├── Represents a global variable node
|
|
72
|
+
ConstAggValNode, // ├── Represents a constant aggregate value node
|
|
73
|
+
// │ └─ Subclass: ConstDataValVar
|
|
74
|
+
ConstDataValNode, // │ ├── Represents a constant data variable
|
|
75
|
+
BlackHoleValNode, // │ ├── Represents a black hole node
|
|
76
|
+
ConstFPValNode, // │ ├── Represents a constant floating-point value node
|
|
77
|
+
ConstIntValNode, // │ ├── Represents a constant integer value node
|
|
78
|
+
ConstNullptrValNode, // │ └── Represents a constant nullptr value node
|
|
79
|
+
// │ └─ Subclass: DummyValVar
|
|
80
|
+
DummyValNode, // │ └── Dummy node for uninitialized values
|
|
81
|
+
|
|
82
|
+
// └─ Subclass: ObjVar (Object variable nodes)
|
|
83
|
+
ObjNode, // ├── Represents an object variable
|
|
84
|
+
// │ └─ Subclass: GepObjVar
|
|
85
|
+
GepObjNode, // │ ├── Represents a GEP object variable
|
|
86
|
+
// │ └─ Subclass: BaseObjVar
|
|
87
|
+
BaseObjNode, // │ ├── Represents a base object node
|
|
88
|
+
FunObjNode, // │ ├── Represents a function object
|
|
89
|
+
HeapObjNode, // │ ├── Represents a heap object
|
|
90
|
+
StackObjNode, // │ ├── Represents a stack object
|
|
91
|
+
GlobalObjNode, // │ ├── Represents a global object
|
|
92
|
+
ConstAggObjNode, // │ ├── Represents a constant aggregate object
|
|
93
|
+
// │ └─ Subclass: ConstDataObjVar
|
|
94
|
+
ConstDataObjNode, // │ ├── Represents a constant data object
|
|
95
|
+
ConstFPObjNode, // │ ├── Represents a constant floating-point object
|
|
96
|
+
ConstIntObjNode, // │ ├── Represents a constant integer object
|
|
97
|
+
ConstNullptrObjNode, // │ └── Represents a constant nullptr object
|
|
98
|
+
// │ └─ Subclass: DummyObjVar
|
|
99
|
+
DummyObjNode, // │ └── Dummy node for uninitialized objects
|
|
100
|
+
|
|
101
|
+
// ┌─────────────────────────────────────────────────────────────────────────┐
|
|
102
|
+
// │ VFGNode: Classes of Value Flow Graph (VFG) node kinds (Parent class: │
|
|
103
|
+
// │ VFGNode) │
|
|
104
|
+
// │ Includes operation nodes and specialized subclasses │
|
|
105
|
+
// └─────────────────────────────────────────────────────────────────────────┘
|
|
106
|
+
Cmp, // ├── Represents a comparison operation
|
|
107
|
+
BinaryOp, // ├── Represents a binary operation
|
|
108
|
+
UnaryOp, // ├── Represents a unary operation
|
|
109
|
+
Branch, // ├── Represents a branch operation
|
|
110
|
+
DummyVProp, // ├── Dummy node for value propagation
|
|
111
|
+
NPtr, // ├── Represents a null pointer operation
|
|
112
|
+
// │ └─ Subclass: ArgumentVFGNode
|
|
113
|
+
FRet, // │ ├── Represents a function return value
|
|
114
|
+
ARet, // │ ├── Represents an argument return value
|
|
115
|
+
AParm, // │ ├── Represents an argument parameter
|
|
116
|
+
FParm, // │ └── Represents a function parameter
|
|
117
|
+
// │ └─ Subclass: StmtVFGNode
|
|
118
|
+
Addr, // │ ├── Represents an address operation
|
|
119
|
+
Copy, // │ ├── Represents a copy operation
|
|
120
|
+
Gep, // │ ├── Represents a GEP operation
|
|
121
|
+
Store, // │ ├── Represents a store operation
|
|
122
|
+
Load, // │ └── Represents a load operation
|
|
123
|
+
// │ └─ Subclass: PHIVFGNode
|
|
124
|
+
TPhi, // │ ├── Represents a type-based PHI node
|
|
125
|
+
TIntraPhi, // │ ├── Represents an intra-procedural PHI node
|
|
126
|
+
TInterPhi, // │ └── Represents an inter-procedural PHI node
|
|
127
|
+
// │ └─ Subclass: MRSVFGNode
|
|
128
|
+
FPIN, // │ ├── Function parameter input
|
|
129
|
+
FPOUT, // │ ├── Function parameter output
|
|
130
|
+
APIN, // │ ├── Argument parameter input
|
|
131
|
+
APOUT, // │ └── Argument parameter output
|
|
132
|
+
// │ └─ Subclass: MSSAPHISVFGNode
|
|
133
|
+
MPhi, // │ ├── Memory PHI node
|
|
134
|
+
MIntraPhi, // │ ├── Intra-procedural memory PHI node
|
|
135
|
+
MInterPhi, // │ └── Inter-procedural memory PHI node
|
|
136
|
+
|
|
137
|
+
// ┌─────────────────────────────────────────────────────────────────────────┐
|
|
138
|
+
// │ Additional specific graph node types │
|
|
139
|
+
// └─────────────────────────────────────────────────────────────────────────┘
|
|
140
|
+
CallNodeKd, // Callgraph node
|
|
141
|
+
CDNodeKd, // Control dependence graph node
|
|
142
|
+
CFLNodeKd, // CFL graph node
|
|
143
|
+
CHNodeKd, // Class hierarchy graph node
|
|
144
|
+
ConstraintNodeKd, // Constraint graph node
|
|
145
|
+
TCTNodeKd, // Thread creation tree node
|
|
146
|
+
DCHNodeKd, // DCHG node
|
|
147
|
+
BasicBlockKd, // Basic block node
|
|
148
|
+
OtherKd // Other node kind
|
|
149
|
+
};
|
|
123
150
|
|
|
124
|
-
inline Map<const SVFBasicBlock*,u32_t>& getBBPDomLevel()
|
|
125
|
-
{
|
|
126
|
-
return bb2PdomLevel;
|
|
127
|
-
}
|
|
128
151
|
|
|
129
|
-
|
|
152
|
+
SVFBaseNode(NodeID i, GNodeK k, const SVFType* ty = nullptr): id(i),nodeKind(k), type(ty)
|
|
130
153
|
{
|
|
131
|
-
return bb2PIdom;
|
|
132
|
-
}
|
|
133
154
|
|
|
134
|
-
inline Map<const SVFBasicBlock*,const SVFBasicBlock*>& getBB2PIdom()
|
|
135
|
-
{
|
|
136
|
-
return bb2PIdom;
|
|
137
155
|
}
|
|
138
156
|
|
|
139
|
-
|
|
140
|
-
inline
|
|
157
|
+
/// Get ID
|
|
158
|
+
inline NodeID getId() const
|
|
141
159
|
{
|
|
142
|
-
return
|
|
160
|
+
return id;
|
|
143
161
|
}
|
|
144
162
|
|
|
145
|
-
|
|
163
|
+
/// Get node kind
|
|
164
|
+
inline GNodeK getNodeKind() const
|
|
146
165
|
{
|
|
147
|
-
return
|
|
166
|
+
return nodeKind;
|
|
148
167
|
}
|
|
149
168
|
|
|
150
|
-
|
|
169
|
+
virtual const SVFType* getType() const
|
|
151
170
|
{
|
|
152
|
-
return
|
|
153
|
-
reachableBBs.end();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
inline const BBList& getReachableBBs() const
|
|
157
|
-
{
|
|
158
|
-
return reachableBBs;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
inline void setReachableBBs(BBList& bbs)
|
|
162
|
-
{
|
|
163
|
-
reachableBBs = bbs;
|
|
171
|
+
return type;
|
|
164
172
|
}
|
|
165
173
|
|
|
166
|
-
void
|
|
167
|
-
|
|
168
|
-
bool isLoopHeader(const SVFBasicBlock* bb) const;
|
|
169
|
-
|
|
170
|
-
bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
|
|
171
|
-
|
|
172
|
-
bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
|
|
173
|
-
|
|
174
|
-
/// find nearest common post dominator of two basic blocks
|
|
175
|
-
const SVFBasicBlock *findNearestCommonPDominator(const SVFBasicBlock *A, const SVFBasicBlock *B) const;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
class SVFValue
|
|
179
|
-
{
|
|
180
|
-
friend class SVFIRWriter;
|
|
181
|
-
friend class SVFIRReader;
|
|
182
|
-
friend class LLVMModuleSet;
|
|
183
|
-
|
|
184
|
-
public:
|
|
185
|
-
typedef s64_t GNodeK;
|
|
186
|
-
|
|
187
|
-
enum SVFValKind
|
|
188
|
-
{
|
|
189
|
-
SVFVal,
|
|
190
|
-
SVFFunc,
|
|
191
|
-
SVFBB,
|
|
192
|
-
SVFInst,
|
|
193
|
-
SVFCall,
|
|
194
|
-
SVFVCall,
|
|
195
|
-
SVFGlob,
|
|
196
|
-
SVFArg,
|
|
197
|
-
SVFConst,
|
|
198
|
-
SVFConstData,
|
|
199
|
-
SVFConstInt,
|
|
200
|
-
SVFConstFP,
|
|
201
|
-
SVFNullPtr,
|
|
202
|
-
SVFBlackHole,
|
|
203
|
-
SVFMetaAsValue,
|
|
204
|
-
SVFOther
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
private:
|
|
208
|
-
GNodeK kind; ///< used for classof
|
|
209
|
-
bool ptrInUncalledFun; ///< true if this pointer is in an uncalled function
|
|
210
|
-
bool constDataOrAggData; ///< true if this value is a ConstantData (e.g., numbers, string, floats) or a constantAggregate
|
|
211
|
-
|
|
212
|
-
protected:
|
|
213
|
-
const SVFType* type; ///< Type of this SVFValue
|
|
214
|
-
std::string name; ///< Short name of value for printing & debugging
|
|
215
|
-
std::string sourceLoc; ///< Source code information of this value
|
|
216
|
-
/// Constructor without name
|
|
217
|
-
SVFValue(const SVFType* ty, SVFValKind k)
|
|
218
|
-
: kind(k), ptrInUncalledFun(false),
|
|
219
|
-
constDataOrAggData(SVFConstData == k), type(ty), sourceLoc("NoLoc")
|
|
174
|
+
inline virtual void setName(const std::string& nameInfo)
|
|
220
175
|
{
|
|
176
|
+
name = nameInfo;
|
|
221
177
|
}
|
|
222
178
|
|
|
223
|
-
|
|
224
|
-
/// LLVMModule
|
|
225
|
-
inline void setConstDataOrAggData()
|
|
226
|
-
{
|
|
227
|
-
constDataOrAggData = true;
|
|
228
|
-
}
|
|
229
|
-
inline void setPtrInUncalledFunction()
|
|
179
|
+
inline virtual void setName(std::string&& nameInfo)
|
|
230
180
|
{
|
|
231
|
-
|
|
181
|
+
name = std::move(nameInfo);
|
|
232
182
|
}
|
|
233
|
-
///@}
|
|
234
|
-
public:
|
|
235
|
-
SVFValue() = delete;
|
|
236
|
-
virtual ~SVFValue() = default;
|
|
237
183
|
|
|
238
|
-
|
|
239
|
-
inline GNodeK getKind() const
|
|
240
|
-
{
|
|
241
|
-
return kind;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
inline const std::string &getName() const
|
|
184
|
+
virtual const std::string& getName() const
|
|
245
185
|
{
|
|
246
186
|
return name;
|
|
247
187
|
}
|
|
248
188
|
|
|
249
|
-
inline void setName(std::string&& n)
|
|
250
|
-
{
|
|
251
|
-
name = std::move(n);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
inline virtual const SVFType* getType() const
|
|
255
|
-
{
|
|
256
|
-
return type;
|
|
257
|
-
}
|
|
258
|
-
inline bool isConstDataOrAggData() const
|
|
259
|
-
{
|
|
260
|
-
return constDataOrAggData;
|
|
261
|
-
}
|
|
262
|
-
inline bool ptrInUncalledFunction() const
|
|
263
|
-
{
|
|
264
|
-
return ptrInUncalledFun;
|
|
265
|
-
}
|
|
266
|
-
inline bool isblackHole() const
|
|
267
|
-
{
|
|
268
|
-
return getKind() == SVFBlackHole;;
|
|
269
|
-
}
|
|
270
|
-
inline bool isNullPtr() const
|
|
271
|
-
{
|
|
272
|
-
return getKind() == SVFNullPtr;
|
|
273
|
-
}
|
|
274
189
|
inline virtual void setSourceLoc(const std::string& sourceCodeInfo)
|
|
275
190
|
{
|
|
276
191
|
sourceLoc = sourceCodeInfo;
|
|
277
192
|
}
|
|
278
|
-
inline virtual const std::string getSourceLoc() const
|
|
279
|
-
{
|
|
280
|
-
return sourceLoc;
|
|
281
|
-
}
|
|
282
193
|
|
|
283
|
-
|
|
284
|
-
std::string toString() const;
|
|
285
|
-
|
|
286
|
-
/// Overloading operator << for dumping ICFG node ID
|
|
287
|
-
//@{
|
|
288
|
-
friend OutStream& operator<<(OutStream &os, const SVFValue &value)
|
|
194
|
+
virtual const std::string getSourceLoc() const
|
|
289
195
|
{
|
|
290
|
-
return
|
|
291
|
-
}
|
|
292
|
-
//@}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
class ArgValVar;
|
|
296
|
-
|
|
297
|
-
class SVFFunction : public SVFValue
|
|
298
|
-
{
|
|
299
|
-
friend class LLVMModuleSet;
|
|
300
|
-
friend class SVFIRWriter;
|
|
301
|
-
friend class SVFIRReader;
|
|
302
|
-
friend class SVFIRBuilder;
|
|
303
|
-
|
|
304
|
-
public:
|
|
305
|
-
typename BasicBlockGraph::IDToNodeMapTy::iterator iterator;
|
|
306
|
-
typedef BasicBlockGraph::IDToNodeMapTy::const_iterator const_iterator;
|
|
307
|
-
typedef SVFLoopAndDomInfo::BBSet BBSet;
|
|
308
|
-
typedef SVFLoopAndDomInfo::BBList BBList;
|
|
309
|
-
typedef SVFLoopAndDomInfo::LoopBBs LoopBBs;
|
|
310
|
-
|
|
311
|
-
private:
|
|
312
|
-
bool isDecl; /// return true if this function does not have a body
|
|
313
|
-
bool intrinsic; /// return true if this function is an intrinsic function (e.g., llvm.dbg), which does not reside in the application code
|
|
314
|
-
bool addrTaken; /// return true if this function is address-taken (for indirect call purposes)
|
|
315
|
-
bool isUncalled; /// return true if this function is never called
|
|
316
|
-
bool isNotRet; /// return true if this function never returns
|
|
317
|
-
bool varArg; /// return true if this function supports variable arguments
|
|
318
|
-
const SVFFunctionType* funcType; /// FunctionType, which is different from the type (PointerType) of this SVFFunction
|
|
319
|
-
SVFLoopAndDomInfo* loopAndDom; /// the loop and dominate information
|
|
320
|
-
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
|
|
321
|
-
std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
|
|
322
|
-
SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
|
|
323
|
-
BasicBlockGraph* bbGraph; /// the basic block graph of this function
|
|
324
|
-
|
|
325
|
-
protected:
|
|
326
|
-
|
|
327
|
-
inline void addArgument(const ArgValVar* arg)
|
|
328
|
-
{
|
|
329
|
-
allArgs.push_back(arg);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
inline void setIsUncalledFunction(bool uncalledFunction)
|
|
333
|
-
{
|
|
334
|
-
isUncalled = uncalledFunction;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
inline void setIsNotRet(bool notRet)
|
|
338
|
-
{
|
|
339
|
-
isNotRet = notRet;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
inline void setDefFunForMultipleModule(const SVFFunction* deffun)
|
|
343
|
-
{
|
|
344
|
-
realDefFun = deffun;
|
|
345
|
-
}
|
|
346
|
-
/// @}
|
|
347
|
-
|
|
348
|
-
public:
|
|
349
|
-
SVFFunction(const SVFType* ty,const SVFFunctionType* ft, bool declare, bool intrinsic, bool addrTaken, bool varg, SVFLoopAndDomInfo* ld);
|
|
350
|
-
SVFFunction(void) = delete;
|
|
351
|
-
virtual ~SVFFunction();
|
|
352
|
-
|
|
353
|
-
static inline bool classof(const SVFValue *node)
|
|
354
|
-
{
|
|
355
|
-
return node->getKind() == SVFFunc;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
inline SVFLoopAndDomInfo* getLoopAndDomInfo()
|
|
359
|
-
{
|
|
360
|
-
return loopAndDom;
|
|
361
|
-
}
|
|
362
|
-
inline bool isDeclaration() const
|
|
363
|
-
{
|
|
364
|
-
return isDecl;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
void setBasicBlockGraph(BasicBlockGraph* graph)
|
|
368
|
-
{
|
|
369
|
-
this->bbGraph = graph;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
BasicBlockGraph* getBasicBlockGraph()
|
|
373
|
-
{
|
|
374
|
-
return bbGraph;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
const BasicBlockGraph* getBasicBlockGraph() const
|
|
378
|
-
{
|
|
379
|
-
return bbGraph;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
inline bool isIntrinsic() const
|
|
383
|
-
{
|
|
384
|
-
return intrinsic;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
inline bool hasAddressTaken() const
|
|
388
|
-
{
|
|
389
|
-
return addrTaken;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/// Returns the FunctionType
|
|
393
|
-
inline const SVFFunctionType* getFunctionType() const
|
|
394
|
-
{
|
|
395
|
-
return funcType;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/// Returns the FunctionType
|
|
399
|
-
inline const SVFType* getReturnType() const
|
|
400
|
-
{
|
|
401
|
-
return funcType->getReturnType();
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
inline const SVFFunction* getDefFunForMultipleModule() const
|
|
405
|
-
{
|
|
406
|
-
if(realDefFun==nullptr)
|
|
407
|
-
return this;
|
|
408
|
-
return realDefFun;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
u32_t arg_size() const;
|
|
412
|
-
const ArgValVar* getArg(u32_t idx) const;
|
|
413
|
-
bool isVarArg() const;
|
|
414
|
-
|
|
415
|
-
inline bool hasBasicBlock() const
|
|
416
|
-
{
|
|
417
|
-
return bbGraph && bbGraph->begin() != bbGraph->end();
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
inline const SVFBasicBlock* getEntryBlock() const
|
|
421
|
-
{
|
|
422
|
-
assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
|
|
423
|
-
assert(bbGraph->begin()->second->getInEdges().size() == 0 && "the first basic block is not entry block");
|
|
424
|
-
return bbGraph->begin()->second;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/// Carefully! when you call getExitBB, you need ensure the function has return instruction
|
|
428
|
-
/// more refer to: https://github.com/SVF-tools/SVF/pull/1262
|
|
429
|
-
const SVFBasicBlock* getExitBB() const;
|
|
430
|
-
|
|
431
|
-
void setExitBlock(SVFBasicBlock *bb);
|
|
432
|
-
|
|
433
|
-
inline const SVFBasicBlock* front() const
|
|
434
|
-
{
|
|
435
|
-
return getEntryBlock();
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
inline const SVFBasicBlock* back() const
|
|
439
|
-
{
|
|
440
|
-
assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
|
|
441
|
-
/// Carefully! 'back' is just the last basic block of function,
|
|
442
|
-
/// but not necessarily a exit basic block
|
|
443
|
-
/// more refer to: https://github.com/SVF-tools/SVF/pull/1262
|
|
444
|
-
return std::prev(bbGraph->end())->second;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
inline const_iterator begin() const
|
|
448
|
-
{
|
|
449
|
-
return bbGraph->begin();
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
inline const_iterator end() const
|
|
453
|
-
{
|
|
454
|
-
return bbGraph->end();
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
inline const std::vector<const SVFBasicBlock*>& getReachableBBs() const
|
|
459
|
-
{
|
|
460
|
-
return loopAndDom->getReachableBBs();
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
inline bool isUncalledFunction() const
|
|
464
|
-
{
|
|
465
|
-
return isUncalled;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
inline bool hasReturn() const
|
|
469
|
-
{
|
|
470
|
-
return !isNotRet;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
inline void getExitBlocksOfLoop(const SVFBasicBlock* bb, BBList& exitbbs) const
|
|
474
|
-
{
|
|
475
|
-
return loopAndDom->getExitBlocksOfLoop(bb,exitbbs);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
inline bool hasLoopInfo(const SVFBasicBlock* bb) const
|
|
479
|
-
{
|
|
480
|
-
return loopAndDom->hasLoopInfo(bb);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const
|
|
484
|
-
{
|
|
485
|
-
return loopAndDom->getLoopInfo(bb);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
inline const SVFBasicBlock* getLoopHeader(const BBList& lp) const
|
|
489
|
-
{
|
|
490
|
-
return loopAndDom->getLoopHeader(lp);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
inline bool loopContainsBB(const BBList& lp, const SVFBasicBlock* bb) const
|
|
494
|
-
{
|
|
495
|
-
return loopAndDom->loopContainsBB(lp,bb);
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
inline const Map<const SVFBasicBlock*,BBSet>& getDomTreeMap() const
|
|
499
|
-
{
|
|
500
|
-
return loopAndDom->getDomTreeMap();
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
inline const Map<const SVFBasicBlock*,BBSet>& getDomFrontierMap() const
|
|
504
|
-
{
|
|
505
|
-
return loopAndDom->getDomFrontierMap();
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
inline bool isLoopHeader(const SVFBasicBlock* bb) const
|
|
509
|
-
{
|
|
510
|
-
return loopAndDom->isLoopHeader(bb);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
inline bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
|
|
514
|
-
{
|
|
515
|
-
return loopAndDom->dominate(bbKey,bbValue);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
inline bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
|
|
519
|
-
{
|
|
520
|
-
return loopAndDom->postDominate(bbKey,bbValue);
|
|
521
|
-
}
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
class ICFGNode;
|
|
525
|
-
class FunObjVar;
|
|
526
|
-
|
|
527
|
-
class SVFInstruction : public SVFValue
|
|
528
|
-
{
|
|
529
|
-
friend class SVFIRWriter;
|
|
530
|
-
friend class SVFIRReader;
|
|
531
|
-
|
|
532
|
-
private:
|
|
533
|
-
const SVFBasicBlock* bb; /// The BasicBlock where this Instruction resides
|
|
534
|
-
bool terminator; /// return true if this is a terminator instruction
|
|
535
|
-
bool ret; /// return true if this is an return instruction of a function
|
|
536
|
-
|
|
537
|
-
public:
|
|
538
|
-
/// Constructor without name, set name with setName()
|
|
539
|
-
SVFInstruction(const SVFType* ty, const SVFBasicBlock* b, bool tm,
|
|
540
|
-
bool isRet, SVFValKind k = SVFInst);
|
|
541
|
-
SVFInstruction(void) = delete;
|
|
542
|
-
|
|
543
|
-
static inline bool classof(const SVFValue *node)
|
|
544
|
-
{
|
|
545
|
-
return node->getKind() == SVFInst ||
|
|
546
|
-
node->getKind() == SVFCall ||
|
|
547
|
-
node->getKind() == SVFVCall;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
inline const SVFBasicBlock* getParent() const
|
|
551
|
-
{
|
|
552
|
-
return bb;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
inline const FunObjVar* getFunction() const
|
|
556
|
-
{
|
|
557
|
-
return bb->getParent();
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
inline bool isRetInst() const
|
|
561
|
-
{
|
|
562
|
-
return ret;
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
class SVFCallInst : public SVFInstruction
|
|
567
|
-
{
|
|
568
|
-
friend class SVFIRWriter;
|
|
569
|
-
friend class SVFIRReader;
|
|
570
|
-
friend class LLVMModuleSet;
|
|
571
|
-
friend class SVFIRBuilder;
|
|
572
|
-
|
|
573
|
-
private:
|
|
574
|
-
std::vector<const SVFValue*> args;
|
|
575
|
-
bool varArg;
|
|
576
|
-
const SVFValue* calledVal;
|
|
577
|
-
|
|
578
|
-
protected:
|
|
579
|
-
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
580
|
-
inline void addArgument(const SVFValue* a)
|
|
581
|
-
{
|
|
582
|
-
args.push_back(a);
|
|
583
|
-
}
|
|
584
|
-
inline void setCalledOperand(const SVFValue* v)
|
|
585
|
-
{
|
|
586
|
-
calledVal = v;
|
|
587
|
-
}
|
|
588
|
-
/// @}
|
|
589
|
-
|
|
590
|
-
public:
|
|
591
|
-
SVFCallInst(const SVFType* ty, const SVFBasicBlock* b, bool va, bool tm, SVFValKind k = SVFCall) :
|
|
592
|
-
SVFInstruction(ty, b, tm, false, k), varArg(va), calledVal(nullptr)
|
|
593
|
-
{
|
|
594
|
-
}
|
|
595
|
-
SVFCallInst(void) = delete;
|
|
596
|
-
|
|
597
|
-
static inline bool classof(const SVFValue *node)
|
|
598
|
-
{
|
|
599
|
-
return node->getKind() == SVFCall || node->getKind() == SVFVCall;
|
|
600
|
-
}
|
|
601
|
-
static inline bool classof(const SVFInstruction *node)
|
|
602
|
-
{
|
|
603
|
-
return node->getKind() == SVFCall || node->getKind() == SVFVCall;
|
|
604
|
-
}
|
|
605
|
-
inline u32_t arg_size() const
|
|
606
|
-
{
|
|
607
|
-
return args.size();
|
|
608
|
-
}
|
|
609
|
-
inline bool arg_empty() const
|
|
610
|
-
{
|
|
611
|
-
return args.empty();
|
|
612
|
-
}
|
|
613
|
-
inline const SVFValue* getArgOperand(u32_t i) const
|
|
614
|
-
{
|
|
615
|
-
assert(i < arg_size() && "out of bound access of the argument");
|
|
616
|
-
return args[i];
|
|
617
|
-
}
|
|
618
|
-
inline u32_t getNumArgOperands() const
|
|
619
|
-
{
|
|
620
|
-
return arg_size();
|
|
621
|
-
}
|
|
622
|
-
inline const SVFValue* getCalledOperand() const
|
|
623
|
-
{
|
|
624
|
-
return calledVal;
|
|
625
|
-
}
|
|
626
|
-
inline bool isVarArg() const
|
|
627
|
-
{
|
|
628
|
-
return varArg;
|
|
629
|
-
}
|
|
630
|
-
inline const SVFFunction* getCalledFunction() const
|
|
631
|
-
{
|
|
632
|
-
return SVFUtil::dyn_cast<SVFFunction>(calledVal);
|
|
633
|
-
}
|
|
634
|
-
inline const FunObjVar* getCaller() const
|
|
635
|
-
{
|
|
636
|
-
return getFunction();
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
class SVFConstant : public SVFValue
|
|
641
|
-
{
|
|
642
|
-
friend class SVFIRWriter;
|
|
643
|
-
friend class SVFIRReader;
|
|
644
|
-
public:
|
|
645
|
-
SVFConstant(const SVFType* ty, SVFValKind k = SVFConst): SVFValue(ty, k)
|
|
646
|
-
{
|
|
647
|
-
}
|
|
648
|
-
SVFConstant() = delete;
|
|
649
|
-
|
|
650
|
-
static inline bool classof(const SVFValue *node)
|
|
651
|
-
{
|
|
652
|
-
return node->getKind() == SVFConst ||
|
|
653
|
-
node->getKind() == SVFGlob ||
|
|
654
|
-
node->getKind() == SVFConstData ||
|
|
655
|
-
node->getKind() == SVFConstInt ||
|
|
656
|
-
node->getKind() == SVFConstFP ||
|
|
657
|
-
node->getKind() == SVFNullPtr ||
|
|
658
|
-
node->getKind() == SVFBlackHole;
|
|
196
|
+
return sourceLoc;
|
|
659
197
|
}
|
|
660
198
|
|
|
661
|
-
|
|
199
|
+
const std::string valueOnlyToString() const;
|
|
662
200
|
|
|
663
|
-
class SVFGlobalValue : public SVFConstant
|
|
664
|
-
{
|
|
665
|
-
friend class SVFIRWriter;
|
|
666
|
-
friend class SVFIRReader;
|
|
667
|
-
friend class LLVMModuleSet;
|
|
668
|
-
|
|
669
|
-
private:
|
|
670
|
-
const SVFValue* realDefGlobal; /// the definition of a function across multiple modules
|
|
671
201
|
|
|
672
202
|
protected:
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
203
|
+
NodeID id; ///< Node ID
|
|
204
|
+
GNodeK nodeKind; ///< Node kind
|
|
205
|
+
const SVFType* type; ///< SVF type
|
|
677
206
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
{
|
|
681
|
-
}
|
|
682
|
-
SVFGlobalValue(std::string&& name, const SVFType* ty) : SVFGlobalValue(ty)
|
|
683
|
-
{
|
|
684
|
-
setName(std::move(name));
|
|
685
|
-
}
|
|
686
|
-
SVFGlobalValue() = delete;
|
|
687
|
-
|
|
688
|
-
inline const SVFValue* getDefGlobalForMultipleModule() const
|
|
689
|
-
{
|
|
690
|
-
if(realDefGlobal==nullptr)
|
|
691
|
-
return this;
|
|
692
|
-
return realDefGlobal;
|
|
693
|
-
}
|
|
694
|
-
static inline bool classof(const SVFValue *node)
|
|
695
|
-
{
|
|
696
|
-
return node->getKind() == SVFGlob;
|
|
697
|
-
}
|
|
698
|
-
static inline bool classof(const SVFConstant *node)
|
|
699
|
-
{
|
|
700
|
-
return node->getKind() == SVFGlob;
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
|
|
704
|
-
class SVFArgument : public SVFValue
|
|
705
|
-
{
|
|
706
|
-
friend class SVFIRWriter;
|
|
707
|
-
friend class SVFIRReader;
|
|
708
|
-
private:
|
|
709
|
-
const SVFFunction* fun;
|
|
710
|
-
u32_t argNo;
|
|
711
|
-
bool uncalled;
|
|
712
|
-
public:
|
|
713
|
-
SVFArgument(const SVFType* ty, const SVFFunction* fun, u32_t argNo,
|
|
714
|
-
bool uncalled)
|
|
715
|
-
: SVFValue(ty, SVFValue::SVFArg), fun(fun), argNo(argNo),
|
|
716
|
-
uncalled(uncalled)
|
|
717
|
-
{
|
|
718
|
-
}
|
|
719
|
-
SVFArgument() = delete;
|
|
720
|
-
|
|
721
|
-
inline const SVFFunction* getParent() const
|
|
722
|
-
{
|
|
723
|
-
return fun;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/// Return the index of this formal argument in its containing function.
|
|
727
|
-
/// For example in "void foo(int a, float b)" a is 0 and b is 1.
|
|
728
|
-
inline u32_t getArgNo() const
|
|
729
|
-
{
|
|
730
|
-
return argNo;
|
|
731
|
-
}
|
|
207
|
+
std::string name;
|
|
208
|
+
std::string sourceLoc; ///< Source code information of this value
|
|
732
209
|
|
|
733
|
-
|
|
210
|
+
/// Helper functions to check node kinds
|
|
211
|
+
//{@ Check node kind
|
|
212
|
+
static inline bool isICFGNodeKinds(GNodeK n)
|
|
734
213
|
{
|
|
735
|
-
|
|
214
|
+
static_assert(FunRetBlock - IntraBlock == 5,
|
|
215
|
+
"the number of ICFGNodeKinds has changed, make sure "
|
|
216
|
+
"the range is correct");
|
|
217
|
+
return n <= FunRetBlock && n >= IntraBlock;
|
|
736
218
|
}
|
|
737
219
|
|
|
738
|
-
static inline bool
|
|
220
|
+
static inline bool isInterICFGNodeKind(GNodeK n)
|
|
739
221
|
{
|
|
740
|
-
|
|
222
|
+
static_assert(FunRetBlock - FunEntryBlock == 3,
|
|
223
|
+
"the number of InterICFGNodeKind has changed, make sure "
|
|
224
|
+
"the range is correct");
|
|
225
|
+
return n <= FunRetBlock && n >= FunEntryBlock;
|
|
741
226
|
}
|
|
742
|
-
};
|
|
743
227
|
|
|
744
|
-
|
|
745
|
-
{
|
|
746
|
-
friend class SVFIRWriter;
|
|
747
|
-
friend class SVFIRReader;
|
|
748
|
-
public:
|
|
749
|
-
SVFConstantData(const SVFType* ty, SVFValKind k = SVFConstData)
|
|
750
|
-
: SVFConstant(ty, k)
|
|
228
|
+
static inline bool isSVFVarKind(GNodeK n)
|
|
751
229
|
{
|
|
752
|
-
|
|
753
|
-
|
|
230
|
+
static_assert(DummyObjNode - ValNode == 26,
|
|
231
|
+
"The number of SVFVarKinds has changed, make sure the "
|
|
232
|
+
"range is correct");
|
|
754
233
|
|
|
755
|
-
|
|
756
|
-
{
|
|
757
|
-
return node->getKind() == SVFConstData ||
|
|
758
|
-
node->getKind() == SVFConstInt ||
|
|
759
|
-
node->getKind() == SVFConstFP ||
|
|
760
|
-
node->getKind() == SVFNullPtr ||
|
|
761
|
-
node->getKind() == SVFBlackHole;
|
|
762
|
-
}
|
|
763
|
-
static inline bool classof(const SVFConstantData *node)
|
|
764
|
-
{
|
|
765
|
-
return node->getKind() == SVFConstData ||
|
|
766
|
-
node->getKind() == SVFConstInt ||
|
|
767
|
-
node->getKind() == SVFConstFP ||
|
|
768
|
-
node->getKind() == SVFNullPtr ||
|
|
769
|
-
node->getKind() == SVFBlackHole;
|
|
234
|
+
return n <= DummyObjNode && n >= ValNode;
|
|
770
235
|
}
|
|
771
|
-
};
|
|
772
236
|
|
|
773
|
-
|
|
774
|
-
{
|
|
775
|
-
friend class SVFIRWriter;
|
|
776
|
-
friend class SVFIRReader;
|
|
777
|
-
private:
|
|
778
|
-
u64_t zval;
|
|
779
|
-
s64_t sval;
|
|
780
|
-
public:
|
|
781
|
-
SVFConstantInt(const SVFType* ty, u64_t z, s64_t s)
|
|
782
|
-
: SVFConstantData(ty, SVFValue::SVFConstInt), zval(z), sval(s)
|
|
237
|
+
static inline bool isValVarKinds(GNodeK n)
|
|
783
238
|
{
|
|
239
|
+
static_assert(DummyValNode - ValNode == 13,
|
|
240
|
+
"The number of ValVarKinds has changed, make sure the "
|
|
241
|
+
"range is correct");
|
|
242
|
+
return n <= DummyValNode && n >= ValNode;
|
|
784
243
|
}
|
|
785
|
-
SVFConstantInt() = delete;
|
|
786
244
|
|
|
787
|
-
static inline bool classof(const SVFValue *node)
|
|
788
|
-
{
|
|
789
|
-
return node->getKind() == SVFConstInt;
|
|
790
|
-
}
|
|
791
|
-
static inline bool classof(const SVFConstantData *node)
|
|
792
|
-
{
|
|
793
|
-
return node->getKind() == SVFConstInt;
|
|
794
|
-
}
|
|
795
|
-
// Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate for the type of this constant.
|
|
796
|
-
inline u64_t getZExtValue () const
|
|
797
|
-
{
|
|
798
|
-
return zval;
|
|
799
|
-
}
|
|
800
|
-
// Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the type of this constant
|
|
801
|
-
inline s64_t getSExtValue () const
|
|
802
|
-
{
|
|
803
|
-
return sval;
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
245
|
|
|
807
|
-
|
|
808
|
-
{
|
|
809
|
-
friend class SVFIRWriter;
|
|
810
|
-
friend class SVFIRReader;
|
|
811
|
-
private:
|
|
812
|
-
float dval;
|
|
813
|
-
public:
|
|
814
|
-
SVFConstantFP(const SVFType* ty, double d)
|
|
815
|
-
: SVFConstantData(ty, SVFValue::SVFConstFP), dval(d)
|
|
246
|
+
static inline bool isConstantDataValVar(GNodeK n)
|
|
816
247
|
{
|
|
248
|
+
static_assert(ConstNullptrValNode - ConstDataValNode == 4,
|
|
249
|
+
"The number of ConstantDataValVarKinds has changed, make "
|
|
250
|
+
"sure the range is correct");
|
|
251
|
+
return n <= ConstNullptrValNode && n >= ConstDataValNode;
|
|
817
252
|
}
|
|
818
|
-
SVFConstantFP() = delete;
|
|
819
253
|
|
|
820
|
-
inline
|
|
821
|
-
{
|
|
822
|
-
return dval;
|
|
823
|
-
}
|
|
824
|
-
static inline bool classof(const SVFValue *node)
|
|
254
|
+
static inline bool isObjVarKinds(GNodeK n)
|
|
825
255
|
{
|
|
826
|
-
|
|
256
|
+
static_assert(DummyObjNode - ObjNode == 12,
|
|
257
|
+
"The number of ObjVarKinds has changed, make sure the "
|
|
258
|
+
"range is correct");
|
|
259
|
+
return n <= DummyObjNode && n >= ObjNode;
|
|
827
260
|
}
|
|
828
|
-
static inline bool classof(const SVFConstantData *node)
|
|
829
|
-
{
|
|
830
|
-
return node->getKind() == SVFConstFP;
|
|
831
|
-
}
|
|
832
|
-
};
|
|
833
|
-
|
|
834
|
-
class SVFConstantNullPtr : public SVFConstantData
|
|
835
|
-
{
|
|
836
|
-
friend class SVFIRWriter;
|
|
837
|
-
friend class SVFIRReader;
|
|
838
261
|
|
|
839
|
-
|
|
840
|
-
SVFConstantNullPtr(const SVFType* ty)
|
|
841
|
-
: SVFConstantData(ty, SVFValue::SVFNullPtr)
|
|
262
|
+
static inline bool isBaseObjVarKinds(GNodeK n)
|
|
842
263
|
{
|
|
264
|
+
static_assert(DummyObjNode - BaseObjNode == 10,
|
|
265
|
+
"The number of BaseObjVarKinds has changed, make sure the "
|
|
266
|
+
"range is correct");
|
|
267
|
+
return n <= DummyObjNode && n >= BaseObjNode;
|
|
843
268
|
}
|
|
844
|
-
SVFConstantNullPtr() = delete;
|
|
845
269
|
|
|
846
|
-
static inline bool
|
|
847
|
-
{
|
|
848
|
-
return node->getKind() == SVFNullPtr;
|
|
849
|
-
}
|
|
850
|
-
static inline bool classof(const SVFConstantData *node)
|
|
270
|
+
static inline bool isConstantDataObjVarKinds(GNodeK n)
|
|
851
271
|
{
|
|
852
|
-
|
|
272
|
+
static_assert(ConstNullptrObjNode - ConstDataObjNode == 3,
|
|
273
|
+
"The number of ConstantDataObjVarKinds has changed, make "
|
|
274
|
+
"sure the range is correct");
|
|
275
|
+
return n <= ConstNullptrObjNode && n >= ConstDataObjNode;
|
|
853
276
|
}
|
|
854
|
-
};
|
|
855
|
-
|
|
856
|
-
class SVFBlackHoleValue : public SVFConstantData
|
|
857
|
-
{
|
|
858
|
-
friend class SVFIRWriter;
|
|
859
|
-
friend class SVFIRReader;
|
|
860
277
|
|
|
861
|
-
|
|
862
|
-
SVFBlackHoleValue(const SVFType* ty)
|
|
863
|
-
: SVFConstantData(ty, SVFValue::SVFBlackHole)
|
|
278
|
+
static inline bool isVFGNodeKinds(GNodeK n)
|
|
864
279
|
{
|
|
280
|
+
static_assert(MInterPhi - Cmp == 24,
|
|
281
|
+
"The number of VFGNodeKinds has changed, make sure the "
|
|
282
|
+
"range is correct");
|
|
283
|
+
return n <= MInterPhi && n >= Cmp;
|
|
865
284
|
}
|
|
866
|
-
SVFBlackHoleValue() = delete;
|
|
867
285
|
|
|
868
|
-
static inline bool
|
|
869
|
-
{
|
|
870
|
-
return node->getKind() == SVFBlackHole;
|
|
871
|
-
}
|
|
872
|
-
static inline bool classof(const SVFConstantData *node)
|
|
286
|
+
static inline bool isArgumentVFGNodeKinds(GNodeK n)
|
|
873
287
|
{
|
|
874
|
-
|
|
288
|
+
static_assert(FParm - FRet == 3,
|
|
289
|
+
"The number of ArgumentVFGNodeKinds has changed, make "
|
|
290
|
+
"sure the range is correct");
|
|
291
|
+
return n <= FParm && n >= FRet;
|
|
875
292
|
}
|
|
876
|
-
};
|
|
877
293
|
|
|
878
|
-
|
|
879
|
-
{
|
|
880
|
-
friend class SVFIRWriter;
|
|
881
|
-
friend class SVFIRReader;
|
|
882
|
-
public:
|
|
883
|
-
SVFOtherValue(const SVFType* ty, SVFValKind k = SVFValue::SVFOther)
|
|
884
|
-
: SVFValue(ty, k)
|
|
294
|
+
static inline bool isStmtVFGNodeKinds(GNodeK n)
|
|
885
295
|
{
|
|
296
|
+
static_assert(Load - Addr == 4,
|
|
297
|
+
"The number of StmtVFGNodeKinds has changed, make sure "
|
|
298
|
+
"the range is correct");
|
|
299
|
+
return n <= Load && n >= Addr;
|
|
886
300
|
}
|
|
887
|
-
SVFOtherValue() = delete;
|
|
888
301
|
|
|
889
|
-
static inline bool
|
|
302
|
+
static inline bool isPHIVFGNodeKinds(GNodeK n)
|
|
890
303
|
{
|
|
891
|
-
|
|
304
|
+
static_assert(TInterPhi - TPhi == 2,
|
|
305
|
+
"The number of PHIVFGNodeKinds has changed, make sure "
|
|
306
|
+
"the range is correct");
|
|
307
|
+
return n <= TInterPhi && n >= TPhi;
|
|
892
308
|
}
|
|
893
|
-
};
|
|
894
309
|
|
|
895
|
-
|
|
896
|
-
* This class is only for LLVM's MetadataAsValue
|
|
897
|
-
*/
|
|
898
|
-
class SVFMetadataAsValue : public SVFOtherValue
|
|
899
|
-
{
|
|
900
|
-
friend class SVFIRWriter;
|
|
901
|
-
friend class SVFIRReader;
|
|
902
|
-
public:
|
|
903
|
-
SVFMetadataAsValue(const SVFType* ty)
|
|
904
|
-
: SVFOtherValue(ty, SVFValue::SVFMetaAsValue)
|
|
310
|
+
static inline bool isMRSVFGNodeKinds(GNodeK n)
|
|
905
311
|
{
|
|
312
|
+
static_assert(MInterPhi - FPIN == 6,
|
|
313
|
+
"The number of MRSVFGNodeKinds has changed, make sure "
|
|
314
|
+
"the range is correct");
|
|
315
|
+
return n <= MInterPhi && n >= FPIN;
|
|
906
316
|
}
|
|
907
|
-
SVFMetadataAsValue() = delete;
|
|
908
317
|
|
|
909
|
-
static inline bool
|
|
318
|
+
static inline bool isMSSAPHISVFGNodeKinds(GNodeK n)
|
|
910
319
|
{
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
return node->getKind() == SVFMetaAsValue;
|
|
320
|
+
static_assert(MInterPhi - MPhi == 2,
|
|
321
|
+
"The number of MSSAPHISVFGNodeKinds has changed, make "
|
|
322
|
+
"sure the range is correct");
|
|
323
|
+
return n <= MInterPhi && n >= MPhi;
|
|
916
324
|
}
|
|
325
|
+
//@}
|
|
917
326
|
};
|
|
918
327
|
|
|
919
328
|
|
|
920
|
-
/// [FOR DEBUG ONLY, DON'T USE IT UNSIDE `svf`!]
|
|
921
|
-
/// Converts an SVFValue to corresponding LLVM::Value, then get the string
|
|
922
|
-
/// representation of it. Use it only when you are debugging. Don't use
|
|
923
|
-
/// it in any SVF algorithm because it relies on information stored in LLVM bc.
|
|
924
|
-
std::string dumpLLVMValue(const SVFValue* svfValue);
|
|
925
|
-
|
|
926
329
|
template <typename F, typename S>
|
|
927
330
|
OutStream& operator<< (OutStream &o, const std::pair<F, S> &var)
|
|
928
331
|
{
|
|
@@ -930,6 +333,6 @@ OutStream& operator<< (OutStream &o, const std::pair<F, S> &var)
|
|
|
930
333
|
return o;
|
|
931
334
|
}
|
|
932
335
|
|
|
933
|
-
}
|
|
336
|
+
}
|
|
934
337
|
|
|
935
338
|
#endif /* INCLUDE_SVFIR_SVFVALUE_H_ */
|