svf-lib 1.0.1289 → 1.0.1291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-linux/Release-build/lib/libSvf.a +0 -0
- package/SVF-linux/include/CFL/CFLAlias.h +1 -1
- package/SVF-linux/include/CFL/CFLBase.h +1 -1
- package/SVF-linux/include/CFL/CFLGrammar.h +1 -1
- package/SVF-linux/include/DDA/DDAClient.h +2 -2
- package/SVF-linux/include/DDA/DDAPass.h +3 -3
- package/SVF-linux/include/Graphs/CHG.h +5 -5
- package/SVF-linux/include/Graphs/ConsG.h +1 -1
- package/SVF-linux/include/Graphs/ConsGEdge.h +1 -1
- package/SVF-linux/include/Graphs/GenericGraph.h +1 -1
- package/SVF-linux/include/Graphs/ICFG.h +1 -1
- package/SVF-linux/include/Graphs/ICFGEdge.h +3 -3
- package/SVF-linux/include/Graphs/IRGraph.h +13 -9
- package/SVF-linux/include/Graphs/PTACallGraph.h +1 -1
- package/SVF-linux/include/Graphs/SVFGOPT.h +2 -2
- package/SVF-linux/include/Graphs/ThreadCallGraph.h +2 -2
- package/SVF-linux/include/Graphs/VFG.h +1 -1
- package/SVF-linux/include/Graphs/VFGNode.h +7 -7
- package/SVF-linux/include/MSSA/MemRegion.h +2 -2
- package/SVF-linux/include/MTA/LockAnalysis.h +1 -4
- package/SVF-linux/include/MTA/MHP.h +22 -31
- package/SVF-linux/include/MTA/MTA.h +13 -32
- package/SVF-linux/include/MTA/MTAResultValidator.h +17 -16
- package/SVF-linux/include/MTA/MTAStat.h +1 -1
- package/SVF-linux/include/MTA/TCT.h +25 -18
- package/SVF-linux/include/MemoryModel/AbstractPointsToDS.h +1 -1
- package/SVF-linux/include/MemoryModel/ConditionalPT.h +3 -2
- package/SVF-linux/include/MemoryModel/LocationSet.h +4 -4
- package/SVF-linux/include/MemoryModel/MutablePointsToDS.h +1 -1
- package/SVF-linux/include/MemoryModel/PersistentPointsToCache.h +1 -1
- package/SVF-linux/include/MemoryModel/PointerAnalysis.h +5 -4
- package/SVF-linux/include/MemoryModel/PointerAnalysisImpl.h +4 -4
- package/SVF-linux/include/MemoryModel/PointsTo.h +1 -1
- package/SVF-linux/include/MemoryModel/SVFLoop.h +1 -1
- package/SVF-linux/include/SABER/DoubleFreeChecker.h +2 -2
- package/SVF-linux/include/SABER/FileChecker.h +2 -2
- package/SVF-linux/include/SABER/LeakChecker.h +2 -2
- package/SVF-linux/include/SABER/ProgSlice.h +0 -3
- package/SVF-linux/include/SABER/SaberCondAllocator.h +7 -9
- package/SVF-linux/include/SABER/SaberSVFGBuilder.h +1 -1
- package/SVF-linux/include/SVF-LLVM/BasicTypes.h +248 -0
- package/SVF-linux/include/SVF-LLVM/BreakConstantExpr.h +94 -0
- package/SVF-linux/include/SVF-LLVM/CHGBuilder.h +73 -0
- package/SVF-linux/include/SVF-LLVM/CPPUtil.h +130 -0
- package/SVF-linux/include/SVF-LLVM/DCHG.h +481 -0
- package/SVF-linux/include/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
- package/SVF-linux/include/SVF-LLVM/ICFGBuilder.h +106 -0
- package/SVF-linux/include/SVF-LLVM/IRAnnotator.h +323 -0
- package/SVF-linux/include/SVF-LLVM/LLVMLoopAnalysis.h +59 -0
- package/SVF-linux/include/SVF-LLVM/LLVMModule.h +358 -0
- package/SVF-linux/include/SVF-LLVM/LLVMUtil.h +405 -0
- package/SVF-linux/include/SVF-LLVM/SVFIRBuilder.h +413 -0
- package/SVF-linux/include/SVF-LLVM/SymbolTableBuilder.h +113 -0
- package/SVF-linux/include/SVFIR/PAGBuilderFromFile.h +80 -0
- package/SVF-linux/include/SVFIR/SVFIR.h +661 -0
- package/SVF-linux/include/SVFIR/SVFModule.h +233 -0
- package/SVF-linux/include/SVFIR/SVFStatements.h +1101 -0
- package/SVF-linux/include/SVFIR/SVFType.h +514 -0
- package/SVF-linux/include/SVFIR/SVFValue.h +1129 -0
- package/SVF-linux/include/SVFIR/SVFVariables.h +721 -0
- package/SVF-linux/include/SVFIR/SymbolTableInfo.h +597 -0
- package/SVF-linux/include/Util/Annotator.h +1 -1
- package/SVF-linux/include/Util/CallGraphBuilder.h +74 -0
- package/SVF-linux/include/Util/Casting.h +1 -3
- package/SVF-linux/include/Util/CoreBitVector.h +1 -1
- package/SVF-linux/include/Util/CxtStmt.h +8 -8
- package/SVF-linux/include/Util/DPItem.h +1 -1
- package/SVF-linux/include/Util/ExtAPI.h +1 -1
- package/SVF-linux/include/Util/NodeIDAllocator.h +1 -1
- package/SVF-linux/include/Util/Options.h +1 -0
- package/SVF-linux/include/Util/PTAStat.h +1 -1
- package/SVF-linux/include/Util/SCC.h +1 -1
- package/SVF-linux/include/Util/SVFUtil.h +26 -95
- package/SVF-linux/include/Util/ThreadAPI.h +27 -27
- package/SVF-linux/include/Util/WorkList.h +1 -1
- package/SVF-linux/include/Util/Z3Expr.h +1 -1
- package/SVF-linux/include/WPA/Andersen.h +1 -1
- package/SVF-linux/include/WPA/CSC.h +1 -1
- package/SVF-linux/include/WPA/TypeAnalysis.h +0 -3
- package/SVF-linux/include/WPA/WPAPass.h +8 -8
- package/SVF-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/CFL/CFLAlias.h +1 -1
- package/SVF-osx/include/CFL/CFLBase.h +1 -1
- package/SVF-osx/include/CFL/CFLGrammar.h +1 -1
- package/SVF-osx/include/DDA/DDAClient.h +2 -2
- package/SVF-osx/include/DDA/DDAPass.h +3 -3
- package/SVF-osx/include/Graphs/CHG.h +5 -5
- package/SVF-osx/include/Graphs/ConsG.h +1 -1
- package/SVF-osx/include/Graphs/ConsGEdge.h +1 -1
- package/SVF-osx/include/Graphs/GenericGraph.h +1 -1
- package/SVF-osx/include/Graphs/ICFG.h +1 -1
- package/SVF-osx/include/Graphs/ICFGEdge.h +3 -3
- package/SVF-osx/include/Graphs/IRGraph.h +13 -9
- package/SVF-osx/include/Graphs/PTACallGraph.h +1 -1
- package/SVF-osx/include/Graphs/SVFGOPT.h +2 -2
- package/SVF-osx/include/Graphs/ThreadCallGraph.h +2 -2
- package/SVF-osx/include/Graphs/VFG.h +1 -1
- package/SVF-osx/include/Graphs/VFGNode.h +7 -7
- package/SVF-osx/include/MSSA/MemRegion.h +2 -2
- package/SVF-osx/include/MTA/LockAnalysis.h +1 -4
- package/SVF-osx/include/MTA/MHP.h +22 -31
- package/SVF-osx/include/MTA/MTA.h +13 -32
- package/SVF-osx/include/MTA/MTAResultValidator.h +17 -16
- package/SVF-osx/include/MTA/MTAStat.h +1 -1
- package/SVF-osx/include/MTA/TCT.h +25 -18
- package/SVF-osx/include/MemoryModel/AbstractPointsToDS.h +1 -1
- package/SVF-osx/include/MemoryModel/ConditionalPT.h +3 -2
- package/SVF-osx/include/MemoryModel/LocationSet.h +4 -4
- package/SVF-osx/include/MemoryModel/MutablePointsToDS.h +1 -1
- package/SVF-osx/include/MemoryModel/PersistentPointsToCache.h +1 -1
- package/SVF-osx/include/MemoryModel/PointerAnalysis.h +5 -4
- package/SVF-osx/include/MemoryModel/PointerAnalysisImpl.h +4 -4
- package/SVF-osx/include/MemoryModel/PointsTo.h +1 -1
- package/SVF-osx/include/MemoryModel/SVFLoop.h +1 -1
- package/SVF-osx/include/SABER/DoubleFreeChecker.h +2 -2
- package/SVF-osx/include/SABER/FileChecker.h +2 -2
- package/SVF-osx/include/SABER/LeakChecker.h +2 -2
- package/SVF-osx/include/SABER/ProgSlice.h +0 -3
- package/SVF-osx/include/SABER/SaberCondAllocator.h +7 -9
- package/SVF-osx/include/SABER/SaberSVFGBuilder.h +1 -1
- package/SVF-osx/include/SVF-LLVM/BasicTypes.h +248 -0
- package/SVF-osx/include/SVF-LLVM/BreakConstantExpr.h +94 -0
- package/SVF-osx/include/SVF-LLVM/CHGBuilder.h +73 -0
- package/SVF-osx/include/SVF-LLVM/CPPUtil.h +130 -0
- package/SVF-osx/include/SVF-LLVM/DCHG.h +481 -0
- package/SVF-osx/include/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
- package/SVF-osx/include/SVF-LLVM/ICFGBuilder.h +106 -0
- package/SVF-osx/include/SVF-LLVM/IRAnnotator.h +323 -0
- package/SVF-osx/include/SVF-LLVM/LLVMLoopAnalysis.h +59 -0
- package/SVF-osx/include/SVF-LLVM/LLVMModule.h +358 -0
- package/SVF-osx/include/SVF-LLVM/LLVMUtil.h +405 -0
- package/SVF-osx/include/SVF-LLVM/SVFIRBuilder.h +413 -0
- package/SVF-osx/include/SVF-LLVM/SymbolTableBuilder.h +113 -0
- package/SVF-osx/include/SVFIR/PAGBuilderFromFile.h +80 -0
- package/SVF-osx/include/SVFIR/SVFIR.h +661 -0
- package/SVF-osx/include/SVFIR/SVFModule.h +233 -0
- package/SVF-osx/include/SVFIR/SVFStatements.h +1101 -0
- package/SVF-osx/include/SVFIR/SVFType.h +514 -0
- package/SVF-osx/include/SVFIR/SVFValue.h +1129 -0
- package/SVF-osx/include/SVFIR/SVFVariables.h +721 -0
- package/SVF-osx/include/SVFIR/SymbolTableInfo.h +597 -0
- package/SVF-osx/include/Util/Annotator.h +1 -1
- package/SVF-osx/include/Util/CallGraphBuilder.h +74 -0
- package/SVF-osx/include/Util/Casting.h +1 -3
- package/SVF-osx/include/Util/CoreBitVector.h +1 -1
- package/SVF-osx/include/Util/CxtStmt.h +8 -8
- package/SVF-osx/include/Util/DPItem.h +1 -1
- package/SVF-osx/include/Util/ExtAPI.h +1 -1
- package/SVF-osx/include/Util/NodeIDAllocator.h +1 -1
- package/SVF-osx/include/Util/Options.h +1 -0
- package/SVF-osx/include/Util/PTAStat.h +1 -1
- package/SVF-osx/include/Util/SCC.h +1 -1
- package/SVF-osx/include/Util/SVFUtil.h +26 -95
- package/SVF-osx/include/Util/ThreadAPI.h +27 -27
- package/SVF-osx/include/Util/WorkList.h +1 -1
- package/SVF-osx/include/Util/Z3Expr.h +1 -1
- package/SVF-osx/include/WPA/Andersen.h +1 -1
- package/SVF-osx/include/WPA/CSC.h +1 -1
- package/SVF-osx/include/WPA/TypeAnalysis.h +0 -3
- package/SVF-osx/include/WPA/WPAPass.h +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,358 @@
|
|
|
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-LLVM/BasicTypes.h"
|
|
34
|
+
#include "SVF-LLVM/CPPUtil.h"
|
|
35
|
+
#include "SVFIR/SVFValue.h"
|
|
36
|
+
#include "SVFIR/SVFModule.h"
|
|
37
|
+
|
|
38
|
+
namespace SVF
|
|
39
|
+
{
|
|
40
|
+
|
|
41
|
+
class SymbolTableInfo;
|
|
42
|
+
|
|
43
|
+
class LLVMModuleSet
|
|
44
|
+
{
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
|
|
48
|
+
typedef std::vector<const Function*> FunctionSetType;
|
|
49
|
+
typedef Map<const Function*, const Function*> FunDeclToDefMapTy;
|
|
50
|
+
typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
|
|
51
|
+
typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
|
|
52
|
+
|
|
53
|
+
typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
|
|
54
|
+
typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
|
|
55
|
+
typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
|
|
56
|
+
typedef Map<const Argument*, SVFArgument*> LLVMArgument2SVFArgumentMap;
|
|
57
|
+
typedef Map<const Constant*, SVFConstant*> LLVMConst2SVFConstMap;
|
|
58
|
+
typedef Map<const Value*, SVFOtherValue*> LLVMValue2SVFOtherValueMap;
|
|
59
|
+
typedef Map<const SVFValue*, const Value*> SVFValue2LLVMValueMap;
|
|
60
|
+
typedef Map<const Type*, SVFType*> LLVMType2SVFTypeMap;
|
|
61
|
+
typedef Map<const Type*, StInfo*> Type2TypeInfoMap;
|
|
62
|
+
|
|
63
|
+
private:
|
|
64
|
+
static LLVMModuleSet* llvmModuleSet;
|
|
65
|
+
SymbolTableInfo *symInfo;
|
|
66
|
+
SVFModule* svfModule;
|
|
67
|
+
std::unique_ptr<LLVMContext> cxts;
|
|
68
|
+
std::vector<std::unique_ptr<Module>> owned_modules;
|
|
69
|
+
std::vector<std::reference_wrapper<Module>> modules;
|
|
70
|
+
|
|
71
|
+
/// Function declaration to function definition map
|
|
72
|
+
FunDeclToDefMapTy FunDeclToDefMap;
|
|
73
|
+
/// Function definition to function declaration map
|
|
74
|
+
FunDefToDeclsMapTy FunDefToDeclsMap;
|
|
75
|
+
/// Global definition to a rep definition map
|
|
76
|
+
GlobalDefToRepMapTy GlobalDefToRepMap;
|
|
77
|
+
|
|
78
|
+
LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
|
|
79
|
+
LLVMBB2SVFBBMap LLVMBB2SVFBB;
|
|
80
|
+
LLVMInst2SVFInstMap LLVMInst2SVFInst;
|
|
81
|
+
LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
|
|
82
|
+
LLVMConst2SVFConstMap LLVMConst2SVFConst;
|
|
83
|
+
LLVMValue2SVFOtherValueMap LLVMValue2SVFOtherValue;
|
|
84
|
+
SVFValue2LLVMValueMap SVFValue2LLVMValue;
|
|
85
|
+
LLVMType2SVFTypeMap LLVMType2SVFType;
|
|
86
|
+
Type2TypeInfoMap Type2TypeInfo;
|
|
87
|
+
|
|
88
|
+
/// Constructor
|
|
89
|
+
LLVMModuleSet();
|
|
90
|
+
~LLVMModuleSet();
|
|
91
|
+
|
|
92
|
+
void build();
|
|
93
|
+
|
|
94
|
+
public:
|
|
95
|
+
static inline LLVMModuleSet* getLLVMModuleSet()
|
|
96
|
+
{
|
|
97
|
+
if (llvmModuleSet == nullptr)
|
|
98
|
+
llvmModuleSet = new LLVMModuleSet();
|
|
99
|
+
return llvmModuleSet;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static void releaseLLVMModuleSet()
|
|
103
|
+
{
|
|
104
|
+
if (llvmModuleSet)
|
|
105
|
+
delete llvmModuleSet;
|
|
106
|
+
llvmModuleSet = nullptr;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
SVFModule* buildSVFModule(Module& mod);
|
|
110
|
+
SVFModule* buildSVFModule(const std::vector<std::string>& moduleNameVec);
|
|
111
|
+
|
|
112
|
+
inline SVFModule* getSVFModule()
|
|
113
|
+
{
|
|
114
|
+
assert(svfModule && "svfModule has not been built yet!");
|
|
115
|
+
return svfModule;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void preProcessBCs(std::vector<std::string>& moduleNameVec);
|
|
119
|
+
|
|
120
|
+
u32_t getModuleNum() const
|
|
121
|
+
{
|
|
122
|
+
return modules.size();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const std::vector<std::reference_wrapper<Module>>& getLLVMModules() const
|
|
126
|
+
{
|
|
127
|
+
return modules;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
Module *getModule(u32_t idx) const
|
|
131
|
+
{
|
|
132
|
+
return &getModuleRef(idx);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
Module &getModuleRef(u32_t idx) const
|
|
136
|
+
{
|
|
137
|
+
assert(idx < getModuleNum() && "Out of range.");
|
|
138
|
+
return modules[idx];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Dump modules to files
|
|
142
|
+
void dumpModulesToFile(const std::string suffix);
|
|
143
|
+
|
|
144
|
+
inline void addFunctionMap(const Function* func, SVFFunction* svfFunc)
|
|
145
|
+
{
|
|
146
|
+
LLVMFunc2SVFFunc[func] = svfFunc;
|
|
147
|
+
setValueAttr(func,svfFunc);
|
|
148
|
+
}
|
|
149
|
+
inline void addBasicBlockMap(const BasicBlock* bb, SVFBasicBlock* svfBB)
|
|
150
|
+
{
|
|
151
|
+
LLVMBB2SVFBB[bb] = svfBB;
|
|
152
|
+
setValueAttr(bb,svfBB);
|
|
153
|
+
}
|
|
154
|
+
inline void addInstructionMap(const Instruction* inst, SVFInstruction* svfInst)
|
|
155
|
+
{
|
|
156
|
+
LLVMInst2SVFInst[inst] = svfInst;
|
|
157
|
+
setValueAttr(inst,svfInst);
|
|
158
|
+
}
|
|
159
|
+
inline void addArgumentMap(const Argument* arg, SVFArgument* svfArg)
|
|
160
|
+
{
|
|
161
|
+
LLVMArgument2SVFArgument[arg] = svfArg;
|
|
162
|
+
setValueAttr(arg,svfArg);
|
|
163
|
+
}
|
|
164
|
+
inline void addGlobalValueMap(const GlobalValue* glob, SVFGlobalValue* svfglob)
|
|
165
|
+
{
|
|
166
|
+
LLVMConst2SVFConst[glob] = svfglob;
|
|
167
|
+
setValueAttr(glob,svfglob);
|
|
168
|
+
}
|
|
169
|
+
inline void addConstantDataMap(const ConstantData* cd, SVFConstantData* svfcd)
|
|
170
|
+
{
|
|
171
|
+
LLVMConst2SVFConst[cd] = svfcd;
|
|
172
|
+
setValueAttr(cd,svfcd);
|
|
173
|
+
}
|
|
174
|
+
inline void addOtherConstantMap(const Constant* cons, SVFConstant* svfcons)
|
|
175
|
+
{
|
|
176
|
+
LLVMConst2SVFConst[cons] = svfcons;
|
|
177
|
+
setValueAttr(cons,svfcons);
|
|
178
|
+
}
|
|
179
|
+
inline void addOtherValueMap(const Value* ov, SVFOtherValue* svfov)
|
|
180
|
+
{
|
|
181
|
+
LLVMValue2SVFOtherValue[ov] = svfov;
|
|
182
|
+
setValueAttr(ov,svfov);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
SVFValue* getSVFValue(const Value* value);
|
|
186
|
+
|
|
187
|
+
const Value* getLLVMValue(const SVFValue* value) const
|
|
188
|
+
{
|
|
189
|
+
SVFValue2LLVMValueMap::const_iterator it = SVFValue2LLVMValue.find(value);
|
|
190
|
+
assert(it!=SVFValue2LLVMValue.end() && "can't find corresponding llvm value!");
|
|
191
|
+
return it->second;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
inline SVFFunction* getSVFFunction(const Function* fun) const
|
|
195
|
+
{
|
|
196
|
+
LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
|
|
197
|
+
assert(it!=LLVMFunc2SVFFunc.end() && "SVF Function not found!");
|
|
198
|
+
return it->second;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
inline SVFBasicBlock* getSVFBasicBlock(const BasicBlock* bb) const
|
|
202
|
+
{
|
|
203
|
+
LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
|
|
204
|
+
assert(it!=LLVMBB2SVFBB.end() && "SVF BasicBlock not found!");
|
|
205
|
+
return it->second;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
inline SVFInstruction* getSVFInstruction(const Instruction* inst) const
|
|
209
|
+
{
|
|
210
|
+
LLVMInst2SVFInstMap::const_iterator it = LLVMInst2SVFInst.find(inst);
|
|
211
|
+
assert(it!=LLVMInst2SVFInst.end() && "SVF Instruction not found!");
|
|
212
|
+
return it->second;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
inline SVFArgument* getSVFArgument(const Argument* arg) const
|
|
216
|
+
{
|
|
217
|
+
LLVMArgument2SVFArgumentMap::const_iterator it = LLVMArgument2SVFArgument.find(arg);
|
|
218
|
+
assert(it!=LLVMArgument2SVFArgument.end() && "SVF Argument not found!");
|
|
219
|
+
return it->second;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
inline SVFGlobalValue* getSVFGlobalValue(const GlobalValue* g) const
|
|
223
|
+
{
|
|
224
|
+
LLVMConst2SVFConstMap::const_iterator it = LLVMConst2SVFConst.find(g);
|
|
225
|
+
assert(it!=LLVMConst2SVFConst.end() && "SVF Global not found!");
|
|
226
|
+
assert(SVFUtil::isa<SVFGlobalValue>(it->second) && "not a SVFGlobal type!");
|
|
227
|
+
return SVFUtil::cast<SVFGlobalValue>(it->second);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
SVFConstantData* getSVFConstantData(const ConstantData* cd);
|
|
231
|
+
SVFConstant* getOtherSVFConstant(const Constant* oc);
|
|
232
|
+
|
|
233
|
+
SVFOtherValue* getSVFOtherValue(const Value* ov);
|
|
234
|
+
|
|
235
|
+
/// Get the corresponding Function based on its name
|
|
236
|
+
inline const SVFFunction* getSVFFunction(std::string name)
|
|
237
|
+
{
|
|
238
|
+
Function* fun = nullptr;
|
|
239
|
+
|
|
240
|
+
for (u32_t i = 0; i < llvmModuleSet->getModuleNum(); ++i)
|
|
241
|
+
{
|
|
242
|
+
Module* mod = llvmModuleSet->getModule(i);
|
|
243
|
+
fun = mod->getFunction(name);
|
|
244
|
+
if (fun)
|
|
245
|
+
{
|
|
246
|
+
return llvmModuleSet->getSVFFunction(fun);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return nullptr;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
bool hasDefinition(const Function* fun) const
|
|
253
|
+
{
|
|
254
|
+
assert(fun->isDeclaration() && "not a function declaration?");
|
|
255
|
+
FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
|
|
256
|
+
return it != FunDeclToDefMap.end();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const Function* getDefinition(const Function* fun) const
|
|
260
|
+
{
|
|
261
|
+
assert(fun->isDeclaration() && "not a function declaration?");
|
|
262
|
+
FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
|
|
263
|
+
assert(it != FunDeclToDefMap.end() && "has no definition?");
|
|
264
|
+
return it->second;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
bool hasDeclaration(const Function* fun) const
|
|
268
|
+
{
|
|
269
|
+
if(fun->isDeclaration() && !hasDefinition(fun))
|
|
270
|
+
return false;
|
|
271
|
+
|
|
272
|
+
const Function* funDef = fun;
|
|
273
|
+
if(fun->isDeclaration() && hasDefinition(fun))
|
|
274
|
+
funDef = getDefinition(fun);
|
|
275
|
+
|
|
276
|
+
FunDefToDeclsMapTy::const_iterator it = FunDefToDeclsMap.find(funDef);
|
|
277
|
+
return it != FunDefToDeclsMap.end();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const FunctionSetType& getDeclaration(const Function* fun) const
|
|
281
|
+
{
|
|
282
|
+
const Function* funDef = fun;
|
|
283
|
+
if(fun->isDeclaration() && hasDefinition(fun))
|
|
284
|
+
funDef = getDefinition(fun);
|
|
285
|
+
|
|
286
|
+
FunDefToDeclsMapTy::const_iterator it = FunDefToDeclsMap.find(funDef);
|
|
287
|
+
assert(it != FunDefToDeclsMap.end() && "does not have a function definition (body)?");
|
|
288
|
+
return it->second;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/// Global to rep
|
|
292
|
+
bool hasGlobalRep(const GlobalVariable* val) const
|
|
293
|
+
{
|
|
294
|
+
GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
|
|
295
|
+
return it != GlobalDefToRepMap.end();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
GlobalVariable *getGlobalRep(const GlobalVariable* val) const
|
|
299
|
+
{
|
|
300
|
+
GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
|
|
301
|
+
assert(it != GlobalDefToRepMap.end() && "has no rep?");
|
|
302
|
+
return it->second;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
Module* getMainLLVMModule() const
|
|
307
|
+
{
|
|
308
|
+
return getModule(0);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
LLVMContext& getContext() const
|
|
312
|
+
{
|
|
313
|
+
assert(!empty() && "empty LLVM module!!");
|
|
314
|
+
return getMainLLVMModule()->getContext();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
bool empty() const
|
|
318
|
+
{
|
|
319
|
+
return getModuleNum() == 0;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/// Get or create SVFType and typeinfo
|
|
323
|
+
SVFType* getSVFType(const Type* T);
|
|
324
|
+
/// Get LLVM Type
|
|
325
|
+
const Type* getLLVMType(const SVFType* T) const;
|
|
326
|
+
|
|
327
|
+
private:
|
|
328
|
+
/// Create SVFTypes
|
|
329
|
+
SVFType* addSVFTypeInfo(const Type* t);
|
|
330
|
+
/// Collect a type info
|
|
331
|
+
StInfo* collectTypeInfo(const Type* ty);
|
|
332
|
+
/// Collect the struct info
|
|
333
|
+
StInfo* collectStructInfo(const StructType *T);
|
|
334
|
+
/// Collect the array info
|
|
335
|
+
StInfo* collectArrayInfo(const ArrayType* T);
|
|
336
|
+
/// Collect simple type (non-aggregate) info
|
|
337
|
+
StInfo* collectSimpleTypeInfo(const Type* T);
|
|
338
|
+
|
|
339
|
+
std::vector<const Function*> getLLVMGlobalFunctions(const GlobalVariable* global);
|
|
340
|
+
|
|
341
|
+
void loadModules(const std::vector<std::string>& moduleNameVec);
|
|
342
|
+
void addSVFMain();
|
|
343
|
+
|
|
344
|
+
void createSVFDataStructure();
|
|
345
|
+
void initSVFFunction();
|
|
346
|
+
void initSVFBasicBlock(const Function* func);
|
|
347
|
+
void initDomTree(SVFFunction* func, const Function* f);
|
|
348
|
+
void setValueAttr(const Value* val, SVFValue* value);
|
|
349
|
+
void buildFunToFunMap();
|
|
350
|
+
void buildGlobalDefToRepMap();
|
|
351
|
+
/// Invoke llvm passes to modify module
|
|
352
|
+
void prePassSchedule();
|
|
353
|
+
bool preProcessed;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
} // End namespace SVF
|
|
357
|
+
|
|
358
|
+
#endif /* INCLUDE_SVF_FE_LLVMMODULE_H_ */
|