svf-lib 1.0.1276 → 1.0.1278

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 (60) hide show
  1. package/SVF-linux/Release-build/lib/libSvf.a +0 -0
  2. package/SVF-linux/include/Graphs/ConsGNode.h +48 -24
  3. package/SVF-linux/include/Graphs/GenericGraph.h +4 -2
  4. package/SVF-linux/include/Graphs/ICFG.h +3 -2
  5. package/SVF-linux/include/Graphs/SVFGOPT.h +7 -7
  6. package/SVF-linux/include/Graphs/VFG.h +3 -2
  7. package/SVF-linux/include/MSSA/MemSSA.h +6 -6
  8. package/SVF-linux/include/MemoryModel/PersistentPointsToDS.h +1 -1
  9. package/SVF-linux/include/MemoryModel/SVFIR.h +3 -1
  10. package/SVF-linux/include/SABER/SaberCondAllocator.h +7 -2
  11. package/SVF-linux/include/SVF-FE/IRAnnotator.h +3 -1
  12. package/SVF-linux/include/Util/SparseBitVector.h +2 -0
  13. package/SVF-osx/Release-build/lib/libSvf.a +0 -0
  14. package/SVF-osx/include/DDA/DDAVFSolver.h +1 -2
  15. package/SVF-osx/include/Graphs/ICFG.h +16 -16
  16. package/SVF-osx/include/Graphs/ICFGEdge.h +6 -6
  17. package/SVF-osx/include/Graphs/ICFGNode.h +16 -16
  18. package/SVF-osx/include/Graphs/IRGraph.h +6 -6
  19. package/SVF-osx/include/Graphs/ThreadCallGraph.h +2 -2
  20. package/SVF-osx/include/Graphs/VFGNode.h +1 -1
  21. package/SVF-osx/include/MSSA/MSSAMuChi.h +11 -11
  22. package/SVF-osx/include/MSSA/MemRegion.h +2 -2
  23. package/SVF-osx/include/MSSA/MemSSA.h +13 -13
  24. package/SVF-osx/include/MTA/FSMPTA.h +1 -1
  25. package/SVF-osx/include/MTA/LockAnalysis.h +33 -33
  26. package/SVF-osx/include/MTA/LockResultValidator.h +7 -6
  27. package/SVF-osx/include/MTA/MHP.h +46 -46
  28. package/SVF-osx/include/MTA/MTA.h +4 -4
  29. package/SVF-osx/include/MTA/MTAAnnotator.h +6 -4
  30. package/SVF-osx/include/MTA/MTAResultValidator.h +51 -44
  31. package/SVF-osx/include/MTA/PCG.h +22 -27
  32. package/SVF-osx/include/MTA/TCT.h +28 -37
  33. package/SVF-osx/include/MemoryModel/SVFStatements.h +11 -6
  34. package/SVF-osx/include/MemoryModel/SVFVariables.h +4 -4
  35. package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +13 -19
  36. package/SVF-osx/include/SABER/ProgSlice.h +5 -5
  37. package/SVF-osx/include/SABER/SaberCheckerAPI.h +4 -4
  38. package/SVF-osx/include/SABER/SaberCondAllocator.h +32 -35
  39. package/SVF-osx/include/SVF-FE/BasicTypes.h +10 -0
  40. package/SVF-osx/include/SVF-FE/CPPUtil.h +9 -8
  41. package/SVF-osx/include/SVF-FE/DCHG.h +4 -4
  42. package/SVF-osx/include/SVF-FE/DataFlowUtil.h +1 -1
  43. package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
  44. package/SVF-osx/include/SVF-FE/ICFGBuilder.h +9 -9
  45. package/SVF-osx/include/SVF-FE/IRAnnotator.h +9 -9
  46. package/SVF-osx/include/SVF-FE/LLVMModule.h +119 -22
  47. package/SVF-osx/include/SVF-FE/LLVMUtil.h +31 -52
  48. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +14 -20
  49. package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +8 -8
  50. package/SVF-osx/include/Util/Annotator.h +22 -22
  51. package/SVF-osx/include/Util/BasicTypes.h +476 -72
  52. package/SVF-osx/include/Util/Casting.h +1 -1
  53. package/SVF-osx/include/Util/CxtStmt.h +13 -12
  54. package/SVF-osx/include/Util/SVFBasicTypes.h +0 -78
  55. package/SVF-osx/include/Util/SVFInstruction.h +40 -0
  56. package/SVF-osx/include/Util/SVFModule.h +58 -124
  57. package/SVF-osx/include/Util/SVFUtil.h +48 -39
  58. package/SVF-osx/include/Util/ThreadAPI.h +17 -28
  59. package/SVF-osx/include/WPA/WPAPass.h +4 -4
  60. package/package.json +1 -1
@@ -51,7 +51,6 @@ typedef GenericEdge<TCTNode> GenericTCTEdgeTy;
51
51
  class TCTEdge: public GenericTCTEdgeTy
