svf-lib 1.0.1301 → 1.0.1302
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-linux/include/SVF-FE/BasicTypes.h +0 -219
- package/SVF-linux/include/SVF-FE/BreakConstantExpr.h +0 -94
- package/SVF-linux/include/SVF-FE/CHG.h +0 -334
- package/SVF-linux/include/SVF-FE/CHGBuilder.h +0 -73
- package/SVF-linux/include/SVF-FE/CPPUtil.h +0 -130
- package/SVF-linux/include/SVF-FE/CallGraphBuilder.h +0 -74
- package/SVF-linux/include/SVF-FE/CommonCHG.h +0 -49
- package/SVF-linux/include/SVF-FE/DCHG.h +0 -470
- package/SVF-linux/include/SVF-FE/DataFlowUtil.h +0 -190
- package/SVF-linux/include/SVF-FE/GEPTypeBridgeIterator.h +0 -183
- package/SVF-linux/include/SVF-FE/Graph2Json.h +0 -30
- package/SVF-linux/include/SVF-FE/ICFGBuilder.h +0 -106
- package/SVF-linux/include/SVF-FE/IRAnnotator.h +0 -323
- package/SVF-linux/include/SVF-FE/LLVMLoopAnalysis.h +0 -59
- package/SVF-linux/include/SVF-FE/LLVMModule.h +0 -319
- package/SVF-linux/include/SVF-FE/LLVMUtil.h +0 -303
- package/SVF-linux/include/SVF-FE/LocMemModel.h +0 -35
- package/SVF-linux/include/SVF-FE/MemModelBuilder.h +0 -102
- package/SVF-linux/include/SVF-FE/PAGBuilder.h +0 -390
- package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +0 -412
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +0 -99
- package/SVF-linux/include/SVF-FE/SymbolTableInfo.h +0 -439
- package/SVF-osx/include/SVF-FE/BasicTypes.h +0 -219
- package/SVF-osx/include/SVF-FE/BreakConstantExpr.h +0 -94
- package/SVF-osx/include/SVF-FE/CHG.h +0 -334
- package/SVF-osx/include/SVF-FE/CHGBuilder.h +0 -73
- package/SVF-osx/include/SVF-FE/CPPUtil.h +0 -130
- package/SVF-osx/include/SVF-FE/CallGraphBuilder.h +0 -74
- package/SVF-osx/include/SVF-FE/CommonCHG.h +0 -49
- package/SVF-osx/include/SVF-FE/DCHG.h +0 -470
- package/SVF-osx/include/SVF-FE/DataFlowUtil.h +0 -190
- package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +0 -183
- package/SVF-osx/include/SVF-FE/Graph2Json.h +0 -30
- package/SVF-osx/include/SVF-FE/ICFGBuilder.h +0 -106
- package/SVF-osx/include/SVF-FE/IRAnnotator.h +0 -323
- package/SVF-osx/include/SVF-FE/LLVMLoopAnalysis.h +0 -59
- package/SVF-osx/include/SVF-FE/LLVMModule.h +0 -319
- package/SVF-osx/include/SVF-FE/LLVMUtil.h +0 -303
- package/SVF-osx/include/SVF-FE/LocMemModel.h +0 -35
- package/SVF-osx/include/SVF-FE/MemModelBuilder.h +0 -102
- package/SVF-osx/include/SVF-FE/PAGBuilder.h +0 -390
- package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +0 -412
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +0 -99
- package/SVF-osx/include/SVF-FE/SymbolTableInfo.h +0 -439
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
//===- LLVMModule.h -- LLVM Module class-----------------------------------------//
|
|
2
|
-
//
|
|
3
|
-
// SVF: Static Value-Flow Analysis
|
|
4
|
-
//
|
|
5
|
-
// Copyright (C) <2013-> <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 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 General Public License for more details.
|
|
17
|
-
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
//
|
|
21
|
-
//===----------------------------------------------------------------------===//
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
* LLVMModule.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: 23 Mar.2020
|
|
27
|
-
* Author: Yulei Sui
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef INCLUDE_SVF_FE_LLVMMODULE_H_
|
|
31
|
-
#define INCLUDE_SVF_FE_LLVMMODULE_H_
|
|
32
|
-
|
|
33
|
-
#include "SVF-FE/BasicTypes.h"
|
|
34
|
-
#include "SVF-FE/CPPUtil.h"
|
|
35
|
-
#include "Util/BasicTypes.h"
|
|
36
|
-
#include "Util/SVFModule.h"
|
|
37
|
-
|
|
38
|
-
namespace SVF
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
class LLVMModuleSet
|
|
42
|
-
{
|
|
43
|
-
public:
|
|
44
|
-
|
|
45
|
-
typedef std::vector<const Function*> FunctionSetType;
|
|
46
|
-
typedef Map<const Function*, const Function*> FunDeclToDefMapTy;
|
|
47
|
-
typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
|
|
48
|
-
typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
|
|
49
|
-
|
|
50
|
-
typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
|
|
51
|
-
typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
|
|
52
|
-
typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
|
|
53
|
-
typedef Map<const GlobalValue*, SVFGlobalValue*> LLVMGlobal2SVFGlobalMap;
|
|
54
|
-
typedef Map<const Argument*, SVFArgument*> LLVMArgument2SVFArgumentMap;
|
|
55
|
-
typedef Map<const ConstantData*, SVFConstantData*> LLVMConstData2SVFConstDataMap;
|
|
56
|
-
typedef Map<const Value*, SVFOtherValue*> LLVMValue2SVFOtherValueMap;
|
|
57
|
-
|
|
58
|
-
private:
|
|
59
|
-
static LLVMModuleSet* llvmModuleSet;
|
|
60
|
-
SVFModule* svfModule;
|
|
61
|
-
std::unique_ptr<LLVMContext> cxts;
|
|
62
|
-
std::vector<std::unique_ptr<Module>> owned_modules;
|
|
63
|
-
std::vector<std::reference_wrapper<Module>> modules;
|
|
64
|
-
|
|
65
|
-
/// Function declaration to function definition map
|
|
66
|
-
FunDeclToDefMapTy FunDeclToDefMap;
|
|
67
|
-
/// Function definition to function declaration map
|
|
68
|
-
FunDefToDeclsMapTy FunDefToDeclsMap;
|
|
69
|
-
/// Global definition to a rep definition map
|
|
70
|
-
GlobalDefToRepMapTy GlobalDefToRepMap;
|
|
71
|
-
|
|
72
|
-
LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
|
|
73
|
-
LLVMBB2SVFBBMap LLVMBB2SVFBB;
|
|
74
|
-
LLVMInst2SVFInstMap LLVMInst2SVFInst;
|
|
75
|
-
LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
|
|
76
|
-
LLVMGlobal2SVFGlobalMap LLVMGlobal2SVFGlobal;
|
|
77
|
-
LLVMConstData2SVFConstDataMap LLVMConstData2SVFConstData;
|
|
78
|
-
LLVMValue2SVFOtherValueMap LLVMValue2SVFOtherValue;
|
|
79
|
-
|
|
80
|
-
/// Constructor
|
|
81
|
-
LLVMModuleSet(): svfModule(nullptr), cxts(nullptr), preProcessed(false) {}
|
|
82
|
-
|
|
83
|
-
void build();
|
|
84
|
-
|
|
85
|
-
public:
|
|
86
|
-
static inline LLVMModuleSet* getLLVMModuleSet()
|
|
87
|
-
{
|
|
88
|
-
if (llvmModuleSet == nullptr)
|
|
89
|
-
llvmModuleSet = new LLVMModuleSet();
|
|
90
|
-
return llvmModuleSet;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
static void releaseLLVMModuleSet()
|
|
94
|
-
{
|
|
95
|
-
if (llvmModuleSet)
|
|
96
|
-
delete llvmModuleSet;
|
|
97
|
-
llvmModuleSet = nullptr;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
SVFModule* buildSVFModule(Module& mod);
|
|
101
|
-
SVFModule* buildSVFModule(const std::vector<std::string>& moduleNameVec);
|
|
102
|
-
|
|
103
|
-
inline SVFModule* getSVFModule()
|
|
104
|
-
{
|
|
105
|
-
assert(svfModule && "svfModule has not been built yet!");
|
|
106
|
-
return svfModule;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
void preProcessBCs(std::vector<std::string>& moduleNameVec);
|
|
110
|
-
|
|
111
|
-
u32_t getModuleNum() const
|
|
112
|
-
{
|
|
113
|
-
return modules.size();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const std::vector<std::reference_wrapper<Module>>& getLLVMModules() const
|
|
117
|
-
{
|
|
118
|
-
return modules;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
Module *getModule(u32_t idx) const
|
|
122
|
-
{
|
|
123
|
-
return &getModuleRef(idx);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
Module &getModuleRef(u32_t idx) const
|
|
127
|
-
{
|
|
128
|
-
assert(idx < getModuleNum() && "Out of range.");
|
|
129
|
-
return modules[idx];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Dump modules to files
|
|
133
|
-
void dumpModulesToFile(const std::string suffix);
|
|
134
|
-
|
|
135
|
-
inline void addFunctionMap(const Function* func, SVFFunction* svfFunc)
|
|
136
|
-
{
|
|
137
|
-
LLVMFunc2SVFFunc[func] = svfFunc;
|
|
138
|
-
setValueAttr(func,svfFunc);
|
|
139
|
-
}
|
|
140
|
-
inline void addBasicBlockMap(const BasicBlock* bb, SVFBasicBlock* svfBB)
|
|
141
|
-
{
|
|
142
|
-
LLVMBB2SVFBB[bb] = svfBB;
|
|
143
|
-
setValueAttr(bb,svfBB);
|
|
144
|
-
}
|
|
145
|
-
inline void addInstructionMap(const Instruction* inst, SVFInstruction* svfInst)
|
|
146
|
-
{
|
|
147
|
-
LLVMInst2SVFInst[inst] = svfInst;
|
|
148
|
-
setValueAttr(inst,svfInst);
|
|
149
|
-
}
|
|
150
|
-
inline void addArgumentMap(const Argument* arg, SVFArgument* svfArg)
|
|
151
|
-
{
|
|
152
|
-
LLVMArgument2SVFArgument[arg] = svfArg;
|
|
153
|
-
setValueAttr(arg,svfArg);
|
|
154
|
-
}
|
|
155
|
-
inline void addGlobalValueMap(const GlobalValue* glob, SVFGlobalValue* svfglob)
|
|
156
|
-
{
|
|
157
|
-
LLVMGlobal2SVFGlobal[glob] = svfglob;
|
|
158
|
-
setValueAttr(glob,svfglob);
|
|
159
|
-
}
|
|
160
|
-
inline void addConstantDataMap(const ConstantData* cd, SVFConstantData* svfcd)
|
|
161
|
-
{
|
|
162
|
-
LLVMConstData2SVFConstData[cd] = svfcd;
|
|
163
|
-
setValueAttr(cd,svfcd);
|
|
164
|
-
}
|
|
165
|
-
inline void addOtherValueMap(const Value* ov, SVFOtherValue* svfov)
|
|
166
|
-
{
|
|
167
|
-
LLVMValue2SVFOtherValue[ov] = svfov;
|
|
168
|
-
setValueAttr(ov,svfov);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
SVFValue* getSVFValue(const Value* value);
|
|
172
|
-
|
|
173
|
-
inline SVFFunction* getSVFFunction(const Function* fun) const
|
|
174
|
-
{
|
|
175
|
-
LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
|
|
176
|
-
assert(it!=LLVMFunc2SVFFunc.end() && "SVF Function not found!");
|
|
177
|
-
return it->second;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
inline SVFBasicBlock* getSVFBasicBlock(const BasicBlock* bb) const
|
|
181
|
-
{
|
|
182
|
-
LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
|
|
183
|
-
assert(it!=LLVMBB2SVFBB.end() && "SVF BasicBlock not found!");
|
|
184
|
-
return it->second;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
inline SVFInstruction* getSVFInstruction(const Instruction* inst) const
|
|
188
|
-
{
|
|
189
|
-
LLVMInst2SVFInstMap::const_iterator it = LLVMInst2SVFInst.find(inst);
|
|
190
|
-
assert(it!=LLVMInst2SVFInst.end() && "SVF Instruction not found!");
|
|
191
|
-
return it->second;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
inline SVFArgument* getSVFArgument(const Argument* arg) const
|
|
195
|
-
{
|
|
196
|
-
LLVMArgument2SVFArgumentMap::const_iterator it = LLVMArgument2SVFArgument.find(arg);
|
|
197
|
-
assert(it!=LLVMArgument2SVFArgument.end() && "SVF Argument not found!");
|
|
198
|
-
return it->second;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
inline SVFGlobalValue* getSVFGlobalValue(const GlobalValue* g) const
|
|
202
|
-
{
|
|
203
|
-
LLVMGlobal2SVFGlobalMap::const_iterator it = LLVMGlobal2SVFGlobal.find(g);
|
|
204
|
-
assert(it!=LLVMGlobal2SVFGlobal.end() && "SVF Global not found!");
|
|
205
|
-
return it->second;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
SVFConstantData* getSVFConstantData(const ConstantData* cd);
|
|
209
|
-
|
|
210
|
-
SVFOtherValue* getSVFOtherValue(const Value* ov);
|
|
211
|
-
|
|
212
|
-
/// Get the corresponding Function based on its name
|
|
213
|
-
inline const SVFFunction* getSVFFunction(std::string name)
|
|
214
|
-
{
|
|
215
|
-
Function* fun = nullptr;
|
|
216
|
-
|
|
217
|
-
for (u32_t i = 0; i < llvmModuleSet->getModuleNum(); ++i)
|
|
218
|
-
{
|
|
219
|
-
Module* mod = llvmModuleSet->getModule(i);
|
|
220
|
-
fun = mod->getFunction(name);
|
|
221
|
-
if (fun)
|
|
222
|
-
{
|
|
223
|
-
return llvmModuleSet->getSVFFunction(fun);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return nullptr;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
bool hasDefinition(const Function* fun) const
|
|
230
|
-
{
|
|
231
|
-
assert(fun->isDeclaration() && "not a function declaration?");
|
|
232
|
-
FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
|
|
233
|
-
return it != FunDeclToDefMap.end();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const Function* getDefinition(const Function* fun) const
|
|
237
|
-
{
|
|
238
|
-
assert(fun->isDeclaration() && "not a function declaration?");
|
|
239
|
-
FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
|
|
240
|
-
assert(it != FunDeclToDefMap.end() && "has no definition?");
|
|
241
|
-
return it->second;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
bool hasDeclaration(const Function* fun) const
|
|
245
|
-
{
|
|
246
|
-
if(fun->isDeclaration() && !hasDefinition(fun))
|
|
247
|
-
return false;
|
|
248
|
-
|
|
249
|
-
const Function* funDef = fun;
|
|
250
|
-
if(fun->isDeclaration() && hasDefinition(fun))
|
|
251
|
-
funDef = getDefinition(fun);
|
|
252
|
-
|
|
253
|
-
FunDefToDeclsMapTy::const_iterator it = FunDefToDeclsMap.find(funDef);
|
|
254
|
-
return it != FunDefToDeclsMap.end();
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const FunctionSetType& getDeclaration(const Function* fun) const
|
|
258
|
-
{
|
|
259
|
-
const Function* funDef = fun;
|
|
260
|
-
if(fun->isDeclaration() && hasDefinition(fun))
|
|
261
|
-
funDef = getDefinition(fun);
|
|
262
|
-
|
|
263
|
-
FunDefToDeclsMapTy::const_iterator it = FunDefToDeclsMap.find(funDef);
|
|
264
|
-
assert(it != FunDefToDeclsMap.end() && "does not have a function definition (body)?");
|
|
265
|
-
return it->second;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/// Global to rep
|
|
269
|
-
bool hasGlobalRep(const GlobalVariable* val) const
|
|
270
|
-
{
|
|
271
|
-
GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
|
|
272
|
-
return it != GlobalDefToRepMap.end();
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
GlobalVariable *getGlobalRep(const GlobalVariable* val) const
|
|
276
|
-
{
|
|
277
|
-
GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
|
|
278
|
-
assert(it != GlobalDefToRepMap.end() && "has no rep?");
|
|
279
|
-
return it->second;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
Module* getMainLLVMModule() const
|
|
284
|
-
{
|
|
285
|
-
return getModule(0);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
LLVMContext& getContext() const
|
|
289
|
-
{
|
|
290
|
-
assert(!empty() && "empty LLVM module!!");
|
|
291
|
-
return getMainLLVMModule()->getContext();
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
bool empty() const
|
|
295
|
-
{
|
|
296
|
-
return getModuleNum() == 0;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
private:
|
|
300
|
-
std::vector<const Function*> getLLVMGlobalFunctions(const GlobalVariable* global);
|
|
301
|
-
|
|
302
|
-
void loadModules(const std::vector<std::string>& moduleNameVec);
|
|
303
|
-
void addSVFMain();
|
|
304
|
-
|
|
305
|
-
void createSVFDataStructure();
|
|
306
|
-
void initSVFFunction();
|
|
307
|
-
void initSVFBasicBlock(const SVFFunction* func);
|
|
308
|
-
void initDomTree(const SVFFunction* func);
|
|
309
|
-
void setValueAttr(const Value* val, SVFValue* value);
|
|
310
|
-
void buildFunToFunMap();
|
|
311
|
-
void buildGlobalDefToRepMap();
|
|
312
|
-
/// Invoke llvm passes to modify module
|
|
313
|
-
void prePassSchedule();
|
|
314
|
-
bool preProcessed;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
} // End namespace SVF
|
|
318
|
-
|
|
319
|
-
#endif /* INCLUDE_SVF_FE_LLVMMODULE_H_ */
|
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
//===- LLVMUtil.h -- Analysis helper functions----------------------------//
|
|
2
|
-
//
|
|
3
|
-
// SVF: Static Value-Flow Analysis
|
|
4
|
-
//
|
|
5
|
-
// Copyright (C) <2013-> <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 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 General Public License for more details.
|
|
17
|
-
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
//
|
|
21
|
-
//===----------------------------------------------------------------------===//
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
* LLVMUtil.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: Apr 11, 2013
|
|
27
|
-
* Author: Yulei Sui
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef INCLUDE_SVF_FE_LLVMUTIL_H_
|
|
31
|
-
#define INCLUDE_SVF_FE_LLVMUTIL_H_
|
|
32
|
-
|
|
33
|
-
#include "SVF-FE/BasicTypes.h"
|
|
34
|
-
#include "Util/SVFUtil.h"
|
|
35
|
-
#include "SVF-FE/BasicTypes.h"
|
|
36
|
-
#include "Util/BasicTypes.h"
|
|
37
|
-
#include "Util/ExtAPI.h"
|
|
38
|
-
#include "Util/ThreadAPI.h"
|
|
39
|
-
|
|
40
|
-
namespace SVF
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
namespace LLVMUtil
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/// Check whether this value is a black hole
|
|
48
|
-
inline bool isBlackholeSym(const Value* val)
|
|
49
|
-
{
|
|
50
|
-
return (SVFUtil::isa<UndefValue>(val));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/// Check whether this value is a black hole
|
|
54
|
-
inline bool isNullPtrSym(const Value* val)
|
|
55
|
-
{
|
|
56
|
-
if (const Constant* v = SVFUtil::dyn_cast<Constant>(val))
|
|
57
|
-
{
|
|
58
|
-
return v->isNullValue() && v->getType()->isPointerTy();
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/// Check whether this value points-to a constant object
|
|
64
|
-
bool isConstantObjSym(const Value* val);
|
|
65
|
-
|
|
66
|
-
static inline Type *getPtrElementType(const PointerType* pty)
|
|
67
|
-
{
|
|
68
|
-
#if (LLVM_VERSION_MAJOR < 14)
|
|
69
|
-
return pty->getElementType();
|
|
70
|
-
#else
|
|
71
|
-
assert(!pty->isOpaque() && "Opaque Pointer is used, please recompile the source adding '-Xclang -no-opaque-pointers'");
|
|
72
|
-
return pty->getNonOpaquePointerElementType();
|
|
73
|
-
#endif
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/// Get the reference type of heap/static object from an allocation site.
|
|
77
|
-
//@{
|
|
78
|
-
inline const PointerType *getRefTypeOfHeapAllocOrStatic(const CallSite cs)
|
|
79
|
-
{
|
|
80
|
-
const PointerType *refType = nullptr;
|
|
81
|
-
// Case 1: heap object held by *argument, we should get its element type.
|
|
82
|
-
if (SVFUtil::isHeapAllocExtCallViaArg(cs))
|
|
83
|
-
{
|
|
84
|
-
int argPos = SVFUtil::getHeapAllocHoldingArgPosition(cs);
|
|
85
|
-
const Value* arg = cs.getArgument(argPos);
|
|
86
|
-
if (const PointerType *argType = SVFUtil::dyn_cast<PointerType>(arg->getType()))
|
|
87
|
-
refType = SVFUtil::dyn_cast<PointerType>(getPtrElementType(argType));
|
|
88
|
-
}
|
|
89
|
-
// Case 2: heap/static object held by return value.
|
|
90
|
-
else
|
|
91
|
-
{
|
|
92
|
-
assert((SVFUtil::isStaticExtCall(cs) || SVFUtil::isHeapAllocExtCallViaRet(cs))
|
|
93
|
-
&& "Must be heap alloc via ret, or static allocation site");
|
|
94
|
-
refType = SVFUtil::dyn_cast<PointerType>(cs.getType());
|
|
95
|
-
}
|
|
96
|
-
assert(refType && "Allocated object must be held by a pointer-typed value.");
|
|
97
|
-
return refType;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
inline const PointerType *getRefTypeOfHeapAllocOrStatic(const SVFInstruction* inst)
|
|
101
|
-
{
|
|
102
|
-
CallSite cs(inst);
|
|
103
|
-
return getRefTypeOfHeapAllocOrStatic(cs);
|
|
104
|
-
}
|
|
105
|
-
//@}
|
|
106
|
-
|
|
107
|
-
/// Return true if this value refers to a object
|
|
108
|
-
bool isObject (const Value* ref);
|
|
109
|
-
|
|
110
|
-
/// Method for dead function, which does not have any possible caller
|
|
111
|
-
/// function address is not taken and never be used in call or invoke instruction
|
|
112
|
-
//@{
|
|
113
|
-
/// whether this is a function without any possible caller?
|
|
114
|
-
bool isUncalledFunction (const Function* fun);
|
|
115
|
-
|
|
116
|
-
/// whether this is an argument in dead function
|
|
117
|
-
inline bool ArgInDeadFunction (const Value* val)
|
|
118
|
-
{
|
|
119
|
-
return SVFUtil::isa<Argument>(val)
|
|
120
|
-
&& isUncalledFunction(SVFUtil::cast<Argument>(val)->getParent());
|
|
121
|
-
}
|
|
122
|
-
//@}
|
|
123
|
-
|
|
124
|
-
/// Return true if this is an argument of a program entry function (e.g. main)
|
|
125
|
-
inline bool ArgInProgEntryFunction (const Value* val)
|
|
126
|
-
{
|
|
127
|
-
return SVFUtil::isa<Argument>(val)
|
|
128
|
-
&& SVFUtil::isProgEntryFunction(SVFUtil::cast<Argument>(val)->getParent());
|
|
129
|
-
}
|
|
130
|
-
/// Return true if this is value in a dead function (function without any caller)
|
|
131
|
-
bool isPtrInUncalledFunction (const Value* value);
|
|
132
|
-
//@}
|
|
133
|
-
|
|
134
|
-
//@}
|
|
135
|
-
|
|
136
|
-
/// Function does not have any possible caller in the call graph
|
|
137
|
-
//@{
|
|
138
|
-
/// Return true if the function does not have a caller (either it is a main function or a dead function)
|
|
139
|
-
inline bool isNoCallerFunction (const Function* fun)
|
|
140
|
-
{
|
|
141
|
-
return isUncalledFunction(fun) || SVFUtil::isProgEntryFunction(fun);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/// Return true if the argument in a function does not have a caller
|
|
145
|
-
inline bool isArgOfUncalledFunction (const Value* val)
|
|
146
|
-
{
|
|
147
|
-
return SVFUtil::isa<Argument>(val)
|
|
148
|
-
&& isNoCallerFunction(SVFUtil::cast<Argument>(val)->getParent());
|
|
149
|
-
}
|
|
150
|
-
//@}
|
|
151
|
-
|
|
152
|
-
/// Return true if the function has a return instruction reachable from function entry
|
|
153
|
-
bool functionDoesNotRet (const Function* fun);
|
|
154
|
-
|
|
155
|
-
/// Get reachable basic block from function entry
|
|
156
|
-
void getFunReachableBBs (const SVFFunction* svfFun, std::vector<const SVFBasicBlock*>& bbs);
|
|
157
|
-
|
|
158
|
-
/// Strip off the constant casts
|
|
159
|
-
const Value* stripConstantCasts(const Value* val);
|
|
160
|
-
|
|
161
|
-
/// Strip off the all casts
|
|
162
|
-
const Value* stripAllCasts(const Value* val) ;
|
|
163
|
-
|
|
164
|
-
/// Get the type of the heap allocation
|
|
165
|
-
const Type *getTypeOfHeapAlloc(const SVFInstruction* inst) ;
|
|
166
|
-
|
|
167
|
-
/// Return the bitcast instruction which is val's only use site, otherwise return nullptr
|
|
168
|
-
const Value* getUniqueUseViaCastInst(const Value* val);
|
|
169
|
-
|
|
170
|
-
/// Return corresponding constant expression, otherwise return nullptr
|
|
171
|
-
//@{
|
|
172
|
-
inline const ConstantExpr *isGepConstantExpr(const Value* val)
|
|
173
|
-
{
|
|
174
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
175
|
-
{
|
|
176
|
-
if(constExpr->getOpcode() == Instruction::GetElementPtr)
|
|
177
|
-
return constExpr;
|
|
178
|
-
}
|
|
179
|
-
return nullptr;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
inline const ConstantExpr *isInt2PtrConstantExpr(const Value* val)
|
|
183
|
-
{
|
|
184
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
185
|
-
{
|
|
186
|
-
if(constExpr->getOpcode() == Instruction::IntToPtr)
|
|
187
|
-
return constExpr;
|
|
188
|
-
}
|
|
189
|
-
return nullptr;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
inline const ConstantExpr *isPtr2IntConstantExpr(const Value* val)
|
|
193
|
-
{
|
|
194
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
195
|
-
{
|
|
196
|
-
if(constExpr->getOpcode() == Instruction::PtrToInt)
|
|
197
|
-
return constExpr;
|
|
198
|
-
}
|
|
199
|
-
return nullptr;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
inline const ConstantExpr *isCastConstantExpr(const Value* val)
|
|
203
|
-
{
|
|
204
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
205
|
-
{
|
|
206
|
-
if(constExpr->getOpcode() == Instruction::BitCast)
|
|
207
|
-
return constExpr;
|
|
208
|
-
}
|
|
209
|
-
return nullptr;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
inline const ConstantExpr *isSelectConstantExpr(const Value* val)
|
|
213
|
-
{
|
|
214
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
215
|
-
{
|
|
216
|
-
if(constExpr->getOpcode() == Instruction::Select)
|
|
217
|
-
return constExpr;
|
|
218
|
-
}
|
|
219
|
-
return nullptr;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
inline const ConstantExpr *isTruncConstantExpr(const Value* val)
|
|
223
|
-
{
|
|
224
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
225
|
-
{
|
|
226
|
-
if(constExpr->getOpcode() == Instruction::Trunc ||
|
|
227
|
-
constExpr->getOpcode() == Instruction::FPTrunc ||
|
|
228
|
-
constExpr->getOpcode() == Instruction::ZExt ||
|
|
229
|
-
constExpr->getOpcode() == Instruction::SExt ||
|
|
230
|
-
constExpr->getOpcode() == Instruction::FPExt)
|
|
231
|
-
return constExpr;
|
|
232
|
-
}
|
|
233
|
-
return nullptr;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
inline const ConstantExpr *isCmpConstantExpr(const Value* val)
|
|
237
|
-
{
|
|
238
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
239
|
-
{
|
|
240
|
-
if(constExpr->getOpcode() == Instruction::ICmp || constExpr->getOpcode() == Instruction::FCmp)
|
|
241
|
-
return constExpr;
|
|
242
|
-
}
|
|
243
|
-
return nullptr;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
inline const ConstantExpr *isBinaryConstantExpr(const Value* val)
|
|
247
|
-
{
|
|
248
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
249
|
-
{
|
|
250
|
-
if((constExpr->getOpcode() >= Instruction::BinaryOpsBegin) && (constExpr->getOpcode() <= Instruction::BinaryOpsEnd))
|
|
251
|
-
return constExpr;
|
|
252
|
-
}
|
|
253
|
-
return nullptr;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
inline const ConstantExpr *isUnaryConstantExpr(const Value* val)
|
|
257
|
-
{
|
|
258
|
-
if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
|
|
259
|
-
{
|
|
260
|
-
if((constExpr->getOpcode() >= Instruction::UnaryOpsBegin) && (constExpr->getOpcode() <= Instruction::UnaryOpsEnd))
|
|
261
|
-
return constExpr;
|
|
262
|
-
}
|
|
263
|
-
return nullptr;
|
|
264
|
-
}
|
|
265
|
-
//@}
|
|
266
|
-
|
|
267
|
-
inline static DataLayout* getDataLayout(Module* mod)
|
|
268
|
-
{
|
|
269
|
-
static DataLayout *dl = nullptr;
|
|
270
|
-
if (dl == nullptr) dl = new DataLayout(mod);
|
|
271
|
-
return dl;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/// Get the next instructions following control flow
|
|
275
|
-
void getNextInsts(const SVFInstruction* curInst, std::vector<const SVFInstruction*>& instList);
|
|
276
|
-
|
|
277
|
-
/// Get the previous instructions following control flow
|
|
278
|
-
void getPrevInsts(const SVFInstruction* curInst, std::vector<const SVFInstruction*>& instList);
|
|
279
|
-
|
|
280
|
-
/// Get num of BB's predecessors
|
|
281
|
-
u32_t getBBPredecessorNum(const BasicBlock* BB);
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
/// Check whether a file is an LLVM IR file
|
|
286
|
-
bool isIRFile(const std::string &filename);
|
|
287
|
-
|
|
288
|
-
/// Parse argument for multi-module analysis
|
|
289
|
-
void processArguments(int argc, char **argv, int &arg_num, char **arg_value,
|
|
290
|
-
std::vector<std::string> &moduleNameVec);
|
|
291
|
-
|
|
292
|
-
/// Helper method to get the size of the type from target data layout
|
|
293
|
-
//@{
|
|
294
|
-
u32_t getTypeSizeInBytes(const Type* type);
|
|
295
|
-
u32_t getTypeSizeInBytes(const StructType *sty, u32_t field_index);
|
|
296
|
-
//@}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
} // End namespace LLVMUtil
|
|
300
|
-
|
|
301
|
-
} // End namespace SVF
|
|
302
|
-
|
|
303
|
-
#endif /* INCLUDE_SVF_FE_LLVMUTIL_H_ */
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//===- LocMemModel.h -- Location set based memory model-----------------------//
|
|
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 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 General Public License for more details.
|
|
17
|
-
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
//
|
|
21
|
-
//===----------------------------------------------------------------------===//
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
* LocMemModel.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: Apr 28, 2014
|
|
27
|
-
* Author: Yulei
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef LOCMEMMODEL_H_
|
|
31
|
-
#define LOCMEMMODEL_H_
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
#endif /* LOCMEMMODEL_H_ */
|