svf-lib 1.0.1363 → 1.0.1365

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.
Binary file
@@ -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_ */
@@ -27,21 +27,20 @@
27
27
  * Author: Yulei Sui
28
28
  */
29
29
 
30
+ #ifndef INCLUDE_SVFIR_SVFTYPE_H_
31
+ #define INCLUDE_SVFIR_SVFTYPE_H_
30
32
 
31
- #ifndef INCLUDE_UTIL_SVFBASICTYPES_H_
32
- #define INCLUDE_UTIL_SVFBASICTYPES_H_
33
-
34
- #include <Util/SparseBitVector.h>
33
+ #include "Util/SparseBitVector.h"
35
34
 
35
+ #include <deque>
36
36
  #include <iostream>
37
- #include <vector>
38
37
  #include <list>
39
- #include <set>
40
- #include <unordered_set>
41
38
  #include <map>
42
- #include <unordered_map>
39
+ #include <set>
43
40
  #include <stack>
44
- #include <deque>
41
+ #include <unordered_map>
42
+ #include <unordered_set>
43
+ #include <vector>
45
44
 
46
45
  namespace SVF
47
46
  {
@@ -72,7 +71,7 @@ template <class S, class T> struct Hash<std::pair<S, T>>
72
71
  return a > b ? b * b + a : a * a + a + b;
73
72
  }
74
73
 