52
52
  {
53
53
  public:
54
- typedef Set<const Instruction*> CallInstSet;
55
54
  enum CEDGEK
56
55
  {
57
56
  ThreadCreateEdge
@@ -140,14 +139,14 @@ class TCT: public GenericThreadCreateTreeTy
140
139
  public:
141
140
  typedef TCTEdge::ThreadCreateEdgeSet ThreadCreateEdgeSet;
142
141
  typedef ThreadCreateEdgeSet::iterator TCTNodeIter;
143
- typedef Set<const Function*> FunSet;
144
- typedef std::vector<const Instruction*> InstVec;
145
- typedef Set<const Instruction*> InstSet;
142
+ typedef Set<const SVFFunction*> FunSet;
143
+ typedef std::vector<const SVFInstruction*> InstVec;
144
+ typedef Set<const SVFInstruction*> InstSet;
146
145
  typedef Set<const PTACallGraphNode*> PTACGNodeSet;
147
146
  typedef Map<CxtThread,TCTNode*> CxtThreadToNodeMap;
148
147
  typedef Map<CxtThread,CallStrCxt> CxtThreadToForkCxt;
149
- typedef Map<CxtThread,const Function*> CxtThreadToFun;
150
- typedef Map<const Instruction*, const Loop*> InstToLoopMap;
148
+ typedef Map<CxtThread,const SVFFunction*> CxtThreadToFun;
149
+ typedef Map<const SVFInstruction*, const Loop*> InstToLoopMap;
151
150
  typedef FIFOWorkList<CxtThreadProc> CxtThreadProcVec;
152
151
  typedef Set<CxtThreadProc> CxtThreadProcSet;
153
152
  typedef SCCDetection<PTACallGraph*> ThreadCallGraphSCC;
@@ -169,15 +168,10 @@ public:
169
168
  destroy();
170
169
  }
171
170
  /// Get CallICFGNode given inst
172
- CallICFGNode* getCallICFGNode(const Instruction* inst)
171
+ CallICFGNode* getCallICFGNode(const SVFInstruction* inst)
173
172
  {
174
173
  return pta->getICFG()->getCallICFGNode(inst);
175
174
  }
176
- /// Get SVFFuntion given Function
177
- const SVFFunction* getSVFFun(const Function* fun) const
178
- {
179
- return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(fun);
180
- }
181
175
  /// Get SVFFModule
182
176
  SVFModule* getSVFModule() const
183
177
  {
@@ -272,18 +266,14 @@ public:
272
266
  for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(),
273
267
  ecit = callees.end(); cit!=ecit; cit++)
274
268
  {
275
- if(candidateFuncSet.find((*cit)->getLLVMFun())!=candidateFuncSet.end())
269
+ if(candidateFuncSet.find((*cit))!=candidateFuncSet.end())
276
270
  return true;
277
271
  }
278
272
  return false;
279
273
  }
280
- inline bool isCandidateFun(const Function* fun) const
281
- {
282
- return candidateFuncSet.find(fun)!=candidateFuncSet.end();
283
- }
284
274
  inline bool isCandidateFun(const SVFFunction* fun) const
285
275
  {
286
- return isCandidateFun(fun->getLLVMFun());
276
+ return candidateFuncSet.find(fun)!=candidateFuncSet.end();
287
277
  }
288
278
  /// Whether two functions in the same callgraph scc
289
279
  inline bool inSameCallGraphSCC(const PTACallGraphNode* src,const PTACallGraphNode* dst)
@@ -357,7 +347,7 @@ public:
357
347
  }
358
348
 
359
349
  /// get the start routine function of a thread
360
- const Function* getStartRoutineOfCxtThread(const CxtThread& ct) const
350
+ const SVFFunction* getStartRoutineOfCxtThread(const CxtThread& ct) const
361
351
  {
362
352
  CxtThreadToFun::const_iterator it = ctToRoutineFunMap.find(ct);
363
353
  assert(it!=ctToRoutineFunMap.end() && "Cxt Thread not found!!");
@@ -365,7 +355,7 @@ public:
365
355
  }
366
356
 
367
357
  /// Get loop for join site
368
- inline const Loop* getJoinLoop(const Instruction* join)
358
+ inline const Loop* getJoinLoop(const SVFInstruction* join)
369
359
  {
370
360
  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
371
361
  InstToLoopMap::const_iterator it = joinSiteToLoopMap.find(join);
@@ -374,24 +364,24 @@ public:
374
364
  return nullptr;
375
365
  }
376
366
  /// Return true if a join instruction must be executed inside a loop
377
- bool isJoinMustExecutedInLoop(const Loop* lp,const Instruction* join);
367
+ bool isJoinMustExecutedInLoop(const Loop* lp,const SVFInstruction* join);
378
368
  /// Get loop for an instruction
