svf-lib 1.0.1362 → 1.0.1364

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 (41) hide show
  1. package/SVF-linux/Release-build/lib/libSvf.a +0 -0
  2. package/SVF-linux/include/MTA/MTA.h +1 -0
  3. package/SVF-linux/include/MTA/MTAStat.h +1 -0
  4. package/SVF-linux/include/MemoryModel/PersistentPointsToCache.h +1 -0
  5. package/SVF-linux/include/SVF-LLVM/DCHG.h +2 -1
  6. package/SVF-linux/include/SVF-LLVM/LLVMLoopAnalysis.h +1 -0
  7. package/SVF-linux/include/SVF-LLVM/LLVMModule.h +2 -2
  8. package/SVF-linux/include/SVF-LLVM/LLVMUtil.h +135 -79
  9. package/SVF-linux/include/SVF-LLVM/SVFIRBuilder.h +1 -0
  10. package/SVF-linux/include/SVFIR/PAGBuilderFromFile.h +3 -3
  11. package/SVF-linux/include/SVFIR/SVFIR.h +3 -3
  12. package/SVF-linux/include/SVFIR/SVFModule.h +3 -3
  13. package/SVF-linux/include/SVFIR/SVFStatements.h +3 -3
  14. package/SVF-linux/include/SVFIR/SVFType.h +120 -103
  15. package/SVF-linux/include/SVFIR/SVFValue.h +3 -3
  16. package/SVF-linux/include/SVFIR/SVFVariables.h +3 -3
  17. package/SVF-linux/include/SVFIR/SymbolTableInfo.h +3 -3
  18. package/SVF-linux/include/Util/Annotator.h +8 -17
  19. package/SVF-linux/include/Util/CppUtil.h +81 -0
  20. package/SVF-linux/include/Util/SVFUtil.h +3 -9
  21. package/SVF-osx/Release-build/lib/libSvf.a +0 -0
  22. package/SVF-osx/include/MTA/MTA.h +1 -0
  23. package/SVF-osx/include/MTA/MTAStat.h +1 -0
  24. package/SVF-osx/include/MemoryModel/PersistentPointsToCache.h +1 -0
  25. package/SVF-osx/include/SVF-LLVM/DCHG.h +2 -1
  26. package/SVF-osx/include/SVF-LLVM/LLVMLoopAnalysis.h +1 -0
  27. package/SVF-osx/include/SVF-LLVM/LLVMModule.h +2 -2
  28. package/SVF-osx/include/SVF-LLVM/LLVMUtil.h +135 -79
  29. package/SVF-osx/include/SVF-LLVM/SVFIRBuilder.h +1 -0
  30. package/SVF-osx/include/SVFIR/PAGBuilderFromFile.h +3 -3
  31. package/SVF-osx/include/SVFIR/SVFIR.h +3 -3
  32. package/SVF-osx/include/SVFIR/SVFModule.h +3 -3
  33. package/SVF-osx/include/SVFIR/SVFStatements.h +3 -3
  34. package/SVF-osx/include/SVFIR/SVFType.h +120 -103
  35. package/SVF-osx/include/SVFIR/SVFValue.h +3 -3
  36. package/SVF-osx/include/SVFIR/SVFVariables.h +3 -3
  37. package/SVF-osx/include/SVFIR/SymbolTableInfo.h +3 -3
  38. package/SVF-osx/include/Util/Annotator.h +8 -17
  39. package/SVF-osx/include/Util/CppUtil.h +81 -0
  40. package/SVF-osx/include/Util/SVFUtil.h +3 -9
  41. package/package.json +1 -1
@@ -36,6 +36,7 @@
36
36
 
37
37
  #include <set>
38
38
  #include <vector>
39
+ #include "SVF-LLVM/BasicTypes.h"
39
40
  #include "SVFIR/SVFValue.h"
40
41
 
41
42
  namespace SVF
@@ -31,6 +31,7 @@
31
31
  #define MTASTAT_H_
32
32
 
33
33
  #include "Util/PTAStat.h"
34
+ #include "SVF-LLVM/BasicTypes.h"
34
35
 
35
36
  namespace SVF