75
- size_t operator()(const std::pair<S, T> &t) const
74
+ size_t operator()(const std::pair<S, T>& t) const
76
75
  {
77
76
  Hash<decltype(t.first)> first;
78
77
  Hash<decltype(t.second)> second;
@@ -82,65 +81,68 @@ template <class S, class T> struct Hash<std::pair<S, T>>
82
81
 
83
82
  template <class T> struct Hash
84
83
  {
85
- size_t operator()(const T &t) const
84
+ size_t operator()(const T& t) const
86
85
  {
87
86
  std::hash<T> h;
88
87
  return h(t);
89
88
  }
90
89
  };
91
90
 
92
- template <typename Key, typename Hash = Hash<Key>, typename KeyEqual = std::equal_to<Key>,
91
+ template <typename Key, typename Hash = Hash<Key>,
92
+ typename KeyEqual = std::equal_to<Key>,
93
93
  typename Allocator = std::allocator<Key>>
94
94
  using Set = std::unordered_set<Key, Hash, KeyEqual, Allocator>;
95
95
 
96
- template<typename Key, typename Value, typename Hash = Hash<Key>,
97
- typename KeyEqual = std::equal_to<Key>,
98
- typename Allocator = std::allocator<std::pair<const Key, Value>>>
99
- using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
100
-
101
- template<typename Key, typename Compare = std::less<Key>, typename Allocator = std::allocator<Key>>
102
- using OrderedSet = std::set<Key, Compare, Allocator>;
103
-
104
- template<typename Key, typename Value, typename Compare = std::less<Key>,
105
- typename Allocator = std::allocator<std::pair<const Key, Value>>>
106
- using OrderedMap = std::map<Key, Value, Compare, Allocator>;
107
-
108
- typedef std::pair<NodeID, NodeID> NodePair;
109
- typedef OrderedSet<NodeID> OrderedNodeSet;
110
- typedef Set<NodeID> NodeSet;
111
- typedef Set<NodePair> NodePairSet;
112
- typedef Map<NodePair,NodeID> NodePairMap;
113
- typedef std::vector<NodeID> NodeVector;
114
- typedef std::vector<EdgeID> EdgeVector;
115
- typedef std::stack<NodeID> NodeStack;
116
- typedef std::list<NodeID> NodeList;
117
- typedef std::deque<NodeID> NodeDeque;
118
- typedef NodeSet EdgeSet;
119
- typedef std::vector<u32_t> CallStrCxt;
120
- typedef unsigned Version;
121
- typedef Set<Version> VersionSet;
122
- typedef std::pair<NodeID, Version> VersionedVar;
123
- typedef Set<VersionedVar> VersionedVarSet;
124
-
125
- class SVFType;
126
- class SVFPointerType;
127
-
128
- /*!
129
- * Flatterned type information of StructType, ArrayType and SingleValueType
130
- */
131
- class StInfo
96
+ template <typename Key, typename Value, typename Hash = Hash<Key>,
97
+ typename KeyEqual = std::equal_to<Key>,
98
+ typename Allocator = std::allocator<std::pair<const Key, Value>>>
99
+ using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
100
+
101
+ template <typename Key, typename Compare = std::less<Key>,
102
+ typename Allocator = std::allocator<Key>>
103
+ using OrderedSet = std::set<Key, Compare, Allocator>;
104
+
105
+ template <typename Key, typename Value, typename Compare = std::less<Key>,
106
+ typename Allocator = std::allocator<std::pair<const Key, Value>>>
107
+ using OrderedMap = std::map<Key, Value, Compare, Allocator>;
108
+
109
+ typedef std::pair<NodeID, NodeID> NodePair;
110
+ typedef OrderedSet<NodeID> OrderedNodeSet;
111
+ typedef Set<NodeID> NodeSet;
112
+ typedef Set<NodePair> NodePairSet;
113
+ typedef Map<NodePair, NodeID> NodePairMap;
114
+ typedef std::vector<NodeID> NodeVector;
115
+ typedef std::vector<EdgeID> EdgeVector;
116
+ typedef std::stack<NodeID> NodeStack;
117
+ typedef std::list<NodeID> NodeList;
118
+ typedef std::deque<NodeID> NodeDeque;
119
+ typedef NodeSet EdgeSet;
120
+ typedef std::vector<u32_t> CallStrCxt;
121
+ typedef unsigned Version;
122
+ typedef Set<Version> VersionSet;
123
+ typedef std::pair<NodeID, Version> VersionedVar;
124
+ typedef Set<VersionedVar> VersionedVarSet;
125
+
126
+ class SVFType;
127
+ class SVFPointerType;
128
+
129
+ /*!
130
+ * Flatterned type information of StructType, ArrayType and SingleValueType
131
+ */
132
+ class StInfo
132
133
  {
133
-
134
134
  private:
135
135
  /// flattened field indices of a struct (ignoring arrays)
136
136
  std::vector<u32_t> fldIdxVec;
137
- /// flattened element indices including structs and arrays by considering strides
137
+ /// flattened element indices including structs and arrays by considering
138
+ /// strides
138
139
  std::vector<u32_t> elemIdxVec;
139
140
  /// Types of all fields of a struct
140
141
  Map<u32_t, const SVFType*> fldIdx2TypeMap;
141
142
  /// All field infos after flattening a struct
142
143
  std::vector<const SVFType*> finfo;
143
- /// stride represents the number of repetitive elements if this StInfo represent an ArrayType. stride is 1 by default.
144
+ /// stride represents the number of repetitive elements if this StInfo
145
+ /// represent an ArrayType. stride is 1 by default.
144
146
  u32_t stride;
145
147
  /// number of elements after flattenning (including array elements)
146
148
  u32_t numOfFlattenElements;
@@ -156,14 +158,15 @@ public:
156
158
  void operator=(const StInfo&) = delete;
157
159
 
158
160
  /// Constructor
159
- explicit StInfo(u32_t s) : stride(s), numOfFlattenElements(s), numOfFlattenFields(s)
161
+ explicit StInfo(u32_t s)
162
+ : stride(s), numOfFlattenElements(s), numOfFlattenFields(s)
160
163
  {
161
164
  }
162
165
  /// Destructor
163
166
  ~StInfo() = default;
164
167
 
165
- /// struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b;
166
- /// OriginalFieldType of b with field_idx 1 : Struct A
168
+ /// struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b;
169
+ // OriginalFieldType of b with field_idx 1 : Struct A
167
170
  /// FlatternedFieldType of b with field_idx 1 : int
168
171
  //{@
169
172
  const SVFType* getOriginalElemType(u32_t fldIdx) const;
@@ -248,27 +251,30 @@ public:
248
251
  };
249
252
 
250
253
  private:
251
- GNodeK kind; ///< used for classof
252
- const SVFPointerType* getPointerToTy; /// Return a pointer to the current type
253
- StInfo* typeinfo; /// < SVF's TypeInfo
254
- bool isSingleValTy; ///< The type represents a single value, not struct or array
254
+ GNodeK kind; ///< used for classof
255
+ const SVFPointerType*
256
+ getPointerToTy; /// Return a pointer to the current type
257
+ StInfo* typeinfo; /// < SVF's TypeInfo
258
+ bool isSingleValTy; ///< The type represents a single value, not struct or
259
+ ///< array
255
260
  protected:
256
- SVFType(bool svt, SVFTyKind k) : kind(k), getPointerToTy(nullptr), typeinfo(nullptr), isSingleValTy(svt)
261
+ SVFType(bool svt, SVFTyKind k)
262
+ : kind(k), getPointerToTy(nullptr), typeinfo(nullptr),
263
+ isSingleValTy(svt)
257
264
  {
258
265
  }
259
266
 
260
267
  public:
261
268
  SVFType(void) = delete;
262
- virtual ~SVFType()
263
- {
264
- }
269
+ virtual ~SVFType() {}
265
270
 
266
271
  inline GNodeK getKind() const
267
272
  {
268
273
  return kind;
269
274
  }
270
275
 
271
- /// Needs to be implemented by a specific SVF front end (e.g., the implementation in LLVMUtil)
276
+ /// Needs to be implemented by a specific SVF front end (e.g., the
277
+ /// implementation in LLVMUtil)
272
278
  virtual const std::string toString() const;
273
279
 
274
280
  inline void setPointerTo(const SVFPointerType* ty)
@@ -276,13 +282,13 @@ public:
276
282
  getPointerToTy = ty;
277
283
  }