379
- const Loop* getLoop(const Instruction* inst);
369
+ const Loop* getLoop(const SVFInstruction* inst);
380
370
  /// Get dominator for a function
381
371
  const DominatorTree* getDT(const Function* fun);
382
372
  /// Get dominator for a function
383
373
  const PostDominatorTree* getPostDT(const Function* fun);
384
374
  /// Get loop for fork/join site
385
- const Loop* getLoop(const BasicBlock* bb);
375
+ const Loop* getLoop(const SVFBasicBlock* bb);
386
376
  /// Get SE for function
387
- ScalarEvolution* getSE(const Instruction* inst);
377
+ ScalarEvolution* getSE(const SVFInstruction* inst);
388
378
 
389
379
  /// Get the next instructions following control flow
390
- void getNextInsts(const Instruction* inst, InstVec& instSet);
380
+ void getNextInsts(const SVFInstruction* inst, InstVec& instSet);
391
381
  /// Push calling context
392
- void pushCxt(CallStrCxt& cxt, const Instruction* call, const Function* callee);
382
+ void pushCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee);
393
383
  /// Match context
394
- bool matchCxt(CallStrCxt& cxt, const Instruction* call, const Function* callee);
384
+ bool matchCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee);
395
385
 
396
386
  inline void pushCxt(CallStrCxt& cxt, CallSiteID csId)
397
387
  {
@@ -400,7 +390,7 @@ public:
400
390
  MaxCxtSize = cxt.size();
401
391
  }
402
392
  /// Whether a join site is in recursion
403
- inline bool isJoinSiteInRecursion(const Instruction* join) const
393
+ inline bool isJoinSiteInRecursion(const SVFInstruction* join) const
404
394
  {
405
395
  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
406
396
  return inRecurJoinSites.find(join)!=inRecurJoinSites.end();
@@ -452,7 +442,7 @@ private:
452
442
  /// Mark relevant procedures that are backward reachable from any fork/join site
453
443
  //@{
454
444
  void markRelProcs();
455
- void markRelProcs(const Function* fun);
445
+ void markRelProcs(const SVFFunction* fun);
456
446
  //@}
457
447
 
458
448
  /// Get entry functions that are neither called by other functions nor extern functions
@@ -467,17 +457,17 @@ private:
467
457
  /// collect loop info for join sites
468
458
  void collectLoopInfoForJoin();
469
459
  /// Whether a given bb is a loop head of a inloop join site
470
- bool isLoopHeaderOfJoinLoop(const BasicBlock* bb);
460
+ bool isLoopHeaderOfJoinLoop(const SVFBasicBlock* bb);
471
461
  /// Whether a given bb is an exit of a inloop join site
472
- bool isLoopExitOfJoinLoop(const BasicBlock* bb);
462
+ bool isLoopExitOfJoinLoop(const SVFBasicBlock* bb);
473
463
  //@}
474
464
 
475
465
  /// Multi-forked threads
476
466
  //@{
477
467
  /// Whether an instruction is in a loop
478
- bool isInLoopInstruction(const Instruction* inst);
468
+ bool isInLoopInstruction(const SVFInstruction* inst);
479
469
  /// Whether an instruction is in a recursion
480
- bool isInRecursion(const Instruction* inst) const;
470
+ bool isInRecursion(const SVFInstruction* inst) const;
481
471
  //@}
482
472
 
483
473
  /// Handle call relations
@@ -485,7 +475,7 @@ private:
485
475
 
486
476
  /// Get or create a tct node based on CxtThread
487
477
  //@{
488
- inline TCTNode* getOrCreateTCTNode(const CallStrCxt& cxt, const CallInst* fork,const CallStrCxt& oldCxt, const Function* routine)
478
+ inline TCTNode* getOrCreateTCTNode(const CallStrCxt& cxt, const SVFInstruction* fork,const CallStrCxt& oldCxt, const SVFFunction* routine)
489
479
  {
490
480
  CxtThread ct(cxt,fork);
491
481
  CxtThreadToNodeMap::const_iterator it = ctpToNodeMap.find(ct);
@@ -508,8 +498,9 @@ private:
508
498
  /// non-main thread
509
499
  if(ct.getThread() != nullptr)
510
500
  {
511
- ct.setInloop(isInLoopInstruction(ct.getThread()));
512
- ct.setIncycle(isInRecursion(ct.getThread()));
501
+ const SVFInstruction* svfInst = ct.getThread();
502
+ ct.setInloop(isInLoopInstruction(svfInst));
503
+ ct.setIncycle(isInRecursion(svfInst));
513
504
  }
514
505
  /// main thread
515
506
  else
@@ -525,7 +516,7 @@ private:
525
516
  ctToForkCxtMap[ct] = cxt;
526
517
  }
527
518
  /// Add start routine function of a cxt thread
528
- void addStartRoutineOfCxtThread(const Function* fun, const CxtThread& ct)
519
+ void addStartRoutineOfCxtThread(const SVFFunction* fun, const CxtThread& ct)
529
520
  {
530
521
  ctToRoutineFunMap[ct] = fun;
531
522
  }
@@ -58,7 +58,7 @@ public:
58
58
 
59
59
  private:
60
60
  const Value* value; ///< LLVM value
61
- const BasicBlock *basicBlock; ///< LLVM BasicBlock
61
+ const SVFBasicBlock* basicBlock; ///< LLVM BasicBlock
62
62
  ICFGNode *icfgNode; ///< ICFGNode
63
63
  EdgeID edgeId; ///< Edge ID
64
64
  public:
@@ -104,11 +104,16 @@ public:
104
104
 
105
105
  /// Get/set methods for llvm instruction
106
106
  //@{
107
- inline const Instruction* getInst() const
107
+ inline const SVFInstruction* getInst() const
108
108
  {
109
- return SVFUtil::dyn_cast<Instruction>(value);
109
+ if(const Instruction* i = SVFUtil::dyn_cast<Instruction>(value))
110
+ {
111
+ return LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(i);
112
+ }
113
+ else
114
+ return nullptr;
110
115
  }
111
- inline void setValue(const Value *val)
116
+ inline void setValue(const Value* val)
112
117
  {
113
118
  value = val;
114
119
  }
@@ -116,11 +121,11 @@ public:
116
121
  {
117
122
  return value;
118
123
  }
119
- inline void setBB(const BasicBlock *bb)
124
+ inline void setBB(const SVFBasicBlock* bb)
120
125
  {
121
126
  basicBlock = bb;
122
127
  }
123
- inline const BasicBlock* getBB() const
128
+ inline const SVFBasicBlock* getBB() const
124
129
  {
125
130
  return basicBlock;
126
131
  }
@@ -124,16 +124,16 @@ public:
124
124
  virtual const std::string getValueName() const = 0;
125
125
 
126
126
  /// Return the function that this SVFVar resides in. Return nullptr if it is a global or constantexpr node
127
- virtual inline const Function* getFunction() const
127
+ virtual inline const SVFFunction* getFunction() const
128
128
  {
129
129
  if(value)
130
130
  {
131
131
  if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(value))
132
- return inst->getParent()->getParent();
132
+ return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(inst->getParent()->getParent());
133
133
  else if (const Argument* arg = SVFUtil::dyn_cast<Argument>(value))
134
- return arg->getParent();
134
+ return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(arg->getParent());
135
135
  else if (const Function* fun = SVFUtil::dyn_cast<Function>(value))
136
- return fun;
136
+ return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(fun);
137
137
  }
138
138
  return nullptr;
139
139
  }
