svf-lib 1.0.1277 → 1.0.1279

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.
Files changed (95) hide show
  1. package/SVF-linux/Release-build/lib/libSvf.a +0 -0
  2. package/SVF-linux/include/DDA/DDAVFSolver.h +1 -2
  3. package/SVF-linux/include/Graphs/ICFG.h +16 -16
  4. package/SVF-linux/include/Graphs/ICFGEdge.h +6 -6
  5. package/SVF-linux/include/Graphs/ICFGNode.h +16 -16
  6. package/SVF-linux/include/Graphs/IRGraph.h +6 -6
  7. package/SVF-linux/include/Graphs/ThreadCallGraph.h +2 -2
  8. package/SVF-linux/include/Graphs/VFGNode.h +1 -1
  9. package/SVF-linux/include/MSSA/MSSAMuChi.h +11 -11
  10. package/SVF-linux/include/MSSA/MemRegion.h +2 -2
  11. package/SVF-linux/include/MSSA/MemSSA.h +13 -13
  12. package/SVF-linux/include/MTA/FSMPTA.h +1 -1
  13. package/SVF-linux/include/MTA/LockAnalysis.h +33 -33
  14. package/SVF-linux/include/MTA/LockResultValidator.h +7 -6
  15. package/SVF-linux/include/MTA/MHP.h +46 -46
  16. package/SVF-linux/include/MTA/MTA.h +4 -4
  17. package/SVF-linux/include/MTA/MTAAnnotator.h +6 -4
  18. package/SVF-linux/include/MTA/MTAResultValidator.h +51 -44
  19. package/SVF-linux/include/MTA/PCG.h +22 -27
  20. package/SVF-linux/include/MTA/TCT.h +28 -37
  21. package/SVF-linux/include/MemoryModel/SVFStatements.h +11 -6
  22. package/SVF-linux/include/MemoryModel/SVFVariables.h +4 -4
  23. package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +13 -19
  24. package/SVF-linux/include/SABER/ProgSlice.h +5 -5
  25. package/SVF-linux/include/SABER/SaberCheckerAPI.h +4 -4
  26. package/SVF-linux/include/SABER/SaberCondAllocator.h +32 -35
  27. package/SVF-linux/include/SVF-FE/BasicTypes.h +10 -0
  28. package/SVF-linux/include/SVF-FE/CPPUtil.h +9 -8
  29. package/SVF-linux/include/SVF-FE/DCHG.h +4 -4
  30. package/SVF-linux/include/SVF-FE/DataFlowUtil.h +1 -1
  31. package/SVF-linux/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
  32. package/SVF-linux/include/SVF-FE/ICFGBuilder.h +9 -9
  33. package/SVF-linux/include/SVF-FE/IRAnnotator.h +9 -9
  34. package/SVF-linux/include/SVF-FE/LLVMModule.h +119 -22
  35. package/SVF-linux/include/SVF-FE/LLVMUtil.h +31 -52
  36. package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +14 -20
  37. package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +8 -8
  38. package/SVF-linux/include/Util/Annotator.h +22 -22
  39. package/SVF-linux/include/Util/BasicTypes.h +476 -72
  40. package/SVF-linux/include/Util/Casting.h +1 -1
  41. package/SVF-linux/include/Util/CxtStmt.h +13 -12
  42. package/SVF-linux/include/Util/SVFBasicTypes.h +0 -78
  43. package/SVF-linux/include/Util/SVFInstruction.h +40 -0
  44. package/SVF-linux/include/Util/SVFModule.h +58 -124
  45. package/SVF-linux/include/Util/SVFUtil.h +48 -39
  46. package/SVF-linux/include/Util/ThreadAPI.h +17 -28
  47. package/SVF-linux/include/WPA/WPAPass.h +4 -4
  48. package/SVF-osx/Release-build/lib/libSvf.a +0 -0
  49. package/SVF-osx/include/DDA/DDAVFSolver.h +1 -2
  50. package/SVF-osx/include/Graphs/ICFG.h +16 -16
  51. package/SVF-osx/include/Graphs/ICFGEdge.h +6 -6
  52. package/SVF-osx/include/Graphs/ICFGNode.h +16 -16
  53. package/SVF-osx/include/Graphs/IRGraph.h +6 -6
  54. package/SVF-osx/include/Graphs/ThreadCallGraph.h +2 -2
  55. package/SVF-osx/include/Graphs/VFGNode.h +1 -1
  56. package/SVF-osx/include/MSSA/MSSAMuChi.h +11 -11
  57. package/SVF-osx/include/MSSA/MemRegion.h +2 -2
  58. package/SVF-osx/include/MSSA/MemSSA.h +13 -13
  59. package/SVF-osx/include/MTA/FSMPTA.h +1 -1
  60. package/SVF-osx/include/MTA/LockAnalysis.h +33 -33
  61. package/SVF-osx/include/MTA/LockResultValidator.h +7 -6
  62. package/SVF-osx/include/MTA/MHP.h +46 -46
  63. package/SVF-osx/include/MTA/MTA.h +4 -4
  64. package/SVF-osx/include/MTA/MTAAnnotator.h +6 -4
  65. package/SVF-osx/include/MTA/MTAResultValidator.h +51 -44
  66. package/SVF-osx/include/MTA/PCG.h +22 -27
  67. package/SVF-osx/include/MTA/TCT.h +28 -37
  68. package/SVF-osx/include/MemoryModel/SVFStatements.h +11 -6
  69. package/SVF-osx/include/MemoryModel/SVFVariables.h +4 -4
  70. package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +13 -19
  71. package/SVF-osx/include/SABER/ProgSlice.h +5 -5
  72. package/SVF-osx/include/SABER/SaberCheckerAPI.h +4 -4
  73. package/SVF-osx/include/SABER/SaberCondAllocator.h +32 -35
  74. package/SVF-osx/include/SVF-FE/BasicTypes.h +10 -0
  75. package/SVF-osx/include/SVF-FE/CPPUtil.h +9 -8
  76. package/SVF-osx/include/SVF-FE/DCHG.h +4 -4
  77. package/SVF-osx/include/SVF-FE/DataFlowUtil.h +1 -1
  78. package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
  79. package/SVF-osx/include/SVF-FE/ICFGBuilder.h +9 -9
  80. package/SVF-osx/include/SVF-FE/IRAnnotator.h +9 -9
  81. package/SVF-osx/include/SVF-FE/LLVMModule.h +119 -22
  82. package/SVF-osx/include/SVF-FE/LLVMUtil.h +31 -52
  83. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +14 -20
  84. package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +8 -8
  85. package/SVF-osx/include/Util/Annotator.h +22 -22
  86. package/SVF-osx/include/Util/BasicTypes.h +476 -72
  87. package/SVF-osx/include/Util/Casting.h +1 -1
  88. package/SVF-osx/include/Util/CxtStmt.h +13 -12
  89. package/SVF-osx/include/Util/SVFBasicTypes.h +0 -78
  90. package/SVF-osx/include/Util/SVFInstruction.h +40 -0
  91. package/SVF-osx/include/Util/SVFModule.h +58 -124
  92. package/SVF-osx/include/Util/SVFUtil.h +48 -39
  93. package/SVF-osx/include/Util/ThreadAPI.h +17 -28
  94. package/SVF-osx/include/WPA/WPAPass.h +4 -4
  95. package/package.json +1 -1