278
284
 
279
- inline const SVFPointerType* getPointerTo () const
285
+ inline const SVFPointerType* getPointerTo() const
280
286
  {
281
287
  assert(getPointerToTy && "set the getPointerToTy first");
282
288
  return getPointerToTy;
283
289
  }
284
290
 
285
- inline void setTypeInfo (StInfo* ti)
291
+ inline void setTypeInfo(StInfo* ti)
286
292
  {
287
293
  typeinfo = ti;
288
294
  }
@@ -301,7 +307,7 @@ public:
301
307
 
302
308
  inline bool isPointerTy() const
303
309
  {
304
- return kind==SVFPointerTy;
310
+ return kind == SVFPointerTy;
305
311
  }
306
312
 
307
313
  inline bool isSingleValueType() const
@@ -317,10 +323,11 @@ private:
317
323
  const SVFType* ptrElementType;
318
324
 
319
325
  public:
320
- SVFPointerType(const SVFType* pty) : SVFType(true, SVFPointerTy), ptrElementType(pty)
326
+ SVFPointerType(const SVFType* pty)
327
+ : SVFType(true, SVFPointerTy), ptrElementType(pty)
321
328
  {
322
329
  }
323
- static inline bool classof(const SVFType *node)
330
+ static inline bool classof(const SVFType* node)
324
331
  {
325
332
  return node->getKind() == SVFPointerTy;
326
333
  }
@@ -333,10 +340,8 @@ public:
333
340
  class SVFIntergerType : public SVFType