@@ -67,17 +67,14 @@ public:
67
67
  //{@
68
68
  /// llvm value to sym id map
69
69
  /// local (%) and global (@) identifiers are pointer types which have a value node id.
70
- typedef OrderedMap<const Value *, SymID> ValueToIDMapTy;
70
+ typedef OrderedMap<const Value*, SymID> ValueToIDMapTy;
71
71
  /// sym id to memory object map
72
72
  typedef OrderedMap<SymID,MemObj*> IDToMemMapTy;
73
73
  /// function to sym id map
74
- typedef OrderedMap<const Function *, SymID> FunToIDMapTy;
74
+ typedef OrderedMap<const SVFFunction*, SymID> FunToIDMapTy;
75
75
  /// struct type to struct info map
76
76
  typedef OrderedMap<const Type*, StInfo*> TypeToFieldInfoMap;
77
77
  typedef Set<CallSite> CallSiteSet;
78
- typedef OrderedMap<const Instruction*,CallSiteID> CallSiteToIDMapTy;
79
- typedef OrderedMap<CallSiteID,const Instruction*> IDToCallSiteMapTy;
80
-
81
78
  //@}
82
79
 
83
80
  private:
@@ -161,15 +158,12 @@ public:
161
158
 
162
159
  /// special value
163
160
  // @{
164
- static bool isNullPtrSym(const Value *val);
165
- static bool isBlackholeSym(const Value *val);
166
- static bool isArgOfUncalledFunction(const Value *val);
167
- static bool isReturn(const Instruction *inst);
168
- static bool isPtrInUncalledFunction (const Value * value);
169
- static const u32_t getBBSuccessorNum(const BasicBlock *bb);
161
+ static bool isBlackholeSym(const Value* val);
162
+ static bool isArgOfUncalledFunction(const Value* val);
163
+ static bool isReturn(const SVFInstruction *inst);
164
+ static bool isPtrInUncalledFunction (const Value* value);
165
+ static const u32_t getBBSuccessorNum(const SVFBasicBlock* bb);
170
166
  static const Type* getPtrElementType(const PointerType* pty);
