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
@@ -61,9 +61,11 @@ typedef llvm::StructType StructType;
61
61
  typedef llvm::ArrayType ArrayType;
62
62
  typedef llvm::PointerType PointerType;
63
63
  typedef llvm::FunctionType FunctionType;
64
+ typedef llvm::IntegerType IntegerType;
64
65
 
65
66
  /// LLVM Aliases and constants
66
67
  typedef llvm::Argument Argument;
68
+ typedef llvm::ConstantData ConstantData;
67
69
  typedef llvm::ConstantInt ConstantInt;
68
70
  typedef llvm::ConstantPointerNull ConstantPointerNull;
69
71
  typedef llvm::GlobalAlias GlobalAlias;
@@ -72,51 +74,187 @@ typedef llvm::GlobalAlias GlobalAlias;
72
74
  typedef llvm::NamedMDNode NamedMDNode;
73
75
  typedef llvm::MDNode MDNode;
74
76
 
75
- /// LLVM Instructions
76
- typedef llvm::CallInst CallInst;
77
- typedef llvm::StoreInst StoreInst;
78
- typedef llvm::LoadInst LoadInst;
79
-
80
-
81
- /// LLVM Iterators
82
- #if LLVM_VERSION_MAJOR >= 11
83
- typedef llvm::const_succ_iterator succ_const_iterator;
84
- #else
85
- typedef llvm::succ_const_iterator succ_const_iterator;
86
- #endif
87
77
  typedef llvm::GraphPrinter GraphPrinter;
88
- typedef llvm::IntegerType IntegerType;
89
78
 
90
79
  // LLVM Debug Information
91
80
  typedef llvm::DISubprogram DISubprogram;
92
81
 
82
+
83
+ class SVFInstruction;
84
+ class SVFBasicBlock;
85
+ class SVFArgument;
86
+
87
+ class SVFValue
88
+ {
89
+
90
+ public:
91
+ typedef s64_t GNodeK;
92
+
93
+ enum SVFValKind
94
+ {
95
+ SVFVal,
96
+ SVFFunc,
97
+ SVFBB,
98
+ SVFInst,
99
+ SVFCall,
100
+ SVFGlob,
101
+ SVFArg,
102
+ SVFConstData,
103
+ SVFOther
104
+ };
105
+
106
+ private:
107
+ const Value* value;
108
+ const Type* type;
109
+ GNodeK kind; ///< Type of this SVFValue
110
+ bool ptrInUncalledFun;
111
+ bool blackHoleSym;
112
+ bool nullptrSym;
113
+ bool isPtr;
114
+ const Type* ptrElementType;
115
+ protected:
116
+ std::string name;
117
+
118
+ /// Constructor
119
+ SVFValue(const Value* val, SVFValKind k): value(val), type(val->getType()), kind(k),
120
+ ptrInUncalledFun(false), blackHoleSym(false), nullptrSym(false), isPtr(val->getType()->isPointerTy()),
121
+ ptrElementType(nullptr),name(val->getName())
122
+ {
123
+ }
124
+
125
+ public:
126
+ SVFValue(void) = delete;
127
+ virtual ~SVFValue() = default;
128
+
129
+ /// Get the type of this SVFValue
130
+ inline GNodeK getKind() const
131
+ {
132
+ return kind;
133
+ }
134
+
135
+ /// Add the hash function for std::set (we also can overload operator< to implement this)
136
+ // and duplicated elements in the set are not inserted (binary tree comparison)
137
+ //@{
138
+ bool operator()(const SVFValue* lhs, const SVFValue* rhs) const
139
+ {
140
+ return lhs->value < rhs->value;
141
+ }
142
+
143
+ inline bool operator==(SVFValue* rhs) const
144
+ {
145
+ return value == rhs->value;
146
+ }
147
+
148
+ inline bool operator!=(SVFValue* rhs) const
149
+ {
150
+ return value != rhs->value;
151
+ }
152
+ //@}
153
+
154
+ inline const std::string getName() const
155
+ {
156
+ return name;
157
+ }
158
+
159
+ inline const Value* getLLVMValue() const
160
+ {
161
+ return value;
162
+ }
163
+
164
+ inline const Type* getType() const
165
+ {
166
+ return type;
167
+ }
168
+
169
+ inline void setPtrInUncalledFunction()
170
+ {
171
+ ptrInUncalledFun = true;
172
+ }
173
+
174
+ inline bool ptrInUncalledFunction() const
175
+ {
176
+ return ptrInUncalledFun;
177
+ }
178
+ inline void setBlackhole()
179
+ {
180
+ blackHoleSym = true;
181
+ }
182
+ inline bool isblackHole() const
183
+ {
184
+ return blackHoleSym;
185
+ }
186
+ inline void setNullPtr()
187
+ {
188
+ nullptrSym = true;
189
+ }
190
+ inline bool isNullPtr() const
191
+ {
192
+ return nullptrSym;
193
+ }
194
+ inline const Type* getPtrElementType() const
195
+ {
196
+ assert(isPtr && "value is not a pointer?");
197
+ return ptrElementType;
198
+ }
199
+ inline void setPtrElementType(const Type* t)
200
+ {
201
+ assert(isPtr && "value is not a pointer?");
202
+ ptrElementType = t;
203
+ }
204
+ /// Overloading operator << for dumping ICFG node ID
205
+ //@{
206
+ friend OutStream& operator<< (OutStream &o, const SVFValue &node)
207
+ {
208
+ o << node.getName();
209
+ return o;
210
+ }
211
+ //@}
212
+
213
+ static inline bool classof(const SVFValue *node)
214
+ {
215
+ return node->getKind() == SVFValue::SVFVal ||
216
+ node->getKind() == SVFValue::SVFFunc ||
217
+ node->getKind() == SVFValue::SVFGlob ||
218
+ node->getKind() == SVFValue::SVFBB ||
219
+ node->getKind() == SVFValue::SVFInst;
220
+ }
221
+ };
222
+
93
223
  class SVFFunction : public SVFValue