36
37
  {
@@ -17,6 +17,7 @@
17
17
  #include <iomanip>
18
18
  #include <iostream>
19
19
  #include <vector>
20
+ #include <functional>
20
21
 
21
22
  #include "SVFIR/SVFType.h"
22
23
 
@@ -16,7 +16,8 @@
16
16
 
17
17
  #include "Graphs/GenericGraph.h"
18
18
  #include "Graphs/CHG.h"
19
- #include "SVF-LLVM/CPPUtil.h"
19
+ #include "Util/CppUtil.h"
20
+ #include "SVF-LLVM/BasicTypes.h"
20
21
  #include "SVFIR/SVFModule.h"
21
22
  #include "Util/SVFUtil.h"
22
23
  #include "Util/WorkList.h"
@@ -32,6 +32,7 @@
32
32
 
33
33
  #include "SVFIR/SVFIR.h"
34
34
  #include "MemoryModel/SVFLoop.h"
35
+ #include "SVF-LLVM/BasicTypes.h"
35
36
 
36
37
  namespace SVF
37
38
  {
@@ -31,7 +31,7 @@
31
31
  #define INCLUDE_SVF_FE_LLVMMODULE_H_
32
32
 
33
33
  #include "SVF-LLVM/BasicTypes.h"
34
- #include "SVF-LLVM/CPPUtil.h"
34
+ #include "Util/CppUtil.h"
35
35
  #include "SVFIR/SVFValue.h"
36
36
  #include "SVFIR/SVFModule.h"
37
37
 
@@ -234,7 +234,7 @@ public:
234
234
  SVFOtherValue* getSVFOtherValue(const Value* ov);
235
235
 
236
236
  /// Get the corresponding Function based on its name
237
- inline const SVFFunction* getSVFFunction(std::string name)
237
+ inline const SVFFunction* getSVFFunction(const std::string& name)
238
238
  {
239
239
  Function* fun = nullptr;
240
240
 
@@ -30,9 +30,9 @@
30
30
  #ifndef INCLUDE_SVF_FE_LLVMUTIL_H_
31
31
  #define INCLUDE_SVF_FE_LLVMUTIL_H_
32
32
 
33
- #include "SVF-LLVM/BasicTypes.h"
34
33
  #include "Util/SVFUtil.h"
35
34
  #include "SVF-LLVM/BasicTypes.h"
35
+ #include "SVF-LLVM/LLVMModule.h"
36
36
  #include "SVFIR/SVFValue.h"
37
37
  #include "Util/ExtAPI.h"
38
38
  #include "Util/ThreadAPI.h"
@@ -51,16 +51,14 @@ inline bool isCallSite(const Instruction* inst)
51
51
  /// Whether an instruction is a call or invoke instruction
52
52
  inline bool isCallSite(const Value* val)
53
53
  {
54
- if(SVFUtil::isa<CallBase>(val))
55
- return true;
56
- else
57
- return false;
54
+ return SVFUtil::isa<CallBase>(val);
58
55
  }
59
56
 
60
57
  /// Get the definition of a function across multiple modules
61
58
  inline const Function* getDefFunForMultipleModule(const Function* fun)
62
59
  {
63
- if(fun == nullptr) return nullptr;
60
+ if (fun == nullptr)
61
+ return nullptr;
64
62
  LLVMModuleSet* llvmModuleset = LLVMModuleSet::getLLVMModuleSet();
65
63
  if (fun->isDeclaration() && llvmModuleset->hasDefinition(fun))
66
64
  fun = LLVMModuleSet::getLLVMModuleSet()->getDefinition(fun);
@@ -78,38 +76,39 @@ inline const Function* getCallee(const CallBase* cs)
78
76
  {
79
77
  // FIXME: do we need to strip-off the casts here to discover more library functions
80
78
  const Function* callee = SVFUtil::dyn_cast<Function>(cs->getCalledOperand()->stripPointerCasts());
81
- if(callee)
82
- return getDefFunForMultipleModule(callee);
83
- else
84
- return nullptr;
79
+ return callee ? getDefFunForMultipleModule(callee) : nullptr;
85
80
  }
86
81
 
87
82
  /// Return LLVM function if this value is
88
83
  inline const Function* getLLVMFunction(const Value* val)
89
84
  {
90
- const Function* fun = SVFUtil::dyn_cast<Function>(val->stripPointerCasts());
91
- return fun;
85
+ return SVFUtil::dyn_cast<Function>(val->stripPointerCasts());
92
86
  }
93
87
 
94
88
  /// Get program entry function from module.
95
89
  inline const Function* getProgFunction(const std::string& funName)
96
90
  {
97
- for (Module& M : LLVMModuleSet::getLLVMModuleSet()->getLLVMModules())
91
+ for (const Module& M : LLVMModuleSet::getLLVMModuleSet()->getLLVMModules())
98
92
  {
99
- for (Module::const_iterator F = M.begin(), E = M.end(); F != E; ++F)
93
+ for (const Function& fun : M)
100
94
  {
101
- const Function *fun = &*F;
102
- if (fun->getName().str()==funName)
103
- return fun;
95
+ if (fun.getName() == funName)
96
+ return &fun;
104
97
  }
105
98
  }
106
99
  return nullptr;
107
100
  }
108
101
 
102
+ /// Check whether a function is an entry function (i.e., main)
103
+ inline bool isProgEntryFunction(const Function* fun)
104
+ {
105
+ return fun && fun->getName() == "main";
106
+ }
107
+
109
108
  /// Check whether this value is a black hole
110
109
  inline bool isBlackholeSym(const Value* val)
111
110
  {
112
- return (SVFUtil::isa<UndefValue>(val));
111
+ return SVFUtil::isa<UndefValue>(val);
113
112
  }
114
113
 
115
114
  /// Check whether this value is a black hole
@@ -162,16 +161,16 @@ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const Instruction* inst)
162
161
  //@}
163
162
 
164
163
  /// Return true if this value refers to a object
165
- bool isObject (const Value* ref);
164
+ bool isObject(const Value* ref);
166
165
 
167
166
  /// Method for dead function, which does not have any possible caller
168
167
  /// function address is not taken and never be used in call or invoke instruction
169
168
  //@{
170
169
  /// whether this is a function without any possible caller?
171
- bool isUncalledFunction (const Function* fun);
170
+ bool isUncalledFunction(const Function* fun);
172
171
 
173
172
  /// whether this is an argument in dead function
174
- inline bool ArgInDeadFunction (const Value* val)
173
+ inline bool ArgInDeadFunction(const Value* val)
175
174
  {
176
175
  return SVFUtil::isa<Argument>(val)
177
176
  && isUncalledFunction(SVFUtil::cast<Argument>(val)->getParent());
@@ -179,13 +178,14 @@ inline bool ArgInDeadFunction (const Value* val)
179
178
  //@}
180
179
 
181
180
  /// Return true if this is an argument of a program entry function (e.g. main)
182
- inline bool ArgInProgEntryFunction (const Value* val)
181
+ inline bool ArgInProgEntryFunction(const Value* val)
183
182
  {
184
- return SVFUtil::isa<Argument>(val)
185
- && SVFUtil::isProgEntryFunction(SVFUtil::cast<Argument>(val)->getParent());
183
+ return SVFUtil::isa<Argument>(val) &&
184
+ LLVMUtil::isProgEntryFunction(
185
+ SVFUtil::cast<Argument>(val)->getParent());
186
186
  }
187
187
  /// Return true if this is value in a dead function (function without any caller)
188
- bool isPtrInUncalledFunction (const Value* value);
188
+ bool isPtrInUncalledFunction(const Value* value);
189
189
  //@}
190
190
 
191
191
  //@}
@@ -193,9 +193,9 @@ bool isPtrInUncalledFunction (const Value* value);
193
193
  /// Function does not have any possible caller in the call graph
194
194
  //@{
195
195
  /// Return true if the function does not have a caller (either it is a main function or a dead function)
196
- inline bool isNoCallerFunction (const Function* fun)
196
+ inline bool isNoCallerFunction(const Function* fun)
197
197
  {
198
- return isUncalledFunction(fun) || SVFUtil::isProgEntryFunction(fun);
198
+ return isUncalledFunction(fun) || LLVMUtil::isProgEntryFunction(fun);
199
199
  }
200
200
 
201
201
  /// Return true if the argument in a function does not have a caller
@@ -206,81 +206,84 @@ inline bool isArgOfUncalledFunction (const Value* val)
206
206
  }
207
207
  //@}
208
208
 
209
- /// Return true if the function has a return instruction reachable from function entry
210
- bool functionDoesNotRet (const Function* fun);
209
+ /// Return true if the function has a return instruction reachable from function
210
+ /// entry
211
+ bool functionDoesNotRet(const Function* fun);
211
212
 
212
213
  /// Get reachable basic block from function entry
213
- void getFunReachableBBs (const Function* svfFun, std::vector<const SVFBasicBlock*>& bbs);
214
+ void getFunReachableBBs(const Function* svfFun,
215
+ std::vector<const SVFBasicBlock*>& bbs);
214
216
 
215
217
  /// Strip off the constant casts
216
- const Value* stripConstantCasts(const Value* val);
218
+ const Value* stripConstantCasts(const Value* val);
217
219
 
218
220
  /// Strip off the all casts
219
- const Value* stripAllCasts(const Value* val) ;
221
+ const Value* stripAllCasts(const Value* val);
220
222
 
221
223
  /// Get the type of the heap allocation
222
- const Type* getTypeOfHeapAlloc(const Instruction* inst) ;
224
+ const Type* getTypeOfHeapAlloc(const Instruction* inst);
223
225
 
224
- /// Return the bitcast instruction which is val's only use site, otherwise return nullptr
226
+ /// Return the bitcast instruction which is val's only use site, otherwise
227
+ /// return nullptr
225
228
  const Value* getUniqueUseViaCastInst(const Value* val);
226
229
 
227
230
  /// Return corresponding constant expression, otherwise return nullptr
228
231
  //@{
229
- inline const ConstantExpr *isGepConstantExpr(const Value* val)
232
+ inline const ConstantExpr* isGepConstantExpr(const Value* val)
230
233
  {
231
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
234
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
232
235
  {
233
- if(constExpr->getOpcode() == Instruction::GetElementPtr)
236
+ if (constExpr->getOpcode() == Instruction::GetElementPtr)
234
237
  return constExpr;
235
238
  }
236
239
  return nullptr;
237
240
  }
238
241
 
239
- inline const ConstantExpr *isInt2PtrConstantExpr(const Value* val)
242
+ inline const ConstantExpr* isInt2PtrConstantExpr(const Value* val)
240
243
  {
241
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
244
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
242
245
  {
243
- if(constExpr->getOpcode() == Instruction::IntToPtr)
246
+ if (constExpr->getOpcode() == Instruction::IntToPtr)
244
247
  return constExpr;
245
248
  }
246
249
  return nullptr;
247
250
  }
248
251
 
249
- inline const ConstantExpr *isPtr2IntConstantExpr(const Value* val)
252
+ inline const ConstantExpr* isPtr2IntConstantExpr(const Value* val)
250
253
  {
251
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
254
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
252
255
  {
253
- if(constExpr->getOpcode() == Instruction::PtrToInt)
256
+ if (constExpr->getOpcode() == Instruction::PtrToInt)
254
257
  return constExpr;
255
258
  }
256
259
  return nullptr;
257
260
  }
258
261
 
259
- inline const ConstantExpr *isCastConstantExpr(const Value* val)
262
+ inline const ConstantExpr* isCastConstantExpr(const Value* val)
260
263
  {
261
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
264
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
262
265
  {
263
- if(constExpr->getOpcode() == Instruction::BitCast)
266
+ if (constExpr->getOpcode() == Instruction::BitCast)
264
267
  return constExpr;
265
268
  }
266
269
  return nullptr;
267
270
  }
268
271
 
269
- inline const ConstantExpr *isSelectConstantExpr(const Value* val)
272
+ inline const ConstantExpr* isSelectConstantExpr(const Value* val)
270
273
  {
271
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
274
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
272
275
  {
273
- if(constExpr->getOpcode() == Instruction::Select)
276
+ if (constExpr->getOpcode() == Instruction::Select)
274
277
  return constExpr;
275
278
  }
276
279
  return nullptr;
277
280
  }
278
281
 
279
- inline const ConstantExpr *isTruncConstantExpr(const Value* val)
282
+ inline const ConstantExpr* isTruncConstantExpr(const Value* val)
280
283
  {
281
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
284
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
282
285
  {
283
- if(constExpr->getOpcode() == Instruction::Trunc ||
286
+ if (constExpr->getOpcode() == Instruction::Trunc ||
284
287
  constExpr->getOpcode() == Instruction::FPTrunc ||
285
288
  constExpr->getOpcode() == Instruction::ZExt ||
286
289
  constExpr->getOpcode() == Instruction::SExt ||
@@ -290,31 +293,34 @@ inline const ConstantExpr *isTruncConstantExpr(const Value* val)
290
293
  return nullptr;
291
294
  }
292
295
 
293
- inline const ConstantExpr *isCmpConstantExpr(const Value* val)
296
+ inline const ConstantExpr* isCmpConstantExpr(const Value* val)
294
297
  {
295
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
298
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
296
299
  {
297
- if(constExpr->getOpcode() == Instruction::ICmp || constExpr->getOpcode() == Instruction::FCmp)
300
+ if (constExpr->getOpcode() == Instruction::ICmp ||
301
+ constExpr->getOpcode() == Instruction::FCmp)
298
302
  return constExpr;
299
303
  }
300
304
  return nullptr;
301
305
  }
302
306
 
303
- inline const ConstantExpr *isBinaryConstantExpr(const Value* val)
307
+ inline const ConstantExpr* isBinaryConstantExpr(const Value* val)
304
308
  {
305
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
309
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
306
310
  {
307
- if((constExpr->getOpcode() >= Instruction::BinaryOpsBegin) && (constExpr->getOpcode() <= Instruction::BinaryOpsEnd))
311
+ if ((constExpr->getOpcode() >= Instruction::BinaryOpsBegin) &&
312
+ (constExpr->getOpcode() <= Instruction::BinaryOpsEnd))
308
313
  return constExpr;
309
314
  }
310
315
  return nullptr;
311
316
  }
312
317
 
313
- inline const ConstantExpr *isUnaryConstantExpr(const Value* val)
318
+ inline const ConstantExpr* isUnaryConstantExpr(const Value* val)
314
319
  {
315
- if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
320
+ if (const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
316
321
  {
317
- if((constExpr->getOpcode() >= Instruction::UnaryOpsBegin) && (constExpr->getOpcode() <= Instruction::UnaryOpsEnd))
322
+ if ((constExpr->getOpcode() >= Instruction::UnaryOpsBegin) &&
323
+ (constExpr->getOpcode() <= Instruction::UnaryOpsEnd))
318
324
  return constExpr;
319
325
  }
320
326
  return nullptr;
@@ -324,38 +330,41 @@ inline const ConstantExpr *isUnaryConstantExpr(const Value* val)
324
330
  inline static DataLayout* getDataLayout(Module* mod)
325
331
  {
326
332
  static DataLayout *dl = nullptr;
327
- if (dl == nullptr) dl = new DataLayout(mod);
333
+ if (dl == nullptr)
334
+ dl = new DataLayout(mod);
328
335
  return dl;
329
336
  }
330
337
 
331
338
  /// Get the next instructions following control flow
332
- void getNextInsts(const Instruction* curInst, std::vector<const SVFInstruction*>& instList);
339
+ void getNextInsts(const Instruction* curInst,
340
+ std::vector<const SVFInstruction*>& instList);
333
341
 
334
342
  /// Get the previous instructions following control flow
335
- void getPrevInsts(const Instruction* curInst, std::vector<const SVFInstruction*>& instList);
343
+ void getPrevInsts(const Instruction* curInst,
344
+ std::vector<const SVFInstruction*>& instList);
336
345
 
337
346
  /// Get the next instructions following control flow
338
- void getNextInsts(const Instruction* curInst, std::vector<const Instruction*>& instList);
347
+ void getNextInsts(const Instruction* curInst,
348
+ std::vector<const Instruction*>& instList);
339
349
 
340
350
  /// Get the previous instructions following control flow
341
- void getPrevInsts(const Instruction* curInst, std::vector<const Instruction*>& instList);
351
+ void getPrevInsts(const Instruction* curInst,
352
+ std::vector<const Instruction*>& instList);
342
353
 
343
354
  /// Get num of BB's predecessors
344
355
  u32_t getBBPredecessorNum(const BasicBlock* BB);
345
356
 
346
-
347
-
348
357
  /// Check whether a file is an LLVM IR file
349
- bool isIRFile(const std::string &filename);
358
+ bool isIRFile(const std::string& filename);
350
359
 
351
360
  /// Parse argument for multi-module analysis
352
- void processArguments(int argc, char **argv, int &arg_num, char **arg_value,
353
- std::vector<std::string> &moduleNameVec);
361
+ void processArguments(int argc, char** argv, int& arg_num, char** arg_value,
362
+ std::vector<std::string>& moduleNameVec);
354
363
 
355
364
  /// Helper method to get the size of the type from target data layout
356
365
  //@{
357
366
  u32_t getTypeSizeInBytes(const Type* type);
358
- u32_t getTypeSizeInBytes(const StructType *sty, u32_t field_index);
367
+ u32_t getTypeSizeInBytes(const StructType* sty, u32_t field_index);
359
368
  //@}
360
369
 
361
370
  const std::string getSourceLoc(const Value* val);
@@ -365,7 +374,7 @@ bool isIntrinsicInst(const Instruction* inst);
365
374
  bool isIntrinsicFun(const Function* func);
366
375
 
367
376
  /// Get the corresponding Function based on its name
368
- inline const SVFFunction* getFunction(std::string name)
377
+ inline const SVFFunction* getFunction(const std::string& name)
369
378
  {
370
379
  return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(name);
371
380
  }
@@ -373,17 +382,14 @@ inline const SVFFunction* getFunction(std::string name)
373
382
  /// Return true if the value refers to constant data, e.g., i32 0
374
383
  inline bool isConstDataOrAggData(const Value* val)
375
384
  {
376
- bool constDataOrConstAggregate = SVFUtil::isa<ConstantData>(val)
377
- || SVFUtil::isa<ConstantAggregate>(val)
378
- || SVFUtil::isa<MetadataAsValue>(val)
379
- || SVFUtil::isa<BlockAddress>(val);
380
- return constDataOrConstAggregate;
385
+ return SVFUtil::isa<ConstantData, ConstantAggregate,
386
+ MetadataAsValue, BlockAddress>(val);
381
387
  }
382
388
 
383
389
  /// find the unique defined global across multiple modules
384
390
  inline const Value* getGlobalRep(const Value* val)
385
391
  {
386
- if(const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
392
+ if (const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
387
393
  {
388
394
  if (LLVMModuleSet::getLLVMModuleSet()->hasGlobalRep(gvar))
389
395
  val = LLVMModuleSet::getLLVMModuleSet()->getGlobalRep(gvar);
@@ -403,6 +409,56 @@ void viewCFG(const Function* fun);
403
409
  // Dump Control Flow Graph of llvm function, without instructions
404
410
  void viewCFGOnly(const Function* fun);
405
411
 
412
+ bool isValVtbl(const Value* val);
413
+ bool isLoadVtblInst(const LoadInst* loadInst);
414
+ bool isVirtualCallSite(const CallBase* cs);
415
+ bool isConstructor(const Function* F);
416
+ bool isDestructor(const Function* F);
417
+ bool isCPPThunkFunction(const Function* F);
418
+ const Function* getThunkTarget(const Function* F);
419
+
420
+ /*
421
+ * VtableA = {&A::foo}
422
+ * A::A(this){
423
+ * *this = &VtableA;
424
+ * }
425
+ *
426
+ *
427
+ * A* p = new A;
428
+ * cs: p->foo(...)
429
+ * ==>
430
+ * vtptr = *p;
431
+ * vfn = &vtptr[i]
432
+ * %funp = *vfn
433
+ * call %funp(p,...)
434
+ * getConstructorThisPtr(A) return "this" pointer
435
+ * getVCallThisPtr(cs) return p (this pointer)
436
+ * getVCallVtblPtr(cs) return vtptr
437
+ * getVCallIdx(cs) return i
438
+ * getClassNameFromVtblObj(VtableA) return
439
+ * getClassNameFromType(type of p) return type A
440
+ */
441
+ const Argument* getConstructorThisPtr(const Function* fun);
442
+ const Value* getVCallThisPtr(const CallBase* cs);
443
+ const Value* getVCallVtblPtr(const CallBase* cs);
444
+ s32_t getVCallIdx(const CallBase* cs);
445
+ std::string getClassNameFromType(const Type* ty);
446
+ std::string getClassNameOfThisPtr(const CallBase* cs);
447
+ std::string getFunNameOfVCallSite(const CallBase* cs);
448
+ bool VCallInCtorOrDtor(const CallBase* cs);
449
+
450
+ /*
451
+ * A(A* this){
452
+ * store this this.addr;
453
+ * tmp = load this.addr;
454
+ * this1 = bitcast(tmp);
455
+ * B(this1);
456
+ * }
457
+ * this and this1 are the same thisPtr in the constructor
458
+ */
459
+ bool isSameThisPtrInConstructor(const Argument* thisPtr1,
460
+ const Value* thisPtr2);
461
+
406
462
  } // End namespace LLVMUtil
407
463
 
408
464
  } // End namespace SVF
@@ -34,6 +34,7 @@
34
34
  #include "Util/ExtAPI.h"
35
35
  #include "SVF-LLVM/BasicTypes.h"
36
36
  #include "SVF-LLVM/ICFGBuilder.h"
37
+ #include "SVF-LLVM/LLVMModule.h"
37
38
 
38
39
  namespace SVF
39
40
  {
@@ -27,8 +27,8 @@
27
27
  * Author: Yulei Sui
28
28
  */
29
29
 
30
- #ifndef INCLUDE_MEMORYMODEL_PAGBUILDERFROMFILE_H_
31
- #define INCLUDE_MEMORYMODEL_PAGBUILDERFROMFILE_H_
30
+ #ifndef INCLUDE_SVFIR_PAGBUILDERFROMFILE_H_
31
+ #define INCLUDE_SVFIR_PAGBUILDERFROMFILE_H_
32
32
 
33
33
  #include "SVFIR/SVFIR.h"
34
34
 
@@ -77,4 +77,4 @@ public:
77
77
 
78
78
  } // End namespace SVF
79
79
 
80
- #endif /* INCLUDE_MEMORYMODEL_PAGBUILDERFROMFILE_H_ */
80
+ #endif /* INCLUDE_SVFIR_PAGBUILDERFROMFILE_H_ */
@@ -27,8 +27,8 @@
27
27
  * Author: Yulei Sui
28
28
  */
29
29
 
30
- #ifndef SVFIR_H_
31
- #define SVFIR_H_
30
+ #ifndef INCLUDE_SVFIR_H_
31
+ #define INCLUDE_SVFIR_H_
32
32
 
33
33
  #include "Graphs/IRGraph.h"
34
34
 
@@ -656,4 +656,4 @@ typedef SVFIR PAG;
656
656
 
657
657
 
658
658
 
659
- #endif /* SVFIR_H_ */
659
+ #endif /* INCLUDE_SVFIR_H_ */
@@ -27,8 +27,8 @@
27
27
  * Author: Xiaokang Fan
28
28
  */
29
29
 
30
- #ifndef SVFMODULE_H_
31
- #define SVFMODULE_H_
30
+ #ifndef INCLUDE_SVFMODULE_H_
31
+ #define INCLUDE_SVFMODULE_H_
32
32
 
33
33
  #include "SVFIR/SVFValue.h"
34
34
  #include "Util/ExtAPI.h"
@@ -230,4 +230,4 @@ public:
230
230
 
231
231
  } // End namespace SVF
232
232
 
233
- #endif /* SVFMODULE_H_ */
233
+ #endif /* INCLUDE_SVFMODULE_H_ */
@@ -28,8 +28,8 @@
28
28
  * Author: Yulei Sui
29
29
  */
30
30
 
31
- #ifndef PAGEDGE_H_
32
- #define PAGEDGE_H_
31
+ #ifndef INCLUDE_SVFIR_SVFSTATEMENT_H_
32
+ #define INCLUDE_SVFIR_SVFSTATEMENT_H_
33
33
 
34
34
  #include "Graphs/GenericGraph.h"
35
35
  #include "MemoryModel/LocationSet.h"
@@ -1144,4 +1144,4 @@ public:
1144
1144
 
1145
1145
  } // End namespace SVF
1146
1146
 
1147
- #endif /* PAGEDGE_H_ */
1147
+ #endif /* INCLUDE_SVFIR_SVFSTATEMENT_H_ */