171
- static const u32_t getBBSuccessorPos(const BasicBlock *BB, const BasicBlock *Succ);
172
- static const u32_t getBBPredecessorPos(const BasicBlock *BB, const BasicBlock *Pred);
173
167
 
174
168
  static inline bool isBlkPtr(NodeID id)
175
169
  {
@@ -231,11 +225,11 @@ public:
231
225
 
232
226
  /// Get different kinds of syms
233
227
  //@{
234
- SymID getValSym(const Value *val);
228
+ SymID getValSym(const Value* val);
235
229
 
236
230
  bool hasValSym(const Value* val);
237
231
 
238
- inline SymID getObjSym(const Value *val) const
232
+ inline SymID getObjSym(const Value* val) const
239
233
  {
240
234
  ValueToIDMapTy::const_iterator iter = objSymMap.find(SVFUtil::getGlobalRep(val));
241
235
  assert(iter!=objSymMap.end() && "obj sym not found");
@@ -249,14 +243,14 @@ public:
249
243
  return iter->second;
250
244
  }
251
245
 
252
- inline SymID getRetSym(const Function *val) const
246
+ inline SymID getRetSym(const SVFFunction* val) const
253
247
  {
254
248
  FunToIDMapTy::const_iterator iter = returnSymMap.find(val);
255
249
  assert(iter!=returnSymMap.end() && "ret sym not found");
256
250
  return iter->second;
257
251
  }
258
252
 
259
- inline SymID getVarargSym(const Function *val) const
253
+ inline SymID getVarargSym(const SVFFunction* val) const
260
254
  {
261
255
  FunToIDMapTy::const_iterator iter = varargSymMap.find(val);
262
256
  assert(iter!=varargSymMap.end() && "vararg sym not found");
@@ -382,13 +376,13 @@ private:
382
376
  /// Type information of this object
383
377
  ObjTypeInfo* typeInfo;
384
378
  /// The unique value of this symbol/variable
385
- const Value *refVal;
379
+ const Value* refVal;
386
380
  /// The unique id to represent this symbol
387
381
  SymID symId;
388
382
 
389
383
  public:
390
384
  /// Constructor
391
- MemObj(SymID id, ObjTypeInfo* ti, const Value *val = nullptr);
385
+ MemObj(SymID id, ObjTypeInfo* ti, const Value* val = nullptr);
392
386
 
393
387
  /// Destructor
394
388
  virtual ~MemObj()
@@ -55,7 +55,7 @@ public:
55
55
  typedef Map<const SVFGNode*, Condition> SVFGNodeToCondMap; ///< map a SVFGNode to its condition during value-flow guard computation
56
56
 
57
57
  typedef FIFOWorkList<const SVFGNode*> VFWorkList; ///< worklist for value-flow guard computation
58
- typedef FIFOWorkList<const BasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
58
+ typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
59
59
 
60
60
  /// Constructor
61
61
  ProgSlice(const SVFGNode* src, SaberCondAllocator* pa, const SVFG* graph):
@@ -246,15 +246,15 @@ protected:
246
246
 
247
247
  /// Compute guards for value-flows
248
248
  //@{
249
- inline Condition ComputeIntraVFGGuard(const BasicBlock* src, const BasicBlock* dst)
249
+ inline Condition ComputeIntraVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst)
250
250
  {
251
251
  return pathAllocator->ComputeIntraVFGGuard(src,dst);
252
252
  }
253
- inline Condition ComputeInterCallVFGGuard(const BasicBlock* src, const BasicBlock* dst, const BasicBlock* callBB)
253
+ inline Condition ComputeInterCallVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* callBB)
254
254
  {
255
255
  return pathAllocator->ComputeInterCallVFGGuard(src,dst,callBB);
256
256
  }
257
- inline Condition ComputeInterRetVFGGuard(const BasicBlock* src, const BasicBlock* dst, const BasicBlock* retBB)
257
+ inline Condition ComputeInterRetVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* retBB)
258
258
  {
259
259
  return pathAllocator->ComputeInterRetVFGGuard(src,dst,retBB);
260
260
  }
@@ -268,7 +268,7 @@ protected:
268
268
  /// Return the basic block where a SVFGNode resides in
269
269
  /// a SVFGNode may not in a basic block if it is not a program statement
270
270
  /// (e.g. PAGEdge is an global assignment or NullPtrSVFGNode)