@@ -47,8 +47,16 @@ public:
47
47
  typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
48
48
  typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
49
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
+
50
58
  private:
51
- static LLVMModuleSet *llvmModuleSet;
59
+ static LLVMModuleSet* llvmModuleSet;
52
60
  SVFModule* svfModule;
53
61
  std::unique_ptr<LLVMContext> cxts;
54
62
  std::vector<std::unique_ptr<Module>> owned_modules;
@@ -61,13 +69,21 @@ private:
61
69
  /// Global definition to a rep definition map
62
70
  GlobalDefToRepMapTy GlobalDefToRepMap;
63
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
+
64
80
  /// Constructor
65
81
  LLVMModuleSet(): svfModule(nullptr), cxts(nullptr), preProcessed(false) {}
66
82
 
67
83
  void build();
68
84
 
69
85
  public:
70
- static inline LLVMModuleSet *getLLVMModuleSet()
86
+ static inline LLVMModuleSet* getLLVMModuleSet()
71
87
  {
72
88
  if (llvmModuleSet == nullptr)
73
89
  llvmModuleSet = new LLVMModuleSet();
@@ -81,8 +97,8 @@ public:
81
97
  llvmModuleSet = nullptr;
82
98
  }
83
99
 
84
- SVFModule* buildSVFModule(Module &mod);
85
- SVFModule* buildSVFModule(const std::vector<std::string> &moduleNameVec);
100
+ SVFModule* buildSVFModule(Module& mod);
101
+ SVFModule* buildSVFModule(const std::vector<std::string>& moduleNameVec);
86
102
 