334
341
  {
335
342
  public:
336
- SVFIntergerType() : SVFType(true, SVFIntergerTy)
337
- {
338
- }
339
- static inline bool classof(const SVFType *node)
343
+ SVFIntergerType() : SVFType(true, SVFIntergerTy) {}
344
+ static inline bool classof(const SVFType* node)
340
345
  {
341
346
  return node->getKind() == SVFIntergerTy;
342
347
  }
@@ -348,10 +353,11 @@ private:
348
353
  const SVFType* retTy;
349
354
 
350
355
  public:
351
- SVFFunctionType(const SVFType* rt) : SVFType(false, SVFFunctionTy), retTy(rt)
356
+ SVFFunctionType(const SVFType* rt)
357
+ : SVFType(false, SVFFunctionTy), retTy(rt)
352
358
  {
353
359
  }
354
- static inline bool classof(const SVFType *node)
360
+ static inline bool classof(const SVFType* node)
355
361
  {
356
362
  return node->getKind() == SVFFunctionTy;
357
363
  }
@@ -364,10 +370,8 @@ public:
364
370
  class SVFStructType : public SVFType
365
371
  {
366
372
  public:
367
- SVFStructType() : SVFType(false, SVFStructTy)
368
- {
369
- }
370
- static inline bool classof(const SVFType *node)
373
+ SVFStructType() : SVFType(false, SVFStructTy) {}
374
+ static inline bool classof(const SVFType* node)
371
375
  {
372
376
  return node->getKind() == SVFStructTy;
373
377
  }
@@ -376,10 +380,8 @@ public:
376
380
  class SVFArrayType : public SVFType
377
381
  {
378
382
  public:
379
- SVFArrayType() : SVFType(false, SVFArrayTy)
380
- {
381
- }
382
- static inline bool classof(const SVFType *node)
383
+ SVFArrayType() : SVFType(false, SVFArrayTy) {}
384
+ static inline bool classof(const SVFType* node)
383
385
  {
384
386
  return node->getKind() == SVFArrayTy;
385
387
  }
@@ -388,20 +390,17 @@ public:
388
390
  class SVFOtherType : public SVFType
389
391
  {
390
392
  public:
391
- SVFOtherType(bool isSingleValueTy) : SVFType(isSingleValueTy, SVFOtherTy)
392
- {
393
- }
394
- static inline bool classof(const SVFType *node)
393
+ SVFOtherType(bool isSingleValueTy) : SVFType(isSingleValueTy, SVFOtherTy) {}
394
+ static inline bool classof(const SVFType* node)
395
395
  {
396
396
  return node->getKind() == SVFOtherTy;
397
397
  }
398
398
  };
399
399
 
400
-
401
400
  // TODO: be explicit that this is a pair of 32-bit unsigneds?
402
401
  template <> struct Hash<NodePair>
403
402
  {
404
- size_t operator()(const NodePair &p) const
403
+ size_t operator()(const NodePair& p) const
405
404
  {
406
405
  // Make sure our assumptions are sound: use u32_t
407
406
  // and u64_t. If NodeID is not actually u32_t or size_t
@@ -413,12 +412,32 @@ template <> struct Hash<NodePair>
413
412
  }
414
413
  };
415
414
 
415
+ #ifndef DEBUG_WITH_TYPE
416
+ # ifndef NDBUG
417
+ // TODO: This comes from the following link
418
+ // https://github.com/llvm/llvm-project/blob/75e33f71c2dae584b13a7d1186ae0a038ba98838/llvm/include/llvm/Support/Debug.h#L64
419
+ // The original LLVM implementation makes use of type. But we can get that info,
420
+ // so we can't simulate the full behaviour for now.
421
+ # define DEBUG_WITH_TYPE(TYPE, X) \
422
+ do \
423
+ { \
424
+ X; \
425
+ } while (false)
426
+ # else
427
+ # define DEBUG_WITH_TYPE(TYPE, X) \
428
+ do \
429
+ { \
430
+ } while (false)
431
+ # endif
432
+ #endif
433
+
416
434
  /// LLVM debug macros, define type of your DEBUG model of each pass
417
- #define DBOUT(TYPE, X) DEBUG_WITH_TYPE(TYPE, X)
418
- #define DOSTAT(X) X
419
- #define DOTIMESTAT(X) X
435
+ #define DBOUT(TYPE, X) DEBUG_WITH_TYPE(TYPE, X)
436
+ #define DOSTAT(X) X
437
+ #define DOTIMESTAT(X) X
420
438
 
421
- /// General debug flag is for each phase of a pass, it is often in a colorful output format
439
+ /// General debug flag is for each phase of a pass, it is often in a colorful
440
+ /// output format
422
441
  #define DGENERAL "general"
423
442
 
424
443
  #define DPAGBuild "pag"
@@ -465,10 +484,9 @@ enum AliasResult
465
484
 
466
485
  } // End namespace SVF
467
486
 
468
-
469
487
  template <> struct std::hash<SVF::NodePair>
470
488
  {
471
- size_t operator()(const SVF::NodePair &p) const
489
+ size_t operator()(const SVF::NodePair& p) const
472
490
  {
473
491
  // Make sure our assumptions are sound: use u32_t
474
492
  // and u64_t. If NodeID is not actually u32_t or size_t
@@ -481,26 +499,25 @@ template <> struct std::hash<SVF::NodePair>
481
499
  };
482
500
 
483
501
  /// Specialise hash for SparseBitVectors.
484
- template <unsigned N>
485
- struct std::hash<SVF::SparseBitVector<N>>
502
+ template <unsigned N> struct std::hash<SVF::SparseBitVector<N>>
486
503
  {
487
- size_t operator()(const SVF::SparseBitVector<N> &sbv) const
504
+ size_t operator()(const SVF::SparseBitVector<N>& sbv) const
488
505
  {
489
506
  SVF::Hash<std::pair<std::pair<size_t, size_t>, size_t>> h;
490
- return h(std::make_pair(std::make_pair(sbv.count(), sbv.find_first()), sbv.find_last()));
507
+ return h(std::make_pair(std::make_pair(sbv.count(), sbv.find_first()),
508
+ sbv.find_last()));
491
509
  }
492
510
  };
493
511
 
494
- template <typename T>
495
- struct std::hash<std::vector<T>>
512
+ template <typename T> struct std::hash<std::vector<T>>
496
513
  {
497
- size_t operator()(const std::vector<T> &v) const
514
+ size_t operator()(const std::vector<T>& v) const
498
515
  {
499
516
  // TODO: repetition with CBV.
500
517
  size_t h = v.size();
501
518
 
502
519
  SVF::Hash<T> hf;
503
- for (const T &t : v)
520
+ for (const T& t : v)
504
521
  {
505
522
  h ^= hf(t) + 0x9e3779b9 + (h << 6) + (h >> 2);
506
523
  }
@@ -509,4 +526,4 @@ struct std::hash<std::vector<T>>
509
526
  }
510
527
  };
511
528
 
512
- #endif /* INCLUDE_UTIL_SVFBASICTYPES_H_ */
529
+ #endif /* INCLUDE_SVFIR_SVFTYPE_H_ */
@@ -27,8 +27,8 @@
27
27
  * Author: Yulei Sui
28
28
  */
29
29
 
30
- #ifndef BASICTYPES_H_
31
- #define BASICTYPES_H_
30
+ #ifndef INCLUDE_SVFIR_SVFVALUE_H_
31
+ #define INCLUDE_SVFIR_SVFVALUE_H_
32
32
 
33
33
  #include "SVFIR/SVFType.h"
34
34
  #include "Graphs/GraphPrinter.h"
@@ -1117,4 +1117,4 @@ template <> struct std::hash<SVF::CallSite>
1117
1117
  }
1118
1118
  };
1119
1119
 
1120
- #endif /* BASICTYPES_H_ */
1120
+ #endif /* INCLUDE_SVFIR_SVFVALUE_H_ */
@@ -27,8 +27,8 @@
27
27
  * Author: Yulei Sui
28
28
  */
29
29
 
30
- #ifndef OBJECTANDSYMBOL_H_
31
- #define OBJECTANDSYMBOL_H_
30
+ #ifndef INCLUDE_SVFIR_SVFVARIABLE_H_
31
+ #define INCLUDE_SVFIR_SVFVARIABLE_H_
32
32
 
33
33
  #include "Graphs/GenericGraph.h"
34
34
  #include "SVFIR/SymbolTableInfo.h"
@@ -718,4 +718,4 @@ public:
718
718
 
719
719
  } // End namespace SVF