271
- inline const BasicBlock* getSVFGNodeBB(const SVFGNode* node) const
271
+ inline const SVFBasicBlock* getSVFGNodeBB(const SVFGNode* node) const
272
272
  {
273
273
  const ICFGNode* icfgNode = node->getICFGNode();
274
274
  if(SVFUtil::isa<NullPtrSVFGNode>(node) == false)
@@ -101,7 +101,7 @@ public:
101
101
  {
102
102
  return getType(fun) == CK_ALLOC;
103
103
  }
104
- inline bool isMemAlloc(const Instruction *inst) const
104
+ inline bool isMemAlloc(const SVFInstruction* inst) const
105
105
  {
106
106
  return getType(SVFUtil::getCallee(inst)) == CK_ALLOC;
107
107
  }
@@ -117,7 +117,7 @@ public:
117
117
  {
118
118
  return getType(fun) == CK_FREE;
119
119
  }
120
- inline bool isMemDealloc(const Instruction *inst) const
120
+ inline bool isMemDealloc(const SVFInstruction *inst) const
121
121
  {
122
122
  return getType(SVFUtil::getCallee(inst)) == CK_FREE;
123
123
  }
@@ -133,7 +133,7 @@ public:
133
133
  {
134
134
  return getType(fun) == CK_FOPEN;
135
135
  }
136
- inline bool isFOpen(const Instruction *inst) const
136
+ inline bool isFOpen(const SVFInstruction* inst) const
137
137
  {
138
138
  return getType(SVFUtil::getCallee(inst)) == CK_FOPEN;
139
139
  }
@@ -149,7 +149,7 @@ public:
149
149
  {
150
150
  return getType(fun) == CK_FCLOSE;
151
151
  }
152
- inline bool isFClose(const Instruction *inst) const
152
+ inline bool isFClose(const SVFInstruction* inst) const
153
153
  {
154
154
  return getType(SVFUtil::getCallee(inst)) == CK_FCLOSE;
155
155
  }
@@ -50,13 +50,13 @@ class SaberCondAllocator
50
50
  public:
51
51
 
52
52
  typedef Z3Expr Condition; /// z3 condition
53
- typedef Map<u32_t, const Instruction *> IndexToTermInstMap; /// id to instruction map for z3
53
+ typedef Map<u32_t, const SVFInstruction *> IndexToTermInstMap; /// id to instruction map for z3
54
54
  typedef Map<u32_t,Condition> CondPosMap; ///< map a branch to its Condition
55
- typedef Map<const BasicBlock*, CondPosMap > BBCondMap; /// map bb to a Condition
56
- typedef Set<const BasicBlock*> BasicBlockSet;
57
- typedef Map<const Function*, BasicBlockSet> FunToExitBBsMap; ///< map a function to all its basic blocks calling program exit
58
- typedef Map<const BasicBlock*, Condition> BBToCondMap; ///< map a basic block to its condition during control-flow guard computation
59
- typedef FIFOWorkList<const BasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
55
+ typedef Map<const SVFBasicBlock*, CondPosMap > BBCondMap; /// map bb to a Condition
56
+ typedef Set<const SVFBasicBlock*> BasicBlockSet;
57
+ typedef Map<const SVFFunction*, BasicBlockSet> FunToExitBBsMap; ///< map a function to all its basic blocks calling program exit
58
+ typedef Map<const SVFBasicBlock*, Condition> BBToCondMap; ///< map a basic block to its condition during control-flow guard computation
59
+ typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
60
60
 
61
61
 
62
62
  /// Constructor
@@ -118,21 +118,21 @@ public:
118
118
  }
119
119
 
120
120
  /// Allocate a new condition
121
- Condition newCond(const Instruction* inst);
121
+ Condition newCond(const SVFInstruction* inst);
122
122
 
123
123
  /// Perform path allocation
124
124
  void allocate(const SVFModule* module);
125
125
 
126
126
  /// Get/Set instruction based on Z3 expression id
127
127
  //{@
128
- inline const Instruction *getCondInst(u32_t id) const
128
+ inline const SVFInstruction* getCondInst(u32_t id) const
129
129
  {
130
130
  IndexToTermInstMap::const_iterator it = idToTermInstMap.find(id);
131
131
  assert(it != idToTermInstMap.end() && "this should be a fresh condition");
132
132
  return it->second;
133
133
  }
134
134
 
135
- inline void setCondInst(const Condition &condition, const Instruction *inst)
135
+ inline void setCondInst(const Condition &condition, const SVFInstruction* inst)
136
136
  {
137
137
  assert(idToTermInstMap.find(condition.id()) == idToTermInstMap.end() && "this should be a fresh condition");
138
138
  idToTermInstMap[condition.id()] = inst;
@@ -144,38 +144,35 @@ public:
144
144
  return negConds.test(id);
145
145
  }
146
146
 
147
- inline bool postDominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
147
+ inline bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
148
148
  {
149
- const SVFFunction* keyFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbKey->getParent());
150
- const SVFFunction* valueFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbValue->getParent());
149
+ const SVFFunction* keyFunc = bbKey->getParent();
150
+ const SVFFunction* valueFunc = bbValue->getParent();
151
151
  bool funcEq = (keyFunc == valueFunc);
152
152
  (void)funcEq; // Suppress warning of unused variable under release build
153
153
  assert(funcEq && "two basicblocks should be in the same function!");