94
224
  {
225
+
226
+ public:
227
+ typedef std::vector<const SVFBasicBlock*>::const_iterator const_iterator;
228
+
95
229
  private:
96
230
  bool isDecl;
97
231
  bool isIntri;
98
- Function* fun;
99
- BasicBlock* exitBB;
100
- std::vector<const BasicBlock*> reachableBBs;
232
+ const Function* fun;
233
+ const SVFBasicBlock* exitBB;
234
+ std::vector<const SVFBasicBlock*> reachableBBs;
235
+ std::vector<const SVFBasicBlock*> allBBs;
236
+ std::vector<const SVFArgument*> allArgs;
237
+
101
238
  bool isUncalled;
102
239
  bool isNotRet;
103
- Map<const BasicBlock*,Set<const BasicBlock*>> dtBBsMap;
104
- Map<const BasicBlock*,Set<const BasicBlock*>> dfBBsMap;
105
- Map<const BasicBlock*,Set<const BasicBlock*>> pdtBBsMap;
106
- Map<const BasicBlock*,std::vector<const BasicBlock*>> bb2LoopMap;
240
+ bool varArg;
241
+ Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>> dtBBsMap;
242
+ Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>> dfBBsMap;
243
+ Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>> pdtBBsMap;
244
+ Map<const SVFBasicBlock*,std::vector<const SVFBasicBlock*>> bb2LoopMap;
245
+
107
246
  public:
108
247
 
109
- SVFFunction(Function* f): SVFValue(f->getName().str(),SVFValue::SVFFunc),
110
- isDecl(f->isDeclaration()), isIntri(f->isIntrinsic()), fun(f), exitBB(nullptr), isUncalled(false), isNotRet(false)
111
- {
112
- }
248
+ SVFFunction(const Function* f);
249
+ SVFFunction(void) = delete;
250
+ virtual ~SVFFunction();
113
251
 
114
- SVFFunction(Function* f, BasicBlock* exitBB, std::vector<const BasicBlock*> reachableBBs): SVFValue(f->getName().str(),SVFValue::SVFFunc),
115
- isDecl(f->isDeclaration()), isIntri(f->isIntrinsic()), fun(f), exitBB(exitBB), reachableBBs(reachableBBs), isUncalled(false), isNotRet(false)
252
+ static inline bool classof(const SVFValue *node)
116
253
  {
254
+ return node->getKind() == SVFFunc;
117
255
  }
118
256
 
119
- inline Function* getLLVMFun() const
257
+ inline const Function* getLLVMFun() const
120
258
  {
121
259
  assert(fun && "no LLVM Function found!");
122
260
  return fun;
@@ -132,22 +270,41 @@ public:
132
270
  return isIntri;
133
271
  }
134
272
 
135
- inline u32_t arg_size() const
273
+ u32_t arg_size() const;
274
+ const SVFArgument* getArg(u32_t idx) const;
275
+ bool isVarArg() const;
276
+
277
+ inline void addBasicBlock(const SVFBasicBlock* bb)
278
+ {
279
+ allBBs.push_back(bb);
280
+ }
281
+
282
+ inline void addArgument(SVFArgument* arg)
283
+ {
284
+ allArgs.push_back(arg);
285
+ }
286
+
287
+ inline const SVFBasicBlock* getEntryBlock() const
288
+ {
289
+ return allBBs.front();
290
+ }
291
+
292
+ inline const_iterator begin() const
136
293
  {
137
- return getLLVMFun()->arg_size();
294
+ return allBBs.begin();
138
295
  }
139
296
 
140
- const Value* getArg(u32_t idx) const
297
+ inline const_iterator end() const
141
298
  {
142
- return getLLVMFun()->getArg(idx);
299
+ return allBBs.end();
143
300
  }
144
301
 
145
- inline bool isVarArg() const
302
+ inline const std::vector<const SVFBasicBlock*>& getBasicBlockList() const
146
303
  {
147
- return getLLVMFun()->isVarArg();
304
+ return allBBs;
148
305
  }
149
306
 
150
- inline const std::vector<const BasicBlock*>& getReachableBBs() const
307
+ inline const std::vector<const SVFBasicBlock*>& getReachableBBs() const
151
308
  {
152
309
  return reachableBBs;
153
310
  }
@@ -157,69 +314,69 @@ public:
157
314
  return isUncalled;
158
315
  }