87
103
  inline SVFModule* getSVFModule()
88
104
  {
@@ -90,13 +106,18 @@ public:
90
106
  return svfModule;
91
107
  }
92
108
 
93
- void preProcessBCs(std::vector<std::string> &moduleNameVec);
109
+ void preProcessBCs(std::vector<std::string>& moduleNameVec);
94
110
 
95
111
  u32_t getModuleNum() const
96
112
  {
97
113
  return modules.size();
98
114
  }
99
115
 
116
+ const std::vector<std::reference_wrapper<Module>>& getLLVMModules() const
117
+ {
118
+ return modules;
119
+ }
120
+
100
121
  Module *getModule(u32_t idx) const
101
122
  {
102
123
  return &getModuleRef(idx);
@@ -111,19 +132,91 @@ public:
111
132
  // Dump modules to files
112
133
  void dumpModulesToFile(const std::string suffix);
113
134
 
114
- const SVFFunction *getSVFFunction(const Function *fun) const
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)
115
151
  {
116
- return svfModule->getSVFFunction(fun);
152
+ LLVMArgument2SVFArgument[arg] = svfArg;
153
+ setValueAttr(arg,svfArg);
117
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);
118
211
 
119
212
  /// Get the corresponding Function based on its name
120
- inline const SVFFunction *getSVFFunction(std::string name)
213
+ inline const SVFFunction* getSVFFunction(std::string name)
121
214
  {
122
- Function *fun = nullptr;
215
+ Function* fun = nullptr;
123
216
 
124
217
  for (u32_t i = 0; i < llvmModuleSet->getModuleNum(); ++i)
125
218
  {
126
- Module *mod = llvmModuleSet->getModule(i);
219
+ Module* mod = llvmModuleSet->getModule(i);
127
220
  fun = mod->getFunction(name);
128
221
  if (fun)
129
222
  {
@@ -133,14 +226,14 @@ public:
133
226
  return nullptr;
134
227
  }
135
228
 
136
- bool hasDefinition(const Function *fun) const
229
+ bool hasDefinition(const Function* fun) const
137
230
  {
138
231
  assert(fun->isDeclaration() && "not a function declaration?");
139
232
  FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
140
233
  return it != FunDeclToDefMap.end();
141
234
  }
142
235
 
143
- const Function *getDefinition(const Function *fun) const
236
+ const Function* getDefinition(const Function* fun) const
144
237
  {
145
238
  assert(fun->isDeclaration() && "not a function declaration?");
146
239
  FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
@@ -148,7 +241,7 @@ public:
148
241
  return it->second;
149
242
  }
150
243
 
151
- bool hasDeclaration(const Function *fun) const
244
+ bool hasDeclaration(const Function* fun) const
152
245
  {
153
246
  if(fun->isDeclaration() && !hasDefinition(fun))
154
247
  return false;
@@ -161,7 +254,7 @@ public:
161
254
  return it != FunDefToDeclsMap.end();
162
255
  }
163
256
 
164
- const FunctionSetType& getDeclaration(const Function *fun) const
257
+ const FunctionSetType& getDeclaration(const Function* fun) const
165
258
  {
166
259
  const Function* funDef = fun;
167
260
  if(fun->isDeclaration() && hasDefinition(fun))
@@ -173,13 +266,13 @@ public:
173
266
  }
174
267
 
175
268
  /// Global to rep
176
- bool hasGlobalRep(const GlobalVariable *val) const
269
+ bool hasGlobalRep(const GlobalVariable* val) const
177
270
  {
178
271
  GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
179
272
  return it != GlobalDefToRepMap.end();
180
273
  }
181
274
 
182
- GlobalVariable *getGlobalRep(const GlobalVariable *val) const
275
+ GlobalVariable *getGlobalRep(const GlobalVariable* val) const
183
276
  {
184
277
  GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
185
278
  assert(it != GlobalDefToRepMap.end() && "has no rep?");
@@ -187,7 +280,7 @@ public:
187
280
  }
188
281
 
189
282
 
190
- Module *getMainLLVMModule() const
283
+ Module* getMainLLVMModule() const
191
284
  {
192
285
  return getModule(0);
193
286
  }
@@ -204,12 +297,16 @@ public:
204
297
  }
205
298
 
206
299
  private:
207
- std::vector<const Function *> getLLVMGlobalFunctions(
208
- const GlobalVariable *global);
300
+ std::vector<const Function*> getLLVMGlobalFunctions(const GlobalVariable* global);
209
301
 
210
- void loadModules(const std::vector<std::string> &moduleNameVec);
302
+ void loadModules(const std::vector<std::string>& moduleNameVec);
211
303
  void addSVFMain();
212
- void initialize();
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);
213
310
  void buildFunToFunMap();