154
-
155
154
  return keyFunc->postDominate(bbKey,bbValue);
156
155
  }
157
156
 
158
- inline bool dominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
157
+ inline bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
159
158
  {
160
- const SVFFunction* keyFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbKey->getParent());
161
- const SVFFunction* valueFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbValue->getParent());
159
+ const SVFFunction* keyFunc = bbKey->getParent();
160
+ const SVFFunction* valueFunc = bbValue->getParent();
162
161
  bool funcEq = (keyFunc == valueFunc);
163
162
  (void)funcEq; // Suppress warning of unused variable under release build
164
-
165
163
  assert(funcEq && "two basicblocks should be in the same function!");
166
-
167
164
  return keyFunc->dominate(bbKey,bbValue);
168
165
  }
169
166
 
170
167
  /// Guard Computation for a value-flow (between two basic blocks)
171
168
  //@{
172
- virtual Condition ComputeIntraVFGGuard(const BasicBlock* src, const BasicBlock* dst);
173
- virtual Condition ComputeInterCallVFGGuard(const BasicBlock* src, const BasicBlock* dst, const BasicBlock* callBB);
174
- virtual Condition ComputeInterRetVFGGuard(const BasicBlock* src, const BasicBlock* dst, const BasicBlock* retBB);
169
+ virtual Condition ComputeIntraVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst);
170
+ virtual Condition ComputeInterCallVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* callBB);
171
+ virtual Condition ComputeInterRetVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* retBB);
175
172
 
176
173
  /// Get complement condition (from B1 to B0) according to a complementBB (BB2) at a phi
177
174
  /// e.g., B0: dstBB; B1:incomingBB; B2:complementBB
178
- virtual Condition getPHIComplementCond(const BasicBlock* BB1, const BasicBlock* BB2, const BasicBlock* BB0);
175
+ virtual Condition getPHIComplementCond(const SVFBasicBlock* BB1, const SVFBasicBlock* BB2, const SVFBasicBlock* BB0);
179
176
 
180
177
  inline void clearCFCond()
181
178
  {
@@ -215,7 +212,7 @@ public:
215
212
 
216
213
  /// Get/Set control-flow conditions
217
214
  //@{
218
- inline bool setCFCond(const BasicBlock* bb, const Condition& cond)
215
+ inline bool setCFCond(const SVFBasicBlock* bb, const Condition& cond)
219
216
  {
220
217
  BBToCondMap::iterator it = bbToCondMap.find(bb);
221
218
  // until a fixed-point is reached (condition is not changed)
@@ -225,7 +222,7 @@ public:
225
222
  bbToCondMap[bb] = cond;
226
223
  return true;
227
224
  }
228
- inline Condition getCFCond(const BasicBlock* bb) const
225
+ inline Condition getCFCond(const SVFBasicBlock* bb) const
229
226
  {
230
227
  BBToCondMap::const_iterator it = bbToCondMap.find(bb);
231
228
  if(it==bbToCondMap.end())
@@ -238,7 +235,7 @@ public:
238
235
 
239
236
 
240
237
  /// mark neg Z3 expression
241
- inline void setNegCondInst(const Condition &condition, const Instruction *inst)
238
+ inline void setNegCondInst(const Condition &condition, const SVFInstruction* inst)
242
239
  {
243
240
  setCondInst(condition, inst);
244
241
  negConds.set(condition.id());
@@ -246,30 +243,30 @@ public:
246
243
  private:
247
244
 
248
245
  /// Allocate path condition for every basic block
249
- virtual void allocateForBB(const BasicBlock& bb);
246
+ virtual void allocateForBB(const SVFBasicBlock& bb);
250
247
 
251
248
  /// Get/Set a branch condition, and its terminator instruction
252
249
  //@{
253
250
  /// Set branch condition
254
- void setBranchCond(const BasicBlock *bb, const BasicBlock *succ, const Condition& cond);
251
+ void setBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ, const Condition& cond);
255
252
  /// Get branch condition
256
- Condition getBranchCond(const BasicBlock * bb, const BasicBlock *succ) const;
253
+ Condition getBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ) const;
257
254
  ///Get a condition, evaluate the value for conditions if necessary (e.g., testNull like express)
258
- Condition getEvalBrCond(const BasicBlock * bb, const BasicBlock *succ);
255
+ Condition getEvalBrCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ);
259
256
  //@}
260
257
  /// Evaluate branch conditions
261
258
  //@{
262
259
  /// Evaluate the branch condtion
263
- Condition evaluateBranchCond(const BasicBlock * bb, const BasicBlock *succ) ;
260
+ Condition evaluateBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ) ;
264
261
  /// Evaluate loop exit branch
265
- Condition evaluateLoopExitBranch(const BasicBlock * bb, const BasicBlock *succ);
262
+ Condition evaluateLoopExitBranch(const SVFBasicBlock* bb, const SVFBasicBlock* succ);
266
263
  /// Return branch condition after evaluating test null like expression