159
316
 
160
- inline const void setIsUncalledFunction(const bool isUncalledFunction)
317
+ inline const void setIsUncalledFunction(bool isUncalledFunction)
161
318
  {
162
319
  this->isUncalled = isUncalledFunction;
163
320
  }
164
321
 
165
- inline const void setIsNotRet(const bool doesNotRet)
322
+ inline const void setIsNotRet(bool doesNotRet)
166
323
  {
167
324
  this->isNotRet = doesNotRet;
168
325
  }
169
326
 
170
- inline const void setExitBB(BasicBlock* exitBB)
327
+ inline const void setExitBB(const SVFBasicBlock* exitBB)
171
328
  {
172
329
  this->exitBB = exitBB;
173
330
  }
174
331
 
175
- inline const void setReachableBBs(std::vector<const BasicBlock*> reachableBBs)
332
+ inline const void setReachableBBs(std::vector<const SVFBasicBlock*> reachableBBs)
176
333
  {
177
334
  this->reachableBBs = reachableBBs;
178
335
  }
179
336
 
180
- inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getDomFrontierMap() const
337
+ inline const Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>>& getDomFrontierMap() const
181
338
  {
182
339
  return dfBBsMap;
183
340
  }
184
341
 
185
- inline Map<const BasicBlock*,Set<const BasicBlock*>>& getDomFrontierMap()
342
+ inline Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>>& getDomFrontierMap()
186
343
  {
187
344
  return dfBBsMap;
188
345
  }
189
346
 
190
- inline bool hasLoopInfo(const BasicBlock* bb) const
347
+ inline bool hasLoopInfo(const SVFBasicBlock* bb) const
191
348
  {
192
349
  return bb2LoopMap.find(bb)!=bb2LoopMap.end();
193
350
  }
194
351
 
195
- const std::vector<const BasicBlock*>& getLoopInfo(const BasicBlock* bb) const;
352
+ const std::vector<const SVFBasicBlock*>& getLoopInfo(const SVFBasicBlock* bb) const;
196
353
 
197
- inline void addToBB2LoopMap(const BasicBlock* bb, const BasicBlock* loopBB)
354
+ inline void addToBB2LoopMap(const SVFBasicBlock* bb, const SVFBasicBlock* loopBB)
198
355
  {
199
356
  bb2LoopMap[bb].push_back(loopBB);
200
357
  }
201
358
 
202
- inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getPostDomTreeMap() const
359
+ inline const Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>>& getPostDomTreeMap() const
203
360
  {
204
361
  return pdtBBsMap;
205
362
  }
206
363
 
207
- inline Map<const BasicBlock*,Set<const BasicBlock*>>& getPostDomTreeMap()
364
+ inline Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>>& getPostDomTreeMap()
208
365
  {
209
366
  return pdtBBsMap;
210
367
  }
211
368
 