720
720
 
721
- #endif /* OBJECTANDSYMBOL_H_ */
721
+ #endif /* INCLUDE_SVFIR_SVFVARIABLE_H_ */
@@ -27,8 +27,8 @@
27
27
  * Author: Yulei Sui
28
28
  */
29
29
 
30
- #ifndef INCLUDE_SVF_FE_SYMBOLTABLEINFO_H_
31
- #define INCLUDE_SVF_FE_SYMBOLTABLEINFO_H_
30
+ #ifndef INCLUDE_SVFIR_SYMBOLTABLEINFO_H_
31
+ #define INCLUDE_SVFIR_SYMBOLTABLEINFO_H_
32
32
 
33
33
 
34
34
  #include "Util/SVFUtil.h"
@@ -594,4 +594,4 @@ public:
594
594
 
595
595
  } // End namespace SVF
596
596
 
597
- #endif /* INCLUDE_SVF_FE_SYMBOLTABLEINFO_H_ */
597
+ #endif /* INCLUDE_SVFIR_SYMBOLTABLEINFO_H_ */
@@ -8,6 +8,7 @@
8
8
  #ifndef ANNOTATOR_H_
9
9
  #define ANNOTATOR_H_
10
10
 
11
+ #include <SVF-LLVM/BasicTypes.h> // TODO: Remove LLVM Header
11
12
  #include "SVFIR/SVFValue.h"