267
- Condition evaluateTestNullLikeExpr(const BranchStmt* branchStmt, const BasicBlock *succ);
264
+ Condition evaluateTestNullLikeExpr(const BranchStmt* branchStmt, const SVFBasicBlock* succ);
268
265
  /// Return condition when there is a branch calls program exit
269
- Condition evaluateProgExit(const BranchStmt* branchStmt, const BasicBlock *succ);
266
+ Condition evaluateProgExit(const BranchStmt* branchStmt, const SVFBasicBlock* succ);
270
267
  /// Collect basic block contains program exit function call
271
- void collectBBCallingProgExit(const BasicBlock& bb);
272
- bool isBBCallsProgExit(const BasicBlock* bb);
268
+ void collectBBCallingProgExit(const SVFBasicBlock& bb);
269
+ bool isBBCallsProgExit(const SVFBasicBlock* bb);
273
270
  //@}
274
271
 
275
272
  /// Evaluate test null/not null like expressions
@@ -88,6 +88,9 @@ typedef llvm::LoopInfo LoopInfo;
88
88
  typedef llvm::User User;
89
89
 
90
90
  // LLVM Instructions
91
+ typedef llvm::CallInst CallInst;
92
+ typedef llvm::StoreInst StoreInst;
93
+ typedef llvm::LoadInst LoadInst;
91
94
  typedef llvm::AllocaInst AllocaInst;
92
95
  typedef llvm::AtomicCmpXchgInst AtomicCmpXchgInst;
93
96
  typedef llvm::AtomicRMWInst AtomicRMWInst;
@@ -183,6 +186,7 @@ namespace dwarf = llvm::dwarf;
183
186
 
184
187
  // Iterators.
185
188
  typedef llvm::inst_iterator inst_iterator;
189
+ typedef llvm::const_inst_iterator const_inst_iterator;
186
190
  typedef llvm::gep_type_iterator gep_type_iterator;
187
191
  typedef llvm::bridge_gep_iterator bridge_gep_iterator;
188
192
  typedef llvm::const_inst_iterator const_inst_iterator;
@@ -204,6 +208,12 @@ typedef llvm::VectorType VectorType;
204
208
  typedef llvm::FunctionCallee FunctionCallee;
205
209
  #endif
206
210
 
211
+ /// LLVM Iterators
212
+ #if LLVM_VERSION_MAJOR >= 11
213
+ typedef llvm::const_succ_iterator succ_const_iterator;
214
+ #else
215
+ typedef llvm::succ_const_iterator succ_const_iterator;
216
+ #endif
207
217
  } // End namespace SVF
208
218
 
209
219
  #endif // SVF_FE_BASIC_TYPES_H
@@ -31,6 +31,7 @@
31
31
  #define CPPUtil_H_
32
32
 
33
33
  #include "Util/BasicTypes.h"
34
+ #include "SVF-FE/BasicTypes.h"
34
35
 
35
36
  namespace SVF
36
37
  {
@@ -53,13 +54,13 @@ struct DemangledName
53
54
  struct DemangledName demangle(const std::string &name);
54
55
 
55
56
  std::string getBeforeBrackets(const std::string &name);
56
- bool isValVtbl(const Value *val);
57
+ bool isValVtbl(const Value* val);
57
58
  bool isLoadVtblInst(const LoadInst *loadInst);
58
59
  bool isVirtualCallSite(CallSite cs);
59
- bool isConstructor(const Function *F);
60
- bool isDestructor(const Function *F);
61
- bool isCPPThunkFunction(const Function *F);
62
- const Function *getThunkTarget(const Function *F);
60
+ bool isConstructor(const Function* F);
61
+ bool isDestructor(const Function* F);
62
+ bool isCPPThunkFunction(const Function* F);
63
+ const Function* getThunkTarget(const Function* F);
63
64
 
64
65
  /*
65
66
  * VtableA = {&A::foo}
@@ -83,10 +84,10 @@ const Function *getThunkTarget(const Function *F);
83
84
  * getClassNameFromType(type of p) return type A
84
85
  */
85
86
  const Argument* getConstructorThisPtr(const Function* fun);
86
- const Value *getVCallThisPtr(CallSite cs);
87
- const Value *getVCallVtblPtr(CallSite cs);
87
+ const Value* getVCallThisPtr(CallSite cs);
88
+ const Value* getVCallVtblPtr(CallSite cs);
88
89
  u64_t getVCallIdx(CallSite cs);
89
- std::string getClassNameFromVtblObj(const Value *value);
90
+ std::string getClassNameFromVtblObj(const Value* value);
90
91
  std::string getClassNameFromType(const Type *ty);
91
92
  std::string getClassNameOfThisPtr(CallSite cs);
92
93
  std::string getFunNameOfVCallSite(CallSite cs);