212
- inline Map<const BasicBlock*,Set<const BasicBlock*>>& getDomTreeMap()
369
+ inline Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>>& getDomTreeMap()
213
370
  {
214
371
  return dtBBsMap;
215
372
  }
216
373
 
217
- inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getDomTreeMap() const
374
+ inline const Map<const SVFBasicBlock*,Set<const SVFBasicBlock*>>& getDomTreeMap() const
218
375
  {
219
376
  return dtBBsMap;
220
377
  }
221
378
 
222
- inline bool isUnreachable(const BasicBlock* bb) const
379
+ inline bool isUnreachable(const SVFBasicBlock* bb) const
223
380
  {
224
381
  return std::find(reachableBBs.begin(), reachableBBs.end(), bb)==reachableBBs.end();
225
382
  }
@@ -229,18 +386,18 @@ public:
229
386
  return isNotRet;
230
387
  }
231
388
 
232
- inline const BasicBlock* getExitBB() const
389
+ inline const SVFBasicBlock* getExitBB() const
233
390
  {
234
391
  return this->exitBB;
235
392
  }
236
393
 
237
- void getExitBlocksOfLoop(const BasicBlock* bb, Set<const BasicBlock*>& exitbbs) const;
394
+ void getExitBlocksOfLoop(const SVFBasicBlock* bb, Set<const SVFBasicBlock*>& exitbbs) const;
238
395
 
239
- bool isLoopHeader(const BasicBlock* bb) const;
396
+ bool isLoopHeader(const SVFBasicBlock* bb) const;
240
397
 
241
- bool dominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const;
398
+ bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
242
399
 
243
- bool postDominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const;
400
+ bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
244
401
 
245
402
  // Dump Control Flow Graph of llvm function, with instructions
246
403
  void viewCFG();
@@ -250,47 +407,294 @@ public:
250
407
 
251
408
  };
252
409
 
253
- class SVFGlobal : public SVFValue
410
+ class SVFBasicBlock : public SVFValue
254
411
  {
255
412
 
256
413
  public:
257
- SVFGlobal(const std::string& val): SVFValue(val,SVFValue::SVFGlob)
414
+ typedef std::vector<const SVFInstruction*>::const_iterator const_iterator;
415
+
416
+ private:
417
+ std::vector<const SVFInstruction*> allInsts;
418
+ std::vector<const SVFBasicBlock*> succBBs;
419
+ std::vector<const SVFBasicBlock*> predBBs;
420
+ const BasicBlock* bb;
421
+ const SVFFunction* fun;
422
+ public:
423
+ SVFBasicBlock(const BasicBlock* b, const SVFFunction* f);
424
+ SVFBasicBlock(void) = delete;
425
+ virtual ~SVFBasicBlock();
426
+
427
+ static inline bool classof(const SVFValue *node)
428
+ {
429
+ return node->getKind() == SVFBB;
430
+ }
431
+
432
+ inline void addInstruction(const SVFInstruction* inst)
433
+ {
434
+ allInsts.push_back(inst);
435
+ }
436
+
437
+ inline const std::vector<const SVFInstruction*>& getInstructionList() const
438
+ {
439
+ return allInsts;
440
+ }
441
+
442
+ inline const_iterator begin() const
443
+ {
444
+ return allInsts.begin();
445
+ }
446
+
447
+ inline const_iterator end() const
448
+ {
449
+ return allInsts.end();
450
+ }
451
+
452
+ inline const SVFFunction* getParent() const
453
+ {
454
+ return fun;
455
+ }
456
+
457
+ inline const SVFInstruction* front() const
458
+ {
459
+ return allInsts.front();
460
+ }
461
+
462
+ inline const SVFInstruction* back() const
463
+ {
464
+ return allInsts.back();
465
+ }
466
+
467
+ inline void addSuccBasicBlock(const SVFBasicBlock* succ)
258
468
  {
469
+ succBBs.push_back(succ);
259
470
  }
260
471
 
472
+ inline void addPredBasicBlock(const SVFBasicBlock* pred)
473
+ {
474
+ predBBs.push_back(pred);
475
+ }
476
+
477
+ inline const std::vector<const SVFBasicBlock*>& getSuccessors() const
478
+ {
479
+ return succBBs;
480
+ }
481
+
482
+ inline const std::vector<const SVFBasicBlock*>& getPredecessors() const
483
+ {
484
+ return predBBs;
485
+ }
486
+ u32_t getNumSuccessors() const
487
+ {
488
+ return succBBs.size();
489
+ }
490
+ u32_t getBBSuccessorPos(const SVFBasicBlock* succbb);
491
+ u32_t getBBSuccessorPos(const SVFBasicBlock* succbb) const;
492
+ u32_t getBBPredecessorPos(const SVFBasicBlock* succbb);
493
+ u32_t getBBPredecessorPos(const SVFBasicBlock* succbb) const;
494
+
495
+ inline const BasicBlock* getLLVMBasicBlock() const
496
+ {
497
+ return bb;
498
+ }
261
499
  };