12
13
  #include <vector>
13
14
 
@@ -36,7 +37,6 @@ public:
36
37
  /// Destructor
37
38
  virtual ~Annotator()
38
39
  {
39
-
40
40
  }
41
41
 
42
42
  /// SB Has flag methods
@@ -46,6 +46,7 @@ public:
46
46
  std::vector<Value* > values;
47
47
  return evalMDTag(inst, inst, SB_SLICESOURCE, values);
48
48
  }
49
+
49
50
  inline bool hasSBSinkFlag(Instruction* inst) const
50
51
  {
51
52
  std::vector<Value* > values;
@@ -59,38 +60,28 @@ public:
59
60
  {
60
61
  //std::vector<Value* > values;
61
62
  //return evalMDTag(inst, inst, DR_NOT_CHECK, values);
62
- if (inst->getMetadata(DR_NOT_CHECK))
63
- return true;
64
- else
65
- return false;
63
+ return inst->getMetadata(DR_NOT_CHECK);
66
64
  }
65
+
67
66
  inline bool hasDRNotCheckFlag(const Instruction* inst) const
68
67
  {
69
68
  //std::vector<Value* > values;
70
69
  //return evalMDTag(inst, inst, DR_NOT_CHECK, values);
71
- if (inst->getMetadata(DR_NOT_CHECK))
72
- return true;
73
- else
74
- return false;
70
+ return inst->getMetadata(DR_NOT_CHECK);
75
71
  }
76
72
 
77
73
  inline bool hasDRCheckFlag(Instruction* inst) const
78
74
  {
79
75
  //std::vector<Value* > values;
80
76
  //return evalMDTag(inst, inst, DR_CHECK, values);
81
- if (inst->getMetadata(DR_CHECK))
82
- return true;
83
- else
84
- return false;
77
+ return inst->getMetadata(DR_CHECK);
85
78
  }
79
+
86
80
  inline bool hasDRCheckFlag(const Instruction* inst) const
87
81
  {
88
82
  //std::vector<Value* > values;
89
83
  //return evalMDTag(inst, inst, DR_CHECK, values);
90
- if (inst->getMetadata(DR_CHECK))
91
- return true;
92
- else
93
- return false;
84
+ return inst->getMetadata(DR_CHECK);
94
85
  }
95
86
  //@}
96
87
 
@@ -0,0 +1,81 @@
1
+ //===- CPPUtil.h -- Base class of pointer analyses ---------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * CPPUtil.h
25
+ *
26
+ * Created on: Apr 13, 2016
27
+ * Author: Xiaokang Fan
28
+ */
29
+
30
+ #ifndef CPPUtil_H_
31
+ #define CPPUtil_H_
32
+
33
+ #include "SVFIR/SVFValue.h"
34
+
35
+ namespace SVF
36
+ {
37
+
38
+ class CHGraph;
39
+ /*
40
+ * Util class to assist pointer analysis for cpp programs
41
+ */
42
+
43
+ namespace cppUtil
44
+ {
45
+
46
+ struct DemangledName
47
+ {
48
+ std::string className;
49
+ std::string funcName;
50
+ bool isThunkFunc;
51
+ };
52
+
53
+ struct DemangledName demangle(const std::string& name);
54
+
55
+ std::string getBeforeBrackets(const std::string& name);
56
+ std::string getClassNameFromVtblObj(const std::string& vtblName);
57
+
58
+ /// Constants pertaining to CTir, for C and C++.
59
+ /// TODO: move helper functions here too?
60
+ namespace ctir
61
+ {
62
+ /// On loads, stores, GEPs representing dereferences, and calls
63
+ /// representing virtual calls.
64
+ /// (The static type.)
65
+ const std::string derefMDName = "ctir";
66
+ /// On the (global) virtual table itself.
67
+ /// (The class it corresponds to.)
68
+ const std::string vtMDName = "ctir.vt";
69
+ /// On the bitcast of `this` to i8*.
70
+ /// (The class the constructor it corresponds to.)
71
+ const std::string vtInitMDName = "ctir.vt.init";
72
+
73
+ /// Value we expect a ctir-annotated module to have.
74
+ const uint32_t moduleFlagValue = 1;
75
+ } // namespace ctir
76
+
77
+ } // End namespace cppUtil
78
+
79
+ } // End namespace SVF
80
+
81
+ #endif /* CPPUtil_H_ */
@@ -31,8 +31,9 @@
31
31
  #define AnalysisUtil_H_
32
32
 
33
33
  #include "FastCluster/fastcluster.h"
34
- #include "SVF-LLVM/LLVMModule.h"
35
34
  #include "SVFIR/SVFValue.h"
35
+ #include "SVFIR/SVFModule.h"
36
+ #include "Util/ExtAPI.h"
36
37
  #include "MemoryModel/PointsTo.h"
37
38
  #include <time.h>
38
39
 
@@ -345,12 +346,11 @@ inline bool isStaticExtFun(const SVFFunction* fun)
345
346
  /// Program entry function e.g. main
346
347
  //@{
347
348
  /// Return true if this is a program entry function (e.g. main)
348
- inline bool isProgEntryFunction (const SVFFunction * fun)
349
+ inline bool isProgEntryFunction(const SVFFunction* fun)
349
350
  {
350
351
  return fun && fun->getName() == "main";
351
352
  }
352
353
 
353
-
354
354
  /// Get program entry function from module.
355
355
  inline const SVFFunction* getProgFunction(SVFModule* svfModule, const std::string& funName)
356
356
  {
@@ -636,12 +636,6 @@ inline const SVFValue* getTaskDataAtHareParForSite(const SVFInstruction *inst)
636
636
  }
637
637
  //@}
638
638
 
639
- inline bool isProgEntryFunction (const Function* fun)
640
- {
641
- return fun && fun->getName() == "main";
642
- }
643
-
644
-
645
639
  inline bool isProgExitCall(const CallSite cs)
646
640
  {
647
641
  return isProgExitFunction(getCallee(cs));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1363",
3
+ "version": "1.0.1365",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {