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
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
//===- BasicTypes.h -- Basic types used in SVF-------------------------------//
|
|
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
|
+
* BasicTypes.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Apr 1, 2014
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef INCLUDE_SVFLLVM_SVFVALUE_H_
|
|
31
|
+
#define INCLUDE_SVFLLVM_SVFVALUE_H_
|
|
32
|
+
|
|
33
|
+
#include "SVFIR/SVFType.h"
|
|
34
|
+
#include "Graphs/GraphPrinter.h"
|
|
35
|
+
#include "Util/Casting.h"
|
|
36
|
+
#include "Graphs/BasicBlockG.h"
|
|
37
|
+
#include "SVFIR/SVFValue.h"
|
|
38
|
+
#include "Util/SVFLoopAndDomInfo.h"
|
|
39
|
+
|
|
40
|
+
namespace SVF
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
/// LLVM Aliases and constants
|
|
44
|
+
typedef SVF::GraphPrinter GraphPrinter;
|
|
45
|
+
|
|
46
|
+
class CallGraphNode;
|
|
47
|
+
class SVFInstruction;
|
|
48
|
+
class SVFBasicBlock;
|
|
49
|
+
class SVFArgument;
|
|
50
|
+
class SVFFunction;
|
|
51
|
+
class SVFType;
|
|
52
|
+
|
|
53
|
+
class SVFValue
|
|
54
|
+
{
|
|
55
|
+
friend class SVFIRWriter;
|
|
56
|
+
friend class SVFIRReader;
|
|
57
|
+
friend class LLVMModuleSet;
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
typedef s64_t GNodeK;
|
|
61
|
+
|
|
62
|
+
enum SVFValKind
|
|
63
|
+
{
|
|
64
|
+
SVFVal,
|
|
65
|
+
SVFFunc,
|
|
66
|
+
SVFBB,
|
|
67
|
+
SVFInst,
|
|
68
|
+
SVFCall,
|
|
69
|
+
SVFVCall,
|
|
70
|
+
SVFGlob,
|
|
71
|
+
SVFArg,
|
|
72
|
+
SVFConst,
|
|
73
|
+
SVFConstData,
|
|
74
|
+
SVFConstInt,
|
|
75
|
+
SVFConstFP,
|
|
76
|
+
SVFNullPtr,
|
|
77
|
+
SVFBlackHole,
|
|
78
|
+
SVFMetaAsValue,
|
|
79
|
+
SVFOther
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
private:
|
|
83
|
+
GNodeK kind; ///< used for classof
|
|
84
|
+
bool ptrInUncalledFun; ///< true if this pointer is in an uncalled function
|
|
85
|
+
bool constDataOrAggData; ///< true if this value is a ConstantData (e.g., numbers, string, floats) or a constantAggregate
|
|
86
|
+
|
|
87
|
+
protected:
|
|
88
|
+
const SVFType* type; ///< Type of this SVFValue
|
|
89
|
+
std::string name; ///< Short name of value for printing & debugging
|
|
90
|
+
std::string sourceLoc; ///< Source code information of this value
|
|
91
|
+
/// Constructor without name
|
|
92
|
+
SVFValue(const SVFType* ty, SVFValKind k)
|
|
93
|
+
: kind(k), ptrInUncalledFun(false),
|
|
94
|
+
constDataOrAggData(SVFConstData == k), type(ty), sourceLoc("NoLoc")
|
|
95
|
+
{
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
///@{ attributes to be set only through Module builders e.g.,
|
|
99
|
+
/// LLVMModule
|
|
100
|
+
inline void setConstDataOrAggData()
|
|
101
|
+
{
|
|
102
|
+
constDataOrAggData = true;
|
|
103
|
+
}
|
|
104
|
+
inline void setPtrInUncalledFunction()
|
|
105
|
+
{
|
|
106
|
+
ptrInUncalledFun = true;
|
|
107
|
+
}
|
|
108
|
+
///@}
|
|
109
|
+
public:
|
|
110
|
+
SVFValue() = delete;
|
|
111
|
+
virtual ~SVFValue() = default;
|
|
112
|
+
|
|
113
|
+
/// Get the type of this SVFValue
|
|
114
|
+
inline GNodeK getKind() const
|
|
115
|
+
{
|
|
116
|
+
return kind;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
inline const std::string &getName() const
|
|
120
|
+
{
|
|
121
|
+
return name;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
inline void setName(std::string&& n)
|
|
125
|
+
{
|
|
126
|
+
name = std::move(n);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
inline virtual const SVFType* getType() const
|
|
130
|
+
{
|
|
131
|
+
return type;
|
|
132
|
+
}
|
|
133
|
+
inline bool isConstDataOrAggData() const
|
|
134
|
+
{
|
|
135
|
+
return constDataOrAggData;
|
|
136
|
+
}
|
|
137
|
+
inline bool ptrInUncalledFunction() const
|
|
138
|
+
{
|
|
139
|
+
return ptrInUncalledFun;
|
|
140
|
+
}
|
|
141
|
+
inline bool isblackHole() const
|
|
142
|
+
{
|
|
143
|
+
return getKind() == SVFBlackHole;;
|
|
144
|
+
}
|
|
145
|
+
inline bool isNullPtr() const
|
|
146
|
+
{
|
|
147
|
+
return getKind() == SVFNullPtr;
|
|
148
|
+
}
|
|
149
|
+
inline virtual void setSourceLoc(const std::string& sourceCodeInfo)
|
|
150
|
+
{
|
|
151
|
+
sourceLoc = sourceCodeInfo;
|
|
152
|
+
}
|
|
153
|
+
inline virtual const std::string getSourceLoc() const
|
|
154
|
+
{
|
|
155
|
+
return sourceLoc;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/// Needs to be implemented by a SVF front end
|
|
159
|
+
std::string toString() const;
|
|
160
|
+
|
|
161
|
+
/// Overloading operator << for dumping ICFG node ID
|
|
162
|
+
//@{
|
|
163
|
+
friend OutStream& operator<<(OutStream &os, const SVFValue &value)
|
|
164
|
+
{
|
|
165
|
+
return os << value.toString();
|
|
166
|
+
}
|
|
167
|
+
//@}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
class ArgValVar;
|
|
171
|
+
|
|
172
|
+
class SVFFunction : public SVFValue
|
|
173
|
+
{
|
|
174
|
+
friend class LLVMModuleSet;
|
|
175
|
+
friend class SVFIRWriter;
|
|
176
|
+
friend class SVFIRReader;
|
|
177
|
+
friend class SVFIRBuilder;
|
|
178
|
+
|
|
179
|
+
public:
|
|
180
|
+
typename BasicBlockGraph::IDToNodeMapTy::iterator iterator;
|
|
181
|
+
typedef BasicBlockGraph::IDToNodeMapTy::const_iterator const_iterator;
|
|
182
|
+
typedef SVFLoopAndDomInfo::BBSet BBSet;
|
|
183
|
+
typedef SVFLoopAndDomInfo::BBList BBList;
|
|
184
|
+
typedef SVFLoopAndDomInfo::LoopBBs LoopBBs;
|
|
185
|
+
|
|
186
|
+
private:
|
|
187
|
+
bool isDecl; /// return true if this function does not have a body
|
|
188
|
+
bool intrinsic; /// return true if this function is an intrinsic function (e.g., llvm.dbg), which does not reside in the application code
|
|
189
|
+
bool addrTaken; /// return true if this function is address-taken (for indirect call purposes)
|
|
190
|
+
bool isUncalled; /// return true if this function is never called
|
|
191
|
+
bool isNotRet; /// return true if this function never returns
|
|
192
|
+
bool varArg; /// return true if this function supports variable arguments
|
|
193
|
+
const SVFFunctionType* funcType; /// FunctionType, which is different from the type (PointerType) of this SVFFunction
|
|
194
|
+
SVFLoopAndDomInfo* loopAndDom; /// the loop and dominate information
|
|
195
|
+
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
|
|
196
|
+
std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
|
|
197
|
+
SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
|
|
198
|
+
BasicBlockGraph* bbGraph; /// the basic block graph of this function
|
|
199
|
+
|
|
200
|
+
protected:
|
|
201
|
+
|
|
202
|
+
inline void addArgument(const ArgValVar* arg)
|
|
203
|
+
{
|
|
204
|
+
allArgs.push_back(arg);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
inline void setIsUncalledFunction(bool uncalledFunction)
|
|
208
|
+
{
|
|
209
|
+
isUncalled = uncalledFunction;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
inline void setIsNotRet(bool notRet)
|
|
213
|
+
{
|
|
214
|
+
isNotRet = notRet;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
inline void setDefFunForMultipleModule(const SVFFunction* deffun)
|
|
218
|
+
{
|
|
219
|
+
realDefFun = deffun;
|
|
220
|
+
}
|
|
221
|
+
/// @}
|
|
222
|
+
|
|
223
|
+
public:
|
|
224
|
+
SVFFunction(const SVFType* ty,const SVFFunctionType* ft, bool declare, bool intrinsic, bool addrTaken, bool varg, SVFLoopAndDomInfo* ld);
|
|
225
|
+
SVFFunction(void) = delete;
|
|
226
|
+
virtual ~SVFFunction();
|
|
227
|
+
|
|
228
|
+
static inline bool classof(const SVFValue *node)
|
|
229
|
+
{
|
|
230
|
+
return node->getKind() == SVFFunc;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
inline SVFLoopAndDomInfo* getLoopAndDomInfo()
|
|
234
|
+
{
|
|
235
|
+
return loopAndDom;
|
|
236
|
+
}
|
|
237
|
+
inline bool isDeclaration() const
|
|
238
|
+
{
|
|
239
|
+
return isDecl;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
void setBasicBlockGraph(BasicBlockGraph* graph)
|
|
243
|
+
{
|
|
244
|
+
this->bbGraph = graph;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
BasicBlockGraph* getBasicBlockGraph()
|
|
248
|
+
{
|
|
249
|
+
return bbGraph;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const BasicBlockGraph* getBasicBlockGraph() const
|
|
253
|
+
{
|
|
254
|
+
return bbGraph;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
inline bool isIntrinsic() const
|
|
258
|
+
{
|
|
259
|
+
return intrinsic;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
inline bool hasAddressTaken() const
|
|
263
|
+
{
|
|
264
|
+
return addrTaken;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/// Returns the FunctionType
|
|
268
|
+
inline const SVFFunctionType* getFunctionType() const
|
|
269
|
+
{
|
|
270
|
+
return funcType;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/// Returns the FunctionType
|
|
274
|
+
inline const SVFType* getReturnType() const
|
|
275
|
+
{
|
|
276
|
+
return funcType->getReturnType();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
inline const SVFFunction* getDefFunForMultipleModule() const
|
|
280
|
+
{
|
|
281
|
+
if(realDefFun==nullptr)
|
|
282
|
+
return this;
|
|
283
|
+
return realDefFun;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
u32_t arg_size() const;
|
|
287
|
+
const ArgValVar* getArg(u32_t idx) const;
|
|
288
|
+
bool isVarArg() const;
|
|
289
|
+
|
|
290
|
+
inline bool hasBasicBlock() const
|
|
291
|
+
{
|
|
292
|
+
return bbGraph && bbGraph->begin() != bbGraph->end();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
inline const SVFBasicBlock* getEntryBlock() const
|
|
296
|
+
{
|
|
297
|
+
assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
|
|
298
|
+
assert(bbGraph->begin()->second->getInEdges().size() == 0 && "the first basic block is not entry block");
|
|
299
|
+
return bbGraph->begin()->second;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/// Carefully! when you call getExitBB, you need ensure the function has return instruction
|
|
303
|
+
/// more refer to: https://github.com/SVF-tools/SVF/pull/1262
|
|
304
|
+
const SVFBasicBlock* getExitBB() const;
|
|
305
|
+
|
|
306
|
+
void setExitBlock(SVFBasicBlock *bb);
|
|
307
|
+
|
|
308
|
+
inline const SVFBasicBlock* front() const
|
|
309
|
+
{
|
|
310
|
+
return getEntryBlock();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
inline const SVFBasicBlock* back() const
|
|
314
|
+
{
|
|
315
|
+
assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
|
|
316
|
+
/// Carefully! 'back' is just the last basic block of function,
|
|
317
|
+
/// but not necessarily a exit basic block
|
|
318
|
+
/// more refer to: https://github.com/SVF-tools/SVF/pull/1262
|
|
319
|
+
return std::prev(bbGraph->end())->second;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
inline const_iterator begin() const
|
|
323
|
+
{
|
|
324
|
+
return bbGraph->begin();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
inline const_iterator end() const
|
|
328
|
+
{
|
|
329
|
+
return bbGraph->end();
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
inline const std::vector<const SVFBasicBlock*>& getReachableBBs() const
|
|
334
|
+
{
|
|
335
|
+
return loopAndDom->getReachableBBs();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
inline bool isUncalledFunction() const
|
|
339
|
+
{
|
|
340
|
+
return isUncalled;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
inline bool hasReturn() const
|
|
344
|
+
{
|
|
345
|
+
return !isNotRet;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
inline void getExitBlocksOfLoop(const SVFBasicBlock* bb, BBList& exitbbs) const
|
|
349
|
+
{
|
|
350
|
+
return loopAndDom->getExitBlocksOfLoop(bb,exitbbs);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
inline bool hasLoopInfo(const SVFBasicBlock* bb) const
|
|
354
|
+
{
|
|
355
|
+
return loopAndDom->hasLoopInfo(bb);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const
|
|
359
|
+
{
|
|
360
|
+
return loopAndDom->getLoopInfo(bb);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
inline const SVFBasicBlock* getLoopHeader(const BBList& lp) const
|
|
364
|
+
{
|
|
365
|
+
return loopAndDom->getLoopHeader(lp);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
inline bool loopContainsBB(const BBList& lp, const SVFBasicBlock* bb) const
|
|
369
|
+
{
|
|
370
|
+
return loopAndDom->loopContainsBB(lp,bb);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
inline const Map<const SVFBasicBlock*,BBSet>& getDomTreeMap() const
|
|
374
|
+
{
|
|
375
|
+
return loopAndDom->getDomTreeMap();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
inline const Map<const SVFBasicBlock*,BBSet>& getDomFrontierMap() const
|
|
379
|
+
{
|
|
380
|
+
return loopAndDom->getDomFrontierMap();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
inline bool isLoopHeader(const SVFBasicBlock* bb) const
|
|
384
|
+
{
|
|
385
|
+
return loopAndDom->isLoopHeader(bb);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
inline bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
|
|
389
|
+
{
|
|
390
|
+
return loopAndDom->dominate(bbKey,bbValue);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
inline bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
|
|
394
|
+
{
|
|
395
|
+
return loopAndDom->postDominate(bbKey,bbValue);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
class ICFGNode;
|
|
400
|
+
class FunObjVar;
|
|
401
|
+
|
|
402
|
+
class SVFInstruction : public SVFValue
|
|
403
|
+
{
|
|
404
|
+
friend class SVFIRWriter;
|
|
405
|
+
friend class SVFIRReader;
|
|
406
|
+
|
|
407
|
+
private:
|
|
408
|
+
const SVFBasicBlock* bb; /// The BasicBlock where this Instruction resides
|
|
409
|
+
bool terminator; /// return true if this is a terminator instruction
|
|
410
|
+
bool ret; /// return true if this is an return instruction of a function
|
|
411
|
+
|
|
412
|
+
public:
|
|
413
|
+
/// Constructor without name, set name with setName()
|
|
414
|
+
SVFInstruction(const SVFType* ty, const SVFBasicBlock* b, bool tm,
|
|
415
|
+
bool isRet, SVFValKind k = SVFInst);
|
|
416
|
+
SVFInstruction(void) = delete;
|
|
417
|
+
|
|
418
|
+
static inline bool classof(const SVFValue *node)
|
|
419
|
+
{
|
|
420
|
+
return node->getKind() == SVFInst ||
|
|
421
|
+
node->getKind() == SVFCall ||
|
|
422
|
+
node->getKind() == SVFVCall;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
inline const SVFBasicBlock* getParent() const
|
|
426
|
+
{
|
|
427
|
+
return bb;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
inline const FunObjVar* getFunction() const
|
|
431
|
+
{
|
|
432
|
+
return bb->getParent();
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
inline bool isRetInst() const
|
|
436
|
+
{
|
|
437
|
+
return ret;
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
class SVFCallInst : public SVFInstruction
|
|
442
|
+
{
|
|
443
|
+
friend class SVFIRWriter;
|
|
444
|
+
friend class SVFIRReader;
|
|
445
|
+
friend class LLVMModuleSet;
|
|
446
|
+
friend class SVFIRBuilder;
|
|
447
|
+
|
|
448
|
+
private:
|
|
449
|
+
std::vector<const SVFValue*> args;
|
|
450
|
+
bool varArg;
|
|
451
|
+
const SVFValue* calledVal;
|
|
452
|
+
|
|
453
|
+
protected:
|
|
454
|
+
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
455
|
+
inline void addArgument(const SVFValue* a)
|
|
456
|
+
{
|
|
457
|
+
args.push_back(a);
|
|
458
|
+
}
|
|
459
|
+
inline void setCalledOperand(const SVFValue* v)
|
|
460
|
+
{
|
|
461
|
+
calledVal = v;
|
|
462
|
+
}
|
|
463
|
+
/// @}
|
|
464
|
+
|
|
465
|
+
public:
|
|
466
|
+
SVFCallInst(const SVFType* ty, const SVFBasicBlock* b, bool va, bool tm, SVFValKind k = SVFCall) :
|
|
467
|
+
SVFInstruction(ty, b, tm, false, k), varArg(va), calledVal(nullptr)
|
|
468
|
+
{
|
|
469
|
+
}
|
|
470
|
+
SVFCallInst(void) = delete;
|
|
471
|
+
|
|
472
|
+
static inline bool classof(const SVFValue *node)
|
|
473
|
+
{
|
|
474
|
+
return node->getKind() == SVFCall || node->getKind() == SVFVCall;
|
|
475
|
+
}
|
|
476
|
+
static inline bool classof(const SVFInstruction *node)
|
|
477
|
+
{
|
|
478
|
+
return node->getKind() == SVFCall || node->getKind() == SVFVCall;
|
|
479
|
+
}
|
|
480
|
+
inline u32_t arg_size() const
|
|
481
|
+
{
|
|
482
|
+
return args.size();
|
|
483
|
+
}
|
|
484
|
+
inline bool arg_empty() const
|
|
485
|
+
{
|
|
486
|
+
return args.empty();
|
|
487
|
+
}
|
|
488
|
+
inline const SVFValue* getArgOperand(u32_t i) const
|
|
489
|
+
{
|
|
490
|
+
assert(i < arg_size() && "out of bound access of the argument");
|
|
491
|
+
return args[i];
|
|
492
|
+
}
|
|
493
|
+
inline u32_t getNumArgOperands() const
|
|
494
|
+
{
|
|
495
|
+
return arg_size();
|
|
496
|
+
}
|
|
497
|
+
inline const SVFValue* getCalledOperand() const
|
|
498
|
+
{
|
|
499
|
+
return calledVal;
|
|
500
|
+
}
|
|
501
|
+
inline bool isVarArg() const
|
|
502
|
+
{
|
|
503
|
+
return varArg;
|
|
504
|
+
}
|
|
505
|
+
inline const SVFFunction* getCalledFunction() const
|
|
506
|
+
{
|
|
507
|
+
return SVFUtil::dyn_cast<SVFFunction>(calledVal);
|
|
508
|
+
}
|
|
509
|
+
inline const FunObjVar* getCaller() const
|
|
510
|
+
{
|
|
511
|
+
return getFunction();
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
class SVFConstant : public SVFValue
|
|
516
|
+
{
|
|
517
|
+
friend class SVFIRWriter;
|
|
518
|
+
friend class SVFIRReader;
|
|
519
|
+
public:
|
|
520
|
+
SVFConstant(const SVFType* ty, SVFValKind k = SVFConst): SVFValue(ty, k)
|
|
521
|
+
{
|
|
522
|
+
}
|
|
523
|
+
SVFConstant() = delete;
|
|
524
|
+
|
|
525
|
+
static inline bool classof(const SVFValue *node)
|
|
526
|
+
{
|
|
527
|
+
return node->getKind() == SVFConst ||
|
|
528
|
+
node->getKind() == SVFGlob ||
|
|
529
|
+
node->getKind() == SVFConstData ||
|
|
530
|
+
node->getKind() == SVFConstInt ||
|
|
531
|
+
node->getKind() == SVFConstFP ||
|
|
532
|
+
node->getKind() == SVFNullPtr ||
|
|
533
|
+
node->getKind() == SVFBlackHole;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
class SVFGlobalValue : public SVFConstant
|
|
539
|
+
{
|
|
540
|
+
friend class SVFIRWriter;
|
|
541
|
+
friend class SVFIRReader;
|
|
542
|
+
friend class LLVMModuleSet;
|
|
543
|
+
|
|
544
|
+
private:
|
|
545
|
+
const SVFValue* realDefGlobal; /// the definition of a function across multiple modules
|
|
546
|
+
|
|
547
|
+
protected:
|
|
548
|
+
inline void setDefGlobalForMultipleModule(const SVFValue* defg)
|
|
549
|
+
{
|
|
550
|
+
realDefGlobal = defg;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
public:
|
|
554
|
+
SVFGlobalValue(const SVFType* ty): SVFConstant(ty, SVFValue::SVFGlob), realDefGlobal(nullptr)
|
|
555
|
+
{
|
|
556
|
+
}
|
|
557
|
+
SVFGlobalValue(std::string&& name, const SVFType* ty) : SVFGlobalValue(ty)
|
|
558
|
+
{
|
|
559
|
+
setName(std::move(name));
|
|
560
|
+
}
|
|
561
|
+
SVFGlobalValue() = delete;
|
|
562
|
+
|
|
563
|
+
inline const SVFValue* getDefGlobalForMultipleModule() const
|
|
564
|
+
{
|
|
565
|
+
if(realDefGlobal==nullptr)
|
|
566
|
+
return this;
|
|
567
|
+
return realDefGlobal;
|
|
568
|
+
}
|
|
569
|
+
static inline bool classof(const SVFValue *node)
|
|
570
|
+
{
|
|
571
|
+
return node->getKind() == SVFGlob;
|
|
572
|
+
}
|
|
573
|
+
static inline bool classof(const SVFConstant *node)
|
|
574
|
+
{
|
|
575
|
+
return node->getKind() == SVFGlob;
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
class SVFArgument : public SVFValue
|
|
580
|
+
{
|
|
581
|
+
friend class SVFIRWriter;
|
|
582
|
+
friend class SVFIRReader;
|
|
583
|
+
private:
|
|
584
|
+
const SVFFunction* fun;
|
|
585
|
+
u32_t argNo;
|
|
586
|
+
bool uncalled;
|
|
587
|
+
public:
|
|
588
|
+
SVFArgument(const SVFType* ty, const SVFFunction* fun, u32_t argNo,
|
|
589
|
+
bool uncalled)
|
|
590
|
+
: SVFValue(ty, SVFValue::SVFArg), fun(fun), argNo(argNo),
|
|
591
|
+
uncalled(uncalled)
|
|
592
|
+
{
|
|
593
|
+
}
|
|
594
|
+
SVFArgument() = delete;
|
|
595
|
+
|
|
596
|
+
inline const SVFFunction* getParent() const
|
|
597
|
+
{
|
|
598
|
+
return fun;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/// Return the index of this formal argument in its containing function.
|
|
602
|
+
/// For example in "void foo(int a, float b)" a is 0 and b is 1.
|
|
603
|
+
inline u32_t getArgNo() const
|
|
604
|
+
{
|
|
605
|
+
return argNo;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
inline bool isArgOfUncalledFunction() const
|
|
609
|
+
{
|
|
610
|
+
return uncalled;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
static inline bool classof(const SVFValue *node)
|
|
614
|
+
{
|
|
615
|
+
return node->getKind() == SVFArg;
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
class SVFConstantData : public SVFConstant
|
|
620
|
+
{
|
|
621
|
+
friend class SVFIRWriter;
|
|
622
|
+
friend class SVFIRReader;
|
|
623
|
+
public:
|
|
624
|
+
SVFConstantData(const SVFType* ty, SVFValKind k = SVFConstData)
|
|
625
|
+
: SVFConstant(ty, k)
|
|
626
|
+
{
|
|
627
|
+
}
|
|
628
|
+
SVFConstantData() = delete;
|
|
629
|
+
|
|
630
|
+
static inline bool classof(const SVFValue *node)
|
|
631
|
+
{
|
|
632
|
+
return node->getKind() == SVFConstData ||
|
|
633
|
+
node->getKind() == SVFConstInt ||
|
|
634
|
+
node->getKind() == SVFConstFP ||
|
|
635
|
+
node->getKind() == SVFNullPtr ||
|
|
636
|
+
node->getKind() == SVFBlackHole;
|
|
637
|
+
}
|
|
638
|
+
static inline bool classof(const SVFConstantData *node)
|
|
639
|
+
{
|
|
640
|
+
return node->getKind() == SVFConstData ||
|
|
641
|
+
node->getKind() == SVFConstInt ||
|
|
642
|
+
node->getKind() == SVFConstFP ||
|
|
643
|
+
node->getKind() == SVFNullPtr ||
|
|
644
|
+
node->getKind() == SVFBlackHole;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
class SVFConstantInt : public SVFConstantData
|
|
649
|
+
{
|
|
650
|
+
friend class SVFIRWriter;
|
|
651
|
+
friend class SVFIRReader;
|
|
652
|
+
private:
|
|
653
|
+
u64_t zval;
|
|
654
|
+
s64_t sval;
|
|
655
|
+
public:
|
|
656
|
+
SVFConstantInt(const SVFType* ty, u64_t z, s64_t s)
|
|
657
|
+
: SVFConstantData(ty, SVFValue::SVFConstInt), zval(z), sval(s)
|
|
658
|
+
{
|
|
659
|
+
}
|
|
660
|
+
SVFConstantInt() = delete;
|
|
661
|
+
|
|
662
|
+
static inline bool classof(const SVFValue *node)
|
|
663
|
+
{
|
|
664
|
+
return node->getKind() == SVFConstInt;
|
|
665
|
+
}
|
|
666
|
+
static inline bool classof(const SVFConstantData *node)
|
|
667
|
+
{
|
|
668
|
+
return node->getKind() == SVFConstInt;
|
|
669
|
+
}
|
|
670
|
+
// Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate for the type of this constant.
|
|
671
|
+
inline u64_t getZExtValue () const
|
|
672
|
+
{
|
|
673
|
+
return zval;
|
|
674
|
+
}
|
|
675
|
+
// Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the type of this constant
|
|
676
|
+
inline s64_t getSExtValue () const
|
|
677
|
+
{
|
|
678
|
+
return sval;
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
class SVFConstantFP : public SVFConstantData
|
|
683
|
+
{
|
|
684
|
+
friend class SVFIRWriter;
|
|
685
|
+
friend class SVFIRReader;
|
|
686
|
+
private:
|
|
687
|
+
float dval;
|
|
688
|
+
public:
|
|
689
|
+
SVFConstantFP(const SVFType* ty, double d)
|
|
690
|
+
: SVFConstantData(ty, SVFValue::SVFConstFP), dval(d)
|
|
691
|
+
{
|
|
692
|
+
}
|
|
693
|
+
SVFConstantFP() = delete;
|
|
694
|
+
|
|
695
|
+
inline double getFPValue () const
|
|
696
|
+
{
|
|
697
|
+
return dval;
|
|
698
|
+
}
|
|
699
|
+
static inline bool classof(const SVFValue *node)
|
|
700
|
+
{
|
|
701
|
+
return node->getKind() == SVFConstFP;
|
|
702
|
+
}
|
|
703
|
+
static inline bool classof(const SVFConstantData *node)
|
|
704
|
+
{
|
|
705
|
+
return node->getKind() == SVFConstFP;
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
class SVFConstantNullPtr : public SVFConstantData
|
|
710
|
+
{
|
|
711
|
+
friend class SVFIRWriter;
|
|
712
|
+
friend class SVFIRReader;
|
|
713
|
+
|
|
714
|
+
public:
|
|
715
|
+
SVFConstantNullPtr(const SVFType* ty)
|
|
716
|
+
: SVFConstantData(ty, SVFValue::SVFNullPtr)
|
|
717
|
+
{
|
|
718
|
+
}
|
|
719
|
+
SVFConstantNullPtr() = delete;
|
|
720
|
+
|
|
721
|
+
static inline bool classof(const SVFValue *node)
|
|
722
|
+
{
|
|
723
|
+
return node->getKind() == SVFNullPtr;
|
|
724
|
+
}
|
|
725
|
+
static inline bool classof(const SVFConstantData *node)
|
|
726
|
+
{
|
|
727
|
+
return node->getKind() == SVFNullPtr;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
class SVFBlackHoleValue : public SVFConstantData
|
|
732
|
+
{
|
|
733
|
+
friend class SVFIRWriter;
|
|
734
|
+
friend class SVFIRReader;
|
|
735
|
+
|
|
736
|
+
public:
|
|
737
|
+
SVFBlackHoleValue(const SVFType* ty)
|
|
738
|
+
: SVFConstantData(ty, SVFValue::SVFBlackHole)
|
|
739
|
+
{
|
|
740
|
+
}
|
|
741
|
+
SVFBlackHoleValue() = delete;
|
|
742
|
+
|
|
743
|
+
static inline bool classof(const SVFValue *node)
|
|
744
|
+
{
|
|
745
|
+
return node->getKind() == SVFBlackHole;
|
|
746
|
+
}
|
|
747
|
+
static inline bool classof(const SVFConstantData *node)
|
|
748
|
+
{
|
|
749
|
+
return node->getKind() == SVFBlackHole;
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
class SVFOtherValue : public SVFValue
|
|
754
|
+
{
|
|
755
|
+
friend class SVFIRWriter;
|
|
756
|
+
friend class SVFIRReader;
|
|
757
|
+
public:
|
|
758
|
+
SVFOtherValue(const SVFType* ty, SVFValKind k = SVFValue::SVFOther)
|
|
759
|
+
: SVFValue(ty, k)
|
|
760
|
+
{
|
|
761
|
+
}
|
|
762
|
+
SVFOtherValue() = delete;
|
|
763
|
+
|
|
764
|
+
static inline bool classof(const SVFValue *node)
|
|
765
|
+
{
|
|
766
|
+
return node->getKind() == SVFOther || node->getKind() == SVFMetaAsValue;
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
/*
|
|
771
|
+
* This class is only for LLVM's MetadataAsValue
|
|
772
|
+
*/
|
|
773
|
+
class SVFMetadataAsValue : public SVFOtherValue
|
|
774
|
+
{
|
|
775
|
+
friend class SVFIRWriter;
|
|
776
|
+
friend class SVFIRReader;
|
|
777
|
+
public:
|
|
778
|
+
SVFMetadataAsValue(const SVFType* ty)
|
|
779
|
+
: SVFOtherValue(ty, SVFValue::SVFMetaAsValue)
|
|
780
|
+
{
|
|
781
|
+
}
|
|
782
|
+
SVFMetadataAsValue() = delete;
|
|
783
|
+
|
|
784
|
+
static inline bool classof(const SVFValue *node)
|
|
785
|
+
{
|
|
786
|
+
return node->getKind() == SVFMetaAsValue;
|
|
787
|
+
}
|
|
788
|
+
static inline bool classof(const SVFOtherValue *node)
|
|
789
|
+
{
|
|
790
|
+
return node->getKind() == SVFMetaAsValue;
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
/// [FOR DEBUG ONLY, DON'T USE IT UNSIDE `svf`!]
|
|
796
|
+
/// Converts an SVFValue to corresponding LLVM::Value, then get the string
|
|
797
|
+
/// representation of it. Use it only when you are debugging. Don't use
|
|
798
|
+
/// it in any SVF algorithm because it relies on information stored in LLVM bc.
|
|
799
|
+
std::string dumpLLVMValue(const SVFValue* svfValue);
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
} // End namespace SVF
|
|
804
|
+
|
|
805
|
+
#endif /* INCLUDE_SVFLLVM_SVFVALUE_H_ */
|