262
500
 
263
- class SVFBasicBlock : public SVFValue
501
+ class SVFInstruction : public SVFValue
502
+ {
503
+
504
+ private:
505
+ const Instruction* inst;
506
+ const SVFBasicBlock* bb;
507
+ const SVFFunction* fun;
508
+ bool terminator;
509
+ bool ret;
510
+ public:
511
+ SVFInstruction(const Instruction* i, const SVFBasicBlock* b, bool isRet);
512
+ SVFInstruction(const Instruction* i) = delete;
513
+ SVFInstruction(void) = delete;
514
+
515
+ inline const Instruction* getLLVMInstruction() const
516
+ {
517
+ return inst;
518
+ }
519
+
520
+ static inline bool classof(const SVFValue *node)
521
+ {
522
+ return node->getKind() == SVFInst || node->getKind() == SVFCall;
523
+ }
524
+
525
+ inline const SVFBasicBlock* getParent() const
526
+ {
527
+ return bb;
528
+ }
529
+
530
+ inline const SVFFunction* getFunction() const
531
+ {
532
+ return fun;
533
+ }
534
+
535
+ inline bool isTerminator() const
536
+ {
537
+ return terminator;
538
+ }
539
+
540
+ inline bool isRetInst() const
541
+ {
542
+ return ret;
543
+ }
544
+ };
545
+
546
+ class SVFCallInst : public SVFInstruction
547
+ {
548
+ private:
549
+ std::vector<const SVFValue*> args;
550
+
551
+ public:
552
+ SVFCallInst(const CallBase* i, const SVFBasicBlock* b) : SVFInstruction(i,b,false)
553
+ {
554
+ }
555
+ SVFCallInst(const Instruction* i) = delete;
556
+ SVFCallInst(const CallBase* i) = delete;
557
+ SVFCallInst(void) = delete;
558
+
559
+ static inline bool classof(const SVFValue *node)
560
+ {
561
+ return node->getKind() == SVFCall;
562
+ }
563
+ static inline bool classof(const SVFInstruction *node)
564
+ {
565
+ return node->getKind() == SVFCall;
566
+ }
567
+ inline void addArgument(const SVFValue* a)
568
+ {
569
+ args.push_back(a);
570
+ }
571
+ };
572
+
573
+ class SVFGlobalValue : public SVFValue
574
+ {
575
+ private:
576
+ const GlobalValue* gv;
577
+ public:
578
+ SVFGlobalValue(const GlobalValue* _gv): SVFValue(_gv, SVFValue::SVFGlob), gv(_gv)
579
+ {
580
+ }
581
+ SVFGlobalValue() = delete;
582
+
583
+ const GlobalValue* getLLVMGlobalValue() const
584
+ {
585
+ return gv;
586
+ }
587
+
588
+ static inline bool classof(const SVFValue *node)
589
+ {
590
+ return node->getKind() == SVFGlob;
591
+ }
592
+ };
593
+
594
+ class SVFArgument : public SVFValue
264
595
  {
596
+ private:
597
+ const SVFFunction* fun;
598
+ const Argument* arg;
599
+ u32_t argNo;
600
+ bool uncalled;
601
+ public:
602
+ SVFArgument(const Argument* _arg, const SVFFunction* _fun, bool _uncalled): SVFValue(_arg, SVFValue::SVFArg), fun(_fun), arg(_arg), argNo(_arg->getArgNo()), uncalled(_uncalled)
603
+ {
604
+ }
605
+ SVFArgument() = delete;
606
+
607
+ const Argument* getLLVMArgument() const
608
+ {
609
+ return arg;
610
+ }
611
+
612
+ inline const SVFFunction* getParent() const
613
+ {
614
+ return fun;
615
+ }
616
+
617
+ /// Return the index of this formal argument in its containing function.
618
+ /// For example in "void foo(int a, float b)" a is 0 and b is 1.
619
+ inline u32_t getArgNo() const
620
+ {
621
+ return argNo;
622
+ }
623
+
624
+ inline bool isArgOfUncalledFunction() const
625
+ {
626
+ return uncalled;
627
+ }
628
+
629
+ static inline bool classof(const SVFValue *node)
630
+ {
631
+ return node->getKind() == SVFArg;
632
+ }
633
+ };
634
+
635
+
636
+ class SVFConstantData : public SVFValue
637
+ {
638
+ private:
639
+ const ConstantData* constData;
265
640
 
266
641
  public:
267
- SVFBasicBlock(const std::string& val): SVFValue(val,SVFValue::SVFBB)
642
+ SVFConstantData(const ConstantData* _const): SVFValue(_const, SVFValue::SVFConstData), constData(_const)
268
643
  {
269
644
  }
645
+ SVFConstantData() = delete;
270
646
 
647
+ const ConstantData* getLLVMConstantData() const
648
+ {
649
+ return constData;
650
+ }
651
+
652
+ static inline bool classof(const SVFValue *node)
653
+ {
654
+ return node->getKind() == SVFConstData;
655
+ }
271
656
  };