214
311
  void buildGlobalDefToRepMap();
215
312
  /// Invoke llvm passes to modify module
@@ -219,4 +316,4 @@ private:
219
316
 
220
317
  } // End namespace SVF
221
318
 
222
- #endif /* INCLUDE_SVF_FE_LLVMMODULE_H_ */
319
+ #endif /* INCLUDE_SVF_FE_LLVMMODULE_H_ */
@@ -45,13 +45,13 @@ namespace LLVMUtil
45
45
 
46
46
 
47
47
  /// Check whether this value is a black hole
48
- inline bool isBlackholeSym(const Value *val)
48
+ inline bool isBlackholeSym(const Value* val)
49
49
  {
50
50
  return (SVFUtil::isa<UndefValue>(val));
51
51
  }
52
52
 
53
53
  /// Check whether this value is a black hole
54
- inline bool isNullPtrSym(const Value *val)
54
+ inline bool isNullPtrSym(const Value* val)
55
55
  {
56
56
  if (const Constant* v = SVFUtil::dyn_cast<Constant>(val))
57
57
  {
@@ -61,14 +61,7 @@ inline bool isNullPtrSym(const Value *val)
61
61
  }
62
62
 
63
63
  /// Check whether this value points-to a constant object
64
- bool isConstantObjSym(const Value *val);
65
-
66
-
67
- /// Whether an instruction is a return instruction
68
- inline bool isReturn(const Instruction* inst)
69
- {
70
- return SVFUtil::isa<ReturnInst>(inst);
71
- }
64
+ bool isConstantObjSym(const Value* val);
72
65
 
73
66
  static inline Type *getPtrElementType(const PointerType* pty)
74
67
  {
@@ -89,7 +82,7 @@ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const CallSite cs)
89
82
  if (SVFUtil::isHeapAllocExtCallViaArg(cs))
90
83
  {
91
84
  int argPos = SVFUtil::getHeapAllocHoldingArgPosition(cs);
92
- const Value *arg = cs.getArgument(argPos);
85
+ const Value* arg = cs.getArgument(argPos);
93
86
  if (const PointerType *argType = SVFUtil::dyn_cast<PointerType>(arg->getType()))
94
87
  refType = SVFUtil::dyn_cast<PointerType>(getPtrElementType(argType));
95
88
  }
@@ -104,24 +97,24 @@ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const CallSite cs)
104
97
  return refType;