272
657
 
658
+
659
+ class SVFOtherValue : public SVFValue
660
+ {
661
+ public:
662
+ SVFOtherValue(const Value* other): SVFValue(other, SVFValue::SVFOther)
663
+ {
664
+ }
665
+ SVFOtherValue() = delete;
666
+
667
+ static inline bool classof(const SVFValue *node)
668
+ {
669
+ return node->getKind() == SVFOther;
670
+ }
671
+ };
672
+
673
+
273
674
  class CallSite
274
675
  {
275
676
  private:
276
- CallBase *CB;
677
+ const CallBase *CB;
678
+ const SVFInstruction* inst;
277
679
  public:
278
- CallSite(Instruction *I) : CB(SVFUtil::dyn_cast<CallBase>(I)) {}
279
- CallSite(Value *I) : CB(SVFUtil::dyn_cast<CallBase>(I)) {}
680
+ CallSite(const SVFInstruction *I) : CB(SVFUtil::dyn_cast<CallBase>(I->getLLVMInstruction())), inst(I)
681
+ {
682
+ assert(CB && "not a callsite?");
683
+ }
280
684
 
281
- CallBase *getInstruction() const
685
+ const SVFInstruction* getInstruction() const
282
686
  {
283
- return CB;
687
+ return inst;
284
688
  }
285
- Value *getArgument(unsigned ArgNo) const
689
+ const Value* getArgument(u32_t ArgNo) const
286
690
  {
287
691
  return CB->getArgOperand(ArgNo);
288
692
  }
289
- Type *getType() const
693
+ Type* getType() const
290
694
  {
291
695
  return CB->getType();
292
696
  }
293
- unsigned arg_size() const
697
+ u32_t arg_size() const
294
698
  {
295
699
  return CB->arg_size();
296
700
  }
@@ -298,27 +702,27 @@ public:
298
702
  {
299
703
  return CB->arg_empty();
300
704
  }
301
- Value *getArgOperand(unsigned i) const
705
+ const Value* getArgOperand(u32_t i) const
302
706
  {
303
707
  return CB->getArgOperand(i);
304
708
  }
305
- unsigned getNumArgOperands() const
709
+ u32_t getNumArgOperands() const
306
710
  {
307
711
  return CB->arg_size();
308
712
  }
309
- Function *getCalledFunction() const
713
+ const Function* getCalledFunction() const
310
714
  {
311
715
  return CB->getCalledFunction();
312
716
  }
313
- Value *getCalledValue() const
717
+ const Value* getCalledValue() const
314
718
  {
315
719
  return CB->getCalledOperand();
316
720
  }
317
- Function *getCaller() const
721
+ const Function* getCaller() const
318
722
  {
319
723
  return CB->getCaller();
320
724
  }
321
- FunctionType *getFunctionType() const
725
+ const FunctionType* getFunctionType() const
322
726
  {
323
727
  return CB->getFunctionType();
324
728
  }
@@ -356,7 +760,7 @@ template <> struct std::hash<SVF::CallSite>
356
760
  {
357
761
  size_t operator()(const SVF::CallSite &cs) const
358
762
  {
359
- std::hash<SVF::Instruction *> h;
763
+ std::hash<const SVF::SVFInstruction *> h;
360
764
  return h(cs.getInstruction());
361
765
  }
362
766
  };