105
98
  }
106
99
 
107
- inline const PointerType *getRefTypeOfHeapAllocOrStatic(const Instruction *inst)
100
+ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const SVFInstruction* inst)
108
101
  {
109
- CallSite cs(const_cast<Instruction*>(inst));
102
+ CallSite cs(inst);
110
103
  return getRefTypeOfHeapAllocOrStatic(cs);
111
104
  }
112
105
  //@}
113
106
 
114
107
  /// Return true if this value refers to a object
115
- bool isObject (const Value * ref);
108
+ bool isObject (const Value* ref);
116
109
 
117
110
  /// Method for dead function, which does not have any possible caller
118
111
  /// function address is not taken and never be used in call or invoke instruction
119
112
  //@{
120
113
  /// whether this is a function without any possible caller?
121
- bool isUncalledFunction (const Function * fun);
114
+ bool isUncalledFunction (const Function* fun);
122
115
 
123
116
  /// whether this is an argument in dead function
124
- inline bool ArgInDeadFunction (const Value * val)
117
+ inline bool ArgInDeadFunction (const Value* val)
125
118
  {
126
119
  return SVFUtil::isa<Argument>(val)
127
120
  && isUncalledFunction(SVFUtil::cast<Argument>(val)->getParent());
@@ -129,13 +122,13 @@ inline bool ArgInDeadFunction (const Value * val)
129
122
  //@}
130
123
 
131
124
  /// Return true if this is an argument of a program entry function (e.g. main)
132
- inline bool ArgInProgEntryFunction (const Value * val)
125
+ inline bool ArgInProgEntryFunction (const Value* val)
133
126
  {
134
127
  return SVFUtil::isa<Argument>(val)
135
128
  && SVFUtil::isProgEntryFunction(SVFUtil::cast<Argument>(val)->getParent());
136
129
  }
137
130
  /// Return true if this is value in a dead function (function without any caller)
138
- bool isPtrInUncalledFunction (const Value * value);
131
+ bool isPtrInUncalledFunction (const Value* value);
139
132
  //@}
140
133
 
141
134
  //@}
@@ -143,13 +136,13 @@ bool isPtrInUncalledFunction (const Value * value);
143
136
  /// Function does not have any possible caller in the call graph
144
137
  //@{
145
138
  /// Return true if the function does not have a caller (either it is a main function or a dead function)
146
- inline bool isNoCallerFunction (const Function * fun)
139
+ inline bool isNoCallerFunction (const Function* fun)
147
140
  {
148
141
  return isUncalledFunction(fun) || SVFUtil::isProgEntryFunction(fun);
149
142
  }
150
143
 
151
144
  /// Return true if the argument in a function does not have a caller
152
- inline bool isArgOfUncalledFunction (const Value * val)
145
+ inline bool isArgOfUncalledFunction (const Value* val)
153
146
  {
154
147
  return SVFUtil::isa<Argument>(val)
155
148
  && isNoCallerFunction(SVFUtil::cast<Argument>(val)->getParent());
@@ -157,34 +150,26 @@ inline bool isArgOfUncalledFunction (const Value * val)
157
150
  //@}
158
151
 
159
152
  /// Return true if the function has a return instruction reachable from function entry
160
- bool functionDoesNotRet (const Function * fun);
153
+ bool functionDoesNotRet (const Function* fun);
161
154
 
162
155
  /// Get reachable basic block from function entry
163
- void getFunReachableBBs (const SVFFunction* svfFun, std::vector<const BasicBlock*>& bbs);
156
+ void getFunReachableBBs (const SVFFunction* svfFun, std::vector<const SVFBasicBlock*>& bbs);
164
157
 
165
- /// Get function exit basic block
166
- /// FIXME: this back() here is only valid when UnifyFunctionExitNodes pass is invoked
167
- inline const BasicBlock* getFunExitBB(const SVFFunction* svfFun)
168
- {
169
- const Function* fun = svfFun->getLLVMFun();
170
- assert(!SVFUtil::isExtCall(svfFun) && "The function cannot be an external call");
171
- return &fun->back();
172
- }
173
158
  /// Strip off the constant casts
174
- const Value * stripConstantCasts(const Value *val);
159
+ const Value* stripConstantCasts(const Value* val);
175
160
 
176
161
  /// Strip off the all casts
177
- const Value *stripAllCasts(const Value *val) ;
162
+ const Value* stripAllCasts(const Value* val) ;
178
163
 
179
164
  /// Get the type of the heap allocation
180
- const Type *getTypeOfHeapAlloc(const llvm::Instruction *inst) ;
165
+ const Type *getTypeOfHeapAlloc(const SVFInstruction* inst) ;
181
166
 
182
167
  /// Return the bitcast instruction which is val's only use site, otherwise return nullptr
183
168
  const Value* getUniqueUseViaCastInst(const Value* val);
184
169
 
185
170
  /// Return corresponding constant expression, otherwise return nullptr
186
171
  //@{
187
- inline const ConstantExpr *isGepConstantExpr(const Value *val)
172
+ inline const ConstantExpr *isGepConstantExpr(const Value* val)
188
173
  {
189
174
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
190
175
  {
@@ -194,7 +179,7 @@ inline const ConstantExpr *isGepConstantExpr(const Value *val)
194
179
  return nullptr;
195
180
  }
196
181
 
197
- inline const ConstantExpr *isInt2PtrConstantExpr(const Value *val)
182
+ inline const ConstantExpr *isInt2PtrConstantExpr(const Value* val)
198
183
  {
199
184
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
200
185
  {
@@ -204,7 +189,7 @@ inline const ConstantExpr *isInt2PtrConstantExpr(const Value *val)
204
189
  return nullptr;
205
190
  }
206
191
 
207
- inline const ConstantExpr *isPtr2IntConstantExpr(const Value *val)
192
+ inline const ConstantExpr *isPtr2IntConstantExpr(const Value* val)
208
193
  {
209
194
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
210
195
  {
@@ -214,7 +199,7 @@ inline const ConstantExpr *isPtr2IntConstantExpr(const Value *val)
214
199
  return nullptr;
215
200
  }
216
201
 
217
- inline const ConstantExpr *isCastConstantExpr(const Value *val)
202
+ inline const ConstantExpr *isCastConstantExpr(const Value* val)
218
203
  {
219
204
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
220
205
  {
@@ -224,7 +209,7 @@ inline const ConstantExpr *isCastConstantExpr(const Value *val)
224
209
  return nullptr;
225
210
  }
226
211
 
227
- inline const ConstantExpr *isSelectConstantExpr(const Value *val)
212
+ inline const ConstantExpr *isSelectConstantExpr(const Value* val)
228
213
  {
229
214
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
230
215
  {
@@ -234,7 +219,7 @@ inline const ConstantExpr *isSelectConstantExpr(const Value *val)
234
219
  return nullptr;
235
220
  }
236
221
 
237
- inline const ConstantExpr *isTruncConstantExpr(const Value *val)
222
+ inline const ConstantExpr *isTruncConstantExpr(const Value* val)
238
223
  {
239
224
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
240
225
  {
@@ -248,7 +233,7 @@ inline const ConstantExpr *isTruncConstantExpr(const Value *val)
248
233
  return nullptr;
249
234
  }
250
235
 
251
- inline const ConstantExpr *isCmpConstantExpr(const Value *val)
236
+ inline const ConstantExpr *isCmpConstantExpr(const Value* val)
252
237
  {
253
238
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
254
239
  {
@@ -258,7 +243,7 @@ inline const ConstantExpr *isCmpConstantExpr(const Value *val)
258
243
  return nullptr;
259
244
  }
260
245
 
261
- inline const ConstantExpr *isBinaryConstantExpr(const Value *val)
246
+ inline const ConstantExpr *isBinaryConstantExpr(const Value* val)
262
247
  {
263
248
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
264
249
  {
@@ -268,7 +253,7 @@ inline const ConstantExpr *isBinaryConstantExpr(const Value *val)
268
253
  return nullptr;
269
254
  }
270
255
 
271
- inline const ConstantExpr *isUnaryConstantExpr(const Value *val)
256
+ inline const ConstantExpr *isUnaryConstantExpr(const Value* val)
272
257
  {
273
258
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
274
259
  {
@@ -287,19 +272,13 @@ inline static DataLayout* getDataLayout(Module* mod)
287
272
  }
288
273
 
289
274
  /// Get the next instructions following control flow
290
- void getNextInsts(const Instruction* curInst, std::vector<const Instruction*>& instList);
275
+ void getNextInsts(const SVFInstruction* curInst, std::vector<const SVFInstruction*>& instList);
291
276
 
292
277
  /// Get the previous instructions following control flow
293
- void getPrevInsts(const Instruction* curInst, std::vector<const Instruction*>& instList);
294
-
295
- /// Get basic block successor position
296
- u32_t getBBSuccessorPos(const BasicBlock *BB, const BasicBlock *Succ);
297
- /// Get num of BB's successors
298
- u32_t getBBSuccessorNum(const BasicBlock *BB);
299
- /// Get basic block predecessor positin
300
- u32_t getBBPredecessorPos(const BasicBlock *BB, const BasicBlock *Pred);
278
+ void getPrevInsts(const SVFInstruction* curInst, std::vector<const SVFInstruction*>& instList);
279
+
301
280
  /// Get num of BB's predecessors
302
- u32_t getBBPredecessorNum(const BasicBlock *BB);
281
+ u32_t getBBPredecessorNum(const BasicBlock* BB);
303
282
 
304
283
 
305
284
 
@@ -83,7 +83,7 @@ public:
83
83
  /// Get different kinds of node
84
84
  //@{
85
85
  // GetValNode - Return the value node according to a LLVM Value.
86
- NodeID getValueNode(const Value *V)
86
+ NodeID getValueNode(const Value* V)
87
87
  {
88
88
  // first handle gep edge if val if a constant expression
89
89
  processCE(V);
@@ -93,7 +93,7 @@ public:
93
93
  }
94
94
 
95
95
  /// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
96
- inline NodeID getObjectNode(const Value *V)
96
+ inline NodeID getObjectNode(const Value* V)
97
97
  {
98
98
  return pag->getObjectNode(V);
99
99
  }
@@ -122,18 +122,9 @@ public:
122
122
  void visitStoreInst(StoreInst &I);
123
123
  void visitLoadInst(LoadInst &I);
124
124
  void visitGetElementPtrInst(GetElementPtrInst &I);
125
- void visitCallInst(CallInst &I)
126
- {
127
- visitCallSite(&I);
128
- }
129
- void visitInvokeInst(InvokeInst &II)
130
- {
131
- visitCallSite(&II);
132
- }
133
- void visitCallBrInst(CallBrInst &I)
134
- {
135
- return visitCallSite(&I);
136
- }
125
+ void visitCallInst(CallInst &I);
126
+ void visitInvokeInst(InvokeInst &II);
127
+ void visitCallBrInst(CallBrInst &I);
137
128
  void visitCallSite(CallSite cs);
138
129
  void visitReturnInst(ReturnInst &I);
139
130
  void visitCastInst(CastInst &I);
@@ -218,7 +209,7 @@ protected:
218
209
  //@}
219
210
 
220
211
  /// Process constant expression
221
- void processCE(const Value *val);
212
+ void processCE(const Value* val);
222
213
 
223
214
  /// Infer field index from byteoffset.
224
215
  u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, s32_t idx);
@@ -230,7 +221,7 @@ protected:
230
221
  const Value* getBaseValueForExtArg(const Value* V);
231
222
 
232
223
  /// Get the base type and max offset
233
- const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<LocationSet> &fields, const Value* sz);
224
+ const Type *getBaseTypeAndFlattenedFields(const Value* V, std::vector<LocationSet> &fields, const Value* sz);
234
225
 
235
226
  /// Handle direct call
236
227
  void handleDirectCall(CallSite cs, const SVFFunction *F);
@@ -242,7 +233,7 @@ protected:
242
233
  //@{
243
234
  virtual void parseOperations(std::vector<ExtAPI::Operation> &operations, CallSite cs);
244
235
  virtual void handleExtCall(CallSite cs, const SVFFunction *F);
245
- void addComplexConsForExt(Value *D, Value *S, const Value* sz);
236
+ void addComplexConsForExt(const Value* D, const Value* S, const Value* sz);
246
237
  //@}
247
238
 
248
239
  /// Set current basic block in order to keep track of control flow information
@@ -251,11 +242,11 @@ protected:
251
242
  curBB = bb;
252
243
  curVal = val;
253
244
  }
254
- inline const Value *getCurrentValue() const
245
+ inline const Value* getCurrentValue() const
255
246
  {
256
247
  return curVal;
257
248
  }
258
- inline const BasicBlock *getCurrentBB() const
249
+ inline const BasicBlock* getCurrentBB() const
259
250
  {
260
251
  return curBB;
261
252
  }
@@ -359,8 +350,11 @@ protected:
359
350
  inline void addStoreEdge(NodeID src, NodeID dst)
360
351
  {
361
352
  IntraICFGNode* node;
362
- if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(curVal))
353
+ if(const Instruction* i = SVFUtil::dyn_cast<Instruction>(curVal))
354
+ {
355
+ const SVFInstruction* inst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(i);
363
356
  node = pag->getICFG()->getIntraICFGNode(inst);
357
+ }
364
358
  else
365
359
  node = nullptr;
366
360
  if(StoreStmt *edge = pag->addStoreStmt(src, dst, node))
@@ -56,30 +56,30 @@ public:
56
56
 
57
57
  /// collect the syms
58
58
  //@{
59
- void collectNullPtrBlackholeSyms(const Value *val);
59
+ void collectNullPtrBlackholeSyms(const Value* val);
60
60
 
61
61
  void collectSpecialSym(const Value* val);
62
62
 
63
- void collectSym(const Value *val);
63
+ void collectSym(const Value* val);
64
64
 
65
- void collectVal(const Value *val);
65
+ void collectVal(const Value* val);
66
66
 
67
- void collectObj(const Value *val);
67
+ void collectObj(const Value* val);
68
68
 
69
- void collectRet(const Function *val);
69
+ void collectRet(const Function* val);
70
70
 
71
- void collectVararg(const Function *val);
71
+ void collectVararg(const Function* val);
72
72
  //@}
73
73
 
74
74
  /// Handle constant expression
75
75
  // @{
76
76
  void handleGlobalCE(const GlobalVariable *G);
77
77
  void handleGlobalInitializerCE(const Constant *C);
78
- void handleCE(const Value *val);
78
+ void handleCE(const Value* val);
79
79
  // @}
80
80
 
81
81
  /// Create an objectInfo based on LLVM value
82
- ObjTypeInfo* createObjTypeInfo(const Value *val);
82
+ ObjTypeInfo* createObjTypeInfo(const Value* val);
83
83
 
84
84
  /// Initialize TypeInfo based on LLVM Value
85
85
  void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value);