svf-lib 1.0.2211 → 1.0.2213

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 (96) hide show
  1. package/SVF-linux/Release-build/bin/ae +0 -0
  2. package/SVF-linux/Release-build/bin/cfl +0 -0
  3. package/SVF-linux/Release-build/bin/dvf +0 -0
  4. package/SVF-linux/Release-build/bin/llvm2svf +0 -0
  5. package/SVF-linux/Release-build/bin/mta +0 -0
  6. package/SVF-linux/Release-build/bin/saber +0 -0
  7. package/SVF-linux/Release-build/bin/svf-ex +0 -0
  8. package/SVF-linux/Release-build/bin/wpa +0 -0
  9. package/SVF-linux/Release-build/include/AE/Svfexe/AbstractInterpretation.h +2 -2
  10. package/SVF-linux/Release-build/include/CFL/CFLAlias.h +1 -1
  11. package/SVF-linux/Release-build/include/DDA/ContextDDA.h +6 -6
  12. package/SVF-linux/Release-build/include/DDA/DDAVFSolver.h +2 -2
  13. package/SVF-linux/Release-build/include/DDA/FlowDDA.h +2 -2
  14. package/SVF-linux/Release-build/include/Graphs/BasicBlockG.h +17 -9
  15. package/SVF-linux/Release-build/include/Graphs/CHG.h +7 -7
  16. package/SVF-linux/Release-build/include/Graphs/CallGraph.h +23 -27
  17. package/SVF-linux/Release-build/include/Graphs/ConsG.h +2 -2
  18. package/SVF-linux/Release-build/include/Graphs/ICFG.h +11 -11
  19. package/SVF-linux/Release-build/include/Graphs/ICFGNode.h +12 -18
  20. package/SVF-linux/Release-build/include/Graphs/IRGraph.h +11 -9
  21. package/SVF-linux/Release-build/include/Graphs/SVFG.h +13 -13
  22. package/SVF-linux/Release-build/include/Graphs/SVFGNode.h +2 -2
  23. package/SVF-linux/Release-build/include/Graphs/ThreadCallGraph.h +3 -21
  24. package/SVF-linux/Release-build/include/Graphs/VFG.h +15 -15
  25. package/SVF-linux/Release-build/include/Graphs/VFGNode.h +10 -10
  26. package/SVF-linux/Release-build/include/MSSA/MSSAMuChi.h +6 -6
  27. package/SVF-linux/Release-build/include/MSSA/MemPartition.h +12 -12
  28. package/SVF-linux/Release-build/include/MSSA/MemRegion.h +21 -21
  29. package/SVF-linux/Release-build/include/MSSA/MemSSA.h +10 -10
  30. package/SVF-linux/Release-build/include/MTA/LockAnalysis.h +4 -4
  31. package/SVF-linux/Release-build/include/MTA/MHP.h +8 -8
  32. package/SVF-linux/Release-build/include/MTA/TCT.h +10 -10
  33. package/SVF-linux/Release-build/include/MemoryModel/PointerAnalysis.h +4 -4
  34. package/SVF-linux/Release-build/include/SABER/DoubleFreeChecker.h +2 -2
  35. package/SVF-linux/Release-build/include/SABER/FileChecker.h +2 -2
  36. package/SVF-linux/Release-build/include/SABER/LeakChecker.h +4 -4
  37. package/SVF-linux/Release-build/include/SABER/SaberCheckerAPI.h +6 -5
  38. package/SVF-linux/Release-build/include/SABER/SaberCondAllocator.h +5 -5
  39. package/SVF-linux/Release-build/include/SABER/SrcSnkDDA.h +2 -2
  40. package/SVF-linux/Release-build/include/SVF-LLVM/LLVMModule.h +83 -7
  41. package/SVF-linux/Release-build/include/SVF-LLVM/LLVMUtil.h +9 -1
  42. package/SVF-linux/Release-build/include/SVF-LLVM/SVFIRBuilder.h +5 -2
  43. package/SVF-linux/Release-build/include/SVFIR/SVFIR.h +20 -27
  44. package/SVF-linux/Release-build/include/SVFIR/SVFValue.h +3 -2
  45. package/SVF-linux/Release-build/include/SVFIR/SVFVariables.h +271 -71
  46. package/SVF-linux/Release-build/include/Util/CDGBuilder.h +1 -1
  47. package/SVF-linux/Release-build/include/Util/CallGraphBuilder.h +1 -1
  48. package/SVF-linux/Release-build/include/Util/CxtStmt.h +6 -6
  49. package/SVF-linux/Release-build/include/Util/ExtAPI.h +20 -16
  50. package/SVF-linux/Release-build/include/Util/SVFUtil.h +16 -30
  51. package/SVF-linux/Release-build/include/Util/ThreadAPI.h +2 -11
  52. package/SVF-linux/Release-build/include/WPA/Andersen.h +2 -2
  53. package/SVF-linux/Release-build/lib/libSvfCore.a +0 -0
  54. package/SVF-linux/Release-build/lib/libSvfLLVM.a +0 -0
  55. package/SVF-osx/Release-build/bin/ae +0 -0
  56. package/SVF-osx/Release-build/bin/cfl +0 -0
  57. package/SVF-osx/Release-build/bin/dvf +0 -0
  58. package/SVF-osx/Release-build/bin/llvm2svf +0 -0
  59. package/SVF-osx/Release-build/bin/mta +0 -0
  60. package/SVF-osx/Release-build/bin/saber +0 -0
  61. package/SVF-osx/Release-build/bin/svf-ex +0 -0
  62. package/SVF-osx/Release-build/bin/wpa +0 -0
  63. package/SVF-osx/Release-build/include/DDA/DDAClient.h +6 -11
  64. package/SVF-osx/Release-build/include/DDA/DDAPass.h +1 -1
  65. package/SVF-osx/Release-build/include/Graphs/CHG.h +2 -3
  66. package/SVF-osx/Release-build/include/Graphs/GenericGraph.h +1 -286
  67. package/SVF-osx/Release-build/include/MTA/MTA.h +2 -2
  68. package/SVF-osx/Release-build/include/MTA/TCT.h +0 -6
  69. package/SVF-osx/Release-build/include/MemoryModel/PointerAnalysis.h +1 -7
  70. package/SVF-osx/Release-build/include/SABER/DoubleFreeChecker.h +1 -1
  71. package/SVF-osx/Release-build/include/SABER/FileChecker.h +1 -1
  72. package/SVF-osx/Release-build/include/SABER/LeakChecker.h +1 -1
  73. package/SVF-osx/Release-build/include/SABER/SaberCondAllocator.h +1 -2
  74. package/SVF-osx/Release-build/include/SABER/SrcSnkDDA.h +2 -2
  75. package/SVF-osx/Release-build/include/SVF-LLVM/BreakConstantExpr.h +1 -1
  76. package/SVF-osx/Release-build/include/SVF-LLVM/CppUtil.h +1 -1
  77. package/SVF-osx/Release-build/include/SVF-LLVM/DCHG.h +1 -1
  78. package/SVF-osx/Release-build/include/SVF-LLVM/LLVMLoopAnalysis.h +1 -1
  79. package/SVF-osx/Release-build/include/SVF-LLVM/LLVMModule.h +2 -2
  80. package/SVF-osx/Release-build/include/SVF-LLVM/LLVMUtil.h +1 -1
  81. package/SVF-osx/Release-build/include/SVF-LLVM/ObjTypeInference.h +1 -1
  82. package/SVF-osx/Release-build/include/{SVFIR → SVF-LLVM}/SVFModule.h +1 -36
  83. package/SVF-osx/Release-build/include/SVF-LLVM/SVFValue.h +805 -0
  84. package/SVF-osx/Release-build/include/SVFIR/ObjTypeInfo.h +0 -1
  85. package/SVF-osx/Release-build/include/SVFIR/SVFIR.h +38 -11
  86. package/SVF-osx/Release-build/include/SVFIR/SVFStatements.h +1 -0
  87. package/SVF-osx/Release-build/include/SVFIR/SVFValue.h +202 -799
  88. package/SVF-osx/Release-build/include/Util/CDGBuilder.h +1 -1
  89. package/SVF-osx/Release-build/include/Util/GeneralType.h +1 -0
  90. package/SVF-osx/Release-build/include/Util/SVFLoopAndDomInfo.h +169 -0
  91. package/SVF-osx/Release-build/include/Util/SVFUtil.h +3 -1
  92. package/SVF-osx/Release-build/include/Util/ThreadAPI.h +2 -1
  93. package/SVF-osx/Release-build/include/WPA/FlowSensitive.h +1 -1
  94. package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
  95. package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
  96. package/package.json +1 -1
@@ -85,8 +85,8 @@ public:
85
85
  //@}
86
86
 
87
87
  /// Map from fun to its entry chi set and return mu set
88
- typedef Map<const SVFFunction*, CHISet> FunToEntryChiSetMap;
89
- typedef Map<const SVFFunction*, MUSet> FunToReturnMuSetMap;
88
+ typedef Map<const FunObjVar*, CHISet> FunToEntryChiSetMap;
89
+ typedef Map<const FunObjVar*, MUSet> FunToReturnMuSetMap;
90
90
 
91
91
  /// For phi insertion
92
92
  //@{
@@ -123,11 +123,11 @@ protected:
123
123
  MemSSAStat* stat;
124
124
 
125
125
  /// Create mu chi for candidate regions in a function
126
- virtual void createMUCHI(const SVFFunction& fun);
126
+ virtual void createMUCHI(const FunObjVar& fun);
127
127
  /// Insert phi for candidate regions in a function
128
- virtual void insertPHI(const SVFFunction& fun);
128
+ virtual void insertPHI(const FunObjVar& fun);
129
129
  /// SSA rename for a function
130
- virtual void SSARename(const SVFFunction& fun);
130
+ virtual void SSARename(const FunObjVar& fun);
131
131
  /// SSA rename for a basic block
132
132
  virtual void SSARenameBB(const SVFBasicBlock& bb);
133
133
  private:
@@ -315,7 +315,7 @@ public:
315
315
  return mrGen;
316
316
  }
317
317
  /// We start from here
318
- virtual void buildMemSSA(const SVFFunction& fun);
318
+ virtual void buildMemSSA(const FunObjVar& fun);
319
319
 
320
320
  /// Perform statistics
321
321
  void performStat();
@@ -357,20 +357,20 @@ public:
357
357
 
358
358
  /// Has function entry chi or return mu
359
359
  //@{
360
- inline bool hasFuncEntryChi(const SVFFunction * fun) const
360
+ inline bool hasFuncEntryChi(const FunObjVar * fun) const
361
361
  {
362
362
  return (funToEntryChiSetMap.find(fun) != funToEntryChiSetMap.end());
363
363
  }
364
- inline bool hasReturnMu(const SVFFunction * fun) const
364
+ inline bool hasReturnMu(const FunObjVar * fun) const
365
365
  {
366
366
  return (funToReturnMuSetMap.find(fun) != funToReturnMuSetMap.end());
367
367
  }
368
368
 
369
- inline CHISet& getFuncEntryChiSet(const SVFFunction * fun)
369
+ inline CHISet& getFuncEntryChiSet(const FunObjVar * fun)
370
370
  {
371
371
  return funToEntryChiSetMap[fun];
372
372
  }
373
- inline MUSet& getReturnMuSet(const SVFFunction * fun)
373
+ inline MUSet& getReturnMuSet(const FunObjVar * fun)
374
374
  {
375
375
  return funToReturnMuSetMap[fun];
376
376
  }
@@ -61,7 +61,7 @@ public:
61
61
  typedef Set<const ICFGNode*> InstSet;
62
62
  typedef InstSet CISpan;
63
63
  typedef Map<const ICFGNode*, CISpan>CILockToSpan;
64
- typedef Set<const SVFFunction*> FunSet;
64
+ typedef Set<const FunObjVar*> FunSet;
65
65
  typedef Map<const ICFGNode*, InstSet> InstToInstSetMap;
66
66
  typedef Map<CxtStmt, ValDomain> CxtStmtToLockFlagMap;
67
67
  typedef FIFOWorkList<CxtStmt> CxtStmtWorkList;
@@ -192,7 +192,7 @@ public:
192
192
  //@}
193
193
 
194
194
  /// Return true if it is a candidate function
195
- inline bool isLockCandidateFun(const SVFFunction* fun) const
195
+ inline bool isLockCandidateFun(const FunObjVar* fun) const
196
196
  {
197
197
  return lockcandidateFuncSet.find(fun)!=lockcandidateFuncSet.end();
198
198
  }
@@ -430,9 +430,9 @@ private:
430
430
  //@}
431
431
 
432
432
  /// Push calling context
433
- void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee);
433
+ void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee);
434
434
  /// Match context
435
- bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee);
435
+ bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee);
436
436
 
437
437
  /// Whether it is a lock site
438
438
  inline bool isTDFork(const ICFGNode* call)
@@ -46,7 +46,7 @@ class MHP
46
46
  {
47
47
 
48
48
  public:
49
- typedef Set<const SVFFunction*> FunSet;
49
+ typedef Set<const FunObjVar*> FunSet;
50
50
  typedef FIFOWorkList<CxtThreadStmt> CxtThreadStmtWorkList;
51
51
  typedef Set<CxtThreadStmt> CxtThreadStmtSet;
52
52
  typedef Map<CxtThreadStmt,NodeBS> ThreadStmtToThreadInterleav;
@@ -55,7 +55,7 @@ public:
55
55
 
56
56
  typedef Set<CxtStmt> LockSpan;
57
57
 
58
- typedef std::pair<const SVFFunction*,const SVFFunction*> FuncPair;
58
+ typedef std::pair<const FunObjVar*,const FunObjVar*> FuncPair;
59
59
  typedef Map<FuncPair, bool> FuncPairToBool;
60
60
 
61
61
  /// Constructor
@@ -83,7 +83,7 @@ public:
83
83
  }
84
84
 
85
85
  /// Whether the function is connected from main function in thread call graph
86
- bool isConnectedfromMain(const SVFFunction* fun);
86
+ bool isConnectedfromMain(const FunObjVar* fun);
87
87
 
88
88
  // LockSpan getSpanfromCxtLock(NodeID l);
89
89
  /// Interface to query whether two instructions may happen-in-parallel
@@ -202,12 +202,12 @@ private:
202
202
  return tct->getTCTNode(curTid)->isMultiforked();
203
203
  }
204
204
  /// Push calling context
205
- inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
205
+ inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
206
206
  {
207
207
  tct->pushCxt(cxt,call,callee);
208
208
  }
209
209
  /// Match context
210
- inline bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
210
+ inline bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
211
211
  {
212
212
  return tct->matchCxt(cxt,call,callee);
213
213
  }
@@ -342,7 +342,7 @@ public:
342
342
  {
343
343
  NodeID parentTid = tct->getParentThread(tid);
344
344
  const CxtThread& parentct = tct->getTCTNode(parentTid)->getCxtThread();
345
- const SVFFunction* parentRoutine = tct->getStartRoutineOfCxtThread(parentct);
345
+ const FunObjVar* parentRoutine = tct->getStartRoutineOfCxtThread(parentct);
346
346
  return parentRoutine->getExitBB()->back();
347
347
  }
348
348
 
@@ -450,12 +450,12 @@ private:
450
450
  //@}
451
451
 
452
452
  /// Push calling context
453
- inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
453
+ inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
454
454
  {
455
455
  tct->pushCxt(cxt,call,callee);
456
456
  }
457
457
  /// Match context
458
- inline bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
458
+ inline bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
459
459
  {
460
460
  return tct->matchCxt(cxt,call,callee);
461
461
  }
@@ -157,13 +157,13 @@ public:
157
157
  typedef SVFLoopAndDomInfo::LoopBBs LoopBBs;
158
158
  typedef TCTEdge::ThreadCreateEdgeSet ThreadCreateEdgeSet;
159
159
  typedef ThreadCreateEdgeSet::iterator TCTNodeIter;
160
- typedef Set<const SVFFunction*> FunSet;
160
+ typedef Set<const FunObjVar*> FunSet;
161
161
  typedef std::vector<const ICFGNode*> InstVec;
162
162
  typedef Set<const ICFGNode*> InstSet;
163
163
  typedef Set<const CallGraphNode*> PTACGNodeSet;
164
164
  typedef Map<CxtThread,TCTNode*> CxtThreadToNodeMap;
165
165
  typedef Map<CxtThread,CallStrCxt> CxtThreadToForkCxt;
166
- typedef Map<CxtThread,const SVFFunction*> CxtThreadToFun;
166
+ typedef Map<CxtThread,const FunObjVar*> CxtThreadToFun;
167
167
  typedef Map<const ICFGNode*, LoopBBs> InstToLoopMap;
168
168
  typedef FIFOWorkList<CxtThreadProc> CxtThreadProcVec;
169
169
  typedef Set<CxtThreadProc> CxtThreadProcSet;
@@ -298,7 +298,7 @@ public:
298
298
  }
299
299
  return false;
300
300
  }
301
- inline bool isCandidateFun(const SVFFunction* fun) const
301
+ inline bool isCandidateFun(const FunObjVar* fun) const
302
302
  {
303
303
  return candidateFuncSet.find(fun)!=candidateFuncSet.end();
304
304
  }
@@ -374,7 +374,7 @@ public:
374
374
  }
375
375
 
376
376
  /// get the start routine function of a thread
377
- const SVFFunction* getStartRoutineOfCxtThread(const CxtThread& ct) const
377
+ const FunObjVar* getStartRoutineOfCxtThread(const CxtThread& ct) const
378
378
  {
379
379
  CxtThreadToFun::const_iterator it = ctToRoutineFunMap.find(ct);
380
380
  assert(it!=ctToRoutineFunMap.end() && "Cxt Thread not found!!");
@@ -399,7 +399,7 @@ public:
399
399
 
400
400
  bool hasLoop(const SVFBasicBlock* bb) const
401
401
  {
402
- const SVFFunction* fun = bb->getFunction();
402
+ const FunObjVar* fun = bb->getFunction();
403
403
  return fun->hasLoopInfo(bb);
404
404
  }
405
405
  bool hasLoop(const ICFGNode* inst) const
@@ -414,9 +414,9 @@ public:
414
414
  const LoopBBs& getLoop(const SVFBasicBlock* bb);
415
415
 
416
416
  /// Push calling context
417
- void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee);
417
+ void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee);
418
418
  /// Match context
419
- bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee);
419
+ bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee);
420
420
 
421
421
  inline void pushCxt(CallStrCxt& cxt, CallSiteID csId)
422
422
  {
@@ -477,7 +477,7 @@ private:
477
477
  /// Mark relevant procedures that are backward reachable from any fork/join site
478
478
  //@{
479
479
  void markRelProcs();
480
- void markRelProcs(const SVFFunction* fun);
480
+ void markRelProcs(const FunObjVar* fun);
481
481
  //@}
482
482
 
483
483
  /// Get entry functions that are neither called by other functions nor extern functions
@@ -510,7 +510,7 @@ private:
510
510
 
511
511
  /// Get or create a tct node based on CxtThread
512
512
  //@{
513
- inline TCTNode* getOrCreateTCTNode(const CallStrCxt& cxt, const ICFGNode* fork,const CallStrCxt& oldCxt, const SVFFunction* routine)
513
+ inline TCTNode* getOrCreateTCTNode(const CallStrCxt& cxt, const ICFGNode* fork,const CallStrCxt& oldCxt, const FunObjVar* routine)
514
514
  {
515
515
  CxtThread ct(cxt,fork);
516
516
  CxtThreadToNodeMap::const_iterator it = ctpToNodeMap.find(ct);
@@ -551,7 +551,7 @@ private:
551
551
  ctToForkCxtMap[ct] = cxt;
552
552
  }
553
553
  /// Add start routine function of a cxt thread
554
- void addStartRoutineOfCxtThread(const SVFFunction* fun, const CxtThread& ct)
554
+ void addStartRoutineOfCxtThread(const FunObjVar* fun, const CxtThread& ct)
555
555
  {
556
556
  ctToRoutineFunMap[ct] = fun;
557
557
  }
@@ -101,11 +101,11 @@ public:
101
101
  //@{
102
102
  typedef Set<const CallICFGNode*> CallSiteSet;
103
103
  typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap;
104
- typedef Set<const SVFFunction*> FunctionSet;
104
+ typedef Set<const FunObjVar*> FunctionSet;
105
105
  typedef OrderedMap<const CallICFGNode*, FunctionSet> CallEdgeMap;
106
106
  typedef SCCDetection<CallGraph*> CallGraphSCC;
107
107
  typedef Set<const GlobalObjVar*> VTableSet;
108
- typedef Set<const SVFFunction*> VFunSet;
108
+ typedef Set<const FunObjVar*> VFunSet;
109
109
  //@}
110
110
 
111
111
  static const std::string aliasTestMayAlias;
@@ -396,13 +396,13 @@ public:
396
396
  return callGraphSCC->repNode(id);
397
397
  }
398
398
  /// Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG.
399
- inline bool inSameCallGraphSCC(const SVFFunction* fun1,const SVFFunction* fun2)
399
+ inline bool inSameCallGraphSCC(const FunObjVar* fun1,const FunObjVar* fun2)
400
400
  {
401
401
  const CallGraphNode* src = callgraph->getCallGraphNode(fun1);
402
402
  const CallGraphNode* dst = callgraph->getCallGraphNode(fun2);
403
403
  return (getCallGraphSCCRepNode(src->getId()) == getCallGraphSCCRepNode(dst->getId()));
404
404
  }
405
- inline bool isInRecursion(const SVFFunction* fun) const
405
+ inline bool isInRecursion(const FunObjVar* fun) const
406
406
  {
407
407
  return callGraphSCC->isInCycle(callgraph->getCallGraphNode(fun)->getId());
408
408
  }
@@ -67,8 +67,8 @@ public:
67
67
 
68
68
  /// Validate test cases for regression test purpose
69
69
  void testsValidation(ProgSlice* slice);
70
- void validateSuccessTests(ProgSlice* slice, const SVFFunction* fun);
71
- void validateExpectedFailureTests(ProgSlice* slice, const SVFFunction* fun);
70
+ void validateSuccessTests(ProgSlice* slice, const FunObjVar* fun);
71
+ void validateExpectedFailureTests(ProgSlice* slice, const FunObjVar* fun);
72
72
  };
73
73
 
74
74
  } // End namespace SVF
@@ -62,12 +62,12 @@ public:
62
62
  return false;
63
63
  }
64
64
 
65
- inline bool isSourceLikeFun(const SVFFunction* fun)
65
+ inline bool isSourceLikeFun(const FunObjVar* fun)
66
66
  {
67
67
  return SaberCheckerAPI::getCheckerAPI()->isFOpen(fun);
68
68
  }
69
69
  /// Whether the function is a heap deallocator (free/release memory)
70
- inline bool isSinkLikeFun(const SVFFunction* fun)
70
+ inline bool isSinkLikeFun(const FunObjVar* fun)
71
71
  {
72
72
  return SaberCheckerAPI::getCheckerAPI()->isFClose(fun);
73
73
  }
@@ -78,12 +78,12 @@ public:
78
78
  virtual void initSrcs() override;
79
79
  virtual void initSnks() override;
80
80
  /// Whether the function is a heap allocator/reallocator (allocate memory)
81
- virtual inline bool isSourceLikeFun(const SVFFunction* fun) override
81
+ virtual inline bool isSourceLikeFun(const FunObjVar* fun) override
82
82
  {
83
83
  return SaberCheckerAPI::getCheckerAPI()->isMemAlloc(fun);
84
84
  }
85
85
  /// Whether the function is a heap deallocator (free/release memory)
86
- virtual inline bool isSinkLikeFun(const SVFFunction* fun) override
86
+ virtual inline bool isSinkLikeFun(const FunObjVar* fun) override
87
87
  {
88
88
  return SaberCheckerAPI::getCheckerAPI()->isMemDealloc(fun);
89
89
  }
@@ -97,8 +97,8 @@ protected:
97
97
 
98
98
  /// Validate test cases for regression test purpose
99
99
  void testsValidation(const ProgSlice* slice);
100
- void validateSuccessTests(const SVFGNode* source, const SVFFunction* fun);
101
- void validateExpectedFailureTests(const SVFGNode* source, const SVFFunction* fun);
100
+ void validateSuccessTests(const SVFGNode* source, const FunObjVar* fun);
101
+ void validateExpectedFailureTests(const SVFGNode* source, const FunObjVar* fun);
102
102
 
103
103
  /// Record a source to its callsite
104
104
  //@{
@@ -32,6 +32,7 @@
32
32
 
33
33
  #include "Util/SVFUtil.h"
34
34
  #include "Graphs/ICFGNode.h"
35
+ #include "SVFIR/SVFVariables.h" // add header
35
36
 
36
37
  namespace SVF
37
38
  {
@@ -73,7 +74,7 @@ private:
73
74
  static SaberCheckerAPI* ckAPI;
74
75
 
75
76
  /// Get the function type of a function
76
- inline CHECKER_TYPE getType(const SVFFunction* F) const
77
+ inline CHECKER_TYPE getType(const FunObjVar* F) const
77
78
  {
78
79
  if(F)
79
80
  {
@@ -97,7 +98,7 @@ public:
97
98
 
98
99
  /// Return true if this call is a memory allocation
99
100
  //@{
100
- inline bool isMemAlloc(const SVFFunction* fun) const
101
+ inline bool isMemAlloc(const FunObjVar* fun) const
101
102
  {
102
103
  return getType(fun) == CK_ALLOC;
103
104
  }
@@ -109,7 +110,7 @@ public:
109
110
 
110
111
  /// Return true if this call is a memory deallocation
111
112
  //@{
112
- inline bool isMemDealloc(const SVFFunction* fun) const
113
+ inline bool isMemDealloc(const FunObjVar* fun) const
113
114
  {
114
115
  return getType(fun) == CK_FREE;
115
116
  }
@@ -121,7 +122,7 @@ public:
121
122
 
122
123
  /// Return true if this call is a file open
123
124
  //@{
124
- inline bool isFOpen(const SVFFunction* fun) const
125
+ inline bool isFOpen(const FunObjVar* fun) const
125
126
  {
126
127
  return getType(fun) == CK_FOPEN;
127
128
  }
@@ -133,7 +134,7 @@ public:
133
134
 
134
135
  /// Return true if this call is a file close
135
136
  //@{
136
- inline bool isFClose(const SVFFunction* fun) const
137
+ inline bool isFClose(const FunObjVar* fun) const
137
138
  {
138
139
  return getType(fun) == CK_FCLOSE;
139
140
  }
@@ -53,7 +53,7 @@ public:
53
53
  typedef Map<u32_t,Condition> CondPosMap; ///< map a branch to its Condition
54
54
  typedef Map<const SVFBasicBlock*, CondPosMap > BBCondMap; /// map bb to a Condition
55
55
  typedef Set<const SVFBasicBlock*> BasicBlockSet;
56
- typedef Map<const SVFFunction*, BasicBlockSet> FunToExitBBsMap; ///< map a function to all its basic blocks calling program exit
56
+ typedef Map<const FunObjVar*, BasicBlockSet> FunToExitBBsMap; ///< map a function to all its basic blocks calling program exit
57
57
  typedef Map<const SVFBasicBlock*, Condition> BBToCondMap; ///< map a basic block to its condition during control-flow guard computation
58
58
  typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
59
59
  typedef Map<const SVFGNode*, Set<const SVFGNode*>> SVFGNodeToSVFGNodeSetMap;
@@ -146,8 +146,8 @@ public:
146
146
 
147
147
  inline bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
148
148
  {
149
- const SVFFunction* keyFunc = bbKey->getParent();
150
- const SVFFunction* valueFunc = bbValue->getParent();
149
+ const FunObjVar* keyFunc = bbKey->getParent();
150
+ const FunObjVar* 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!");
@@ -156,8 +156,8 @@ public:
156
156
 
157
157
  inline bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
158
158
  {
159
- const SVFFunction* keyFunc = bbKey->getParent();
160
- const SVFFunction* valueFunc = bbValue->getParent();
159
+ const FunObjVar* keyFunc = bbKey->getParent();
160
+ const FunObjVar* valueFunc = bbValue->getParent();
161
161
  bool funcEq = (keyFunc == valueFunc);
162
162
  (void)funcEq; // Suppress warning of unused variable under release build
163
163
  assert(funcEq && "two basicblocks should be in the same function!");
@@ -174,12 +174,12 @@ public:
174
174
  ///@{
175
175
  virtual void initSrcs() = 0;
176
176
  virtual void initSnks() = 0;
177
- virtual bool isSourceLikeFun(const SVFFunction* fun)
177
+ virtual bool isSourceLikeFun(const FunObjVar* fun)
178
178
  {
179
179
  return false;
180
180
  }
181
181
 
182
- virtual bool isSinkLikeFun(const SVFFunction* fun)
182
+ virtual bool isSinkLikeFun(const FunObjVar* fun)
183
183
  {
184
184
  return false;
185
185
  }
@@ -55,6 +55,7 @@ public:
55
55
  typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
56
56
 
57
57
  typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
58
+ typedef Map<const Function*, FunObjVar*> LLVMFun2FunObjVarMap;
58
59
  typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
59
60
  typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
60
61
  typedef Map<const Argument*, SVFArgument*> LLVMArgument2SVFArgumentMap;
@@ -76,12 +77,14 @@ public:
76
77
  /// local (%) and global (@) identifiers are pointer types which have a value node id.
77
78
  typedef OrderedMap<const SVFValue*, NodeID> ValueToIDMapTy;
78
79
 
80
+ typedef OrderedMap<const SVFFunction*, NodeID> FunToIDMapTy;
81
+
82
+
79
83
  private:
80
84
  static LLVMModuleSet* llvmModuleSet;
81
85
  static bool preProcessed;
82
86
  SVFIR* svfir;
83
87
  SVFModule* svfModule; ///< Borrowed from singleton SVFModule::svfModule
84
- ICFG* icfg;
85
88
  std::unique_ptr<LLVMContext> owned_ctx;
86
89
  std::vector<std::unique_ptr<Module>> owned_modules;
87
90
  std::vector<std::reference_wrapper<Module>> modules;
@@ -90,10 +93,15 @@ private:
90
93
  FunctionSetType ExtFuncsVec;
91
94
  /// Record annotations of function in extapi.bc
92
95
  Fun2AnnoMap ExtFun2Annotations;
96
+
97
+ // Map SVFFunction to its annotations
98
+ Map<const SVFFunction*, std::vector<std::string>> func2Annotations;
99
+
93
100
  /// Global definition to a rep definition map
94
101
  GlobalDefToRepMapTy GlobalDefToRepMap;
95
102
 
96
103
  LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
104
+ LLVMFun2FunObjVarMap LLVMFun2FunObjVar; ///< Map an LLVM Function to an SVF Funobjvar
97
105
  LLVMBB2SVFBBMap LLVMBB2SVFBB;
98
106
  LLVMInst2SVFInstMap LLVMInst2SVFInst;
99
107
  LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
@@ -110,12 +118,13 @@ private:
110
118
  InstToBlockNodeMapTy InstToBlockNodeMap; ///< map a basic block to its ICFGNode
111
119
  FunToFunEntryNodeMapTy FunToFunEntryNodeMap; ///< map a function to its FunExitICFGNode
112
120
  FunToFunExitNodeMapTy FunToFunExitNodeMap; ///< map a function to its FunEntryICFGNode
113
- CallGraph* callgraph;
114
121
 
115
122
  Map<const Function*, DominatorTree> FunToDominatorTree;
116
123
 
117
124
  ValueToIDMapTy valSymMap; ///< map a value to its sym id
118
125
  ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
126
+ FunToIDMapTy returnSymMap; ///< return map
127
+ FunToIDMapTy varargSymMap; ///< vararg map
119
128
 
120
129
  /// Constructor
121
130
  LLVMModuleSet();
@@ -299,6 +308,37 @@ public:
299
308
  return it->second;
300
309
  }
301
310
 
311
+ inline const FunObjVar* getFunObjVar(const Function* fun) const
312
+ {
313
+ LLVMFun2FunObjVarMap::const_iterator it = LLVMFun2FunObjVar.find(fun);
314
+ assert(it!=LLVMFun2FunObjVar.end() && "SVF Function not found!");
315
+ return it->second;
316
+ }
317
+
318
+ inline FunToIDMapTy& retSyms()
319
+ {
320
+ return returnSymMap;
321
+ }
322
+
323
+ inline FunToIDMapTy& varargSyms()
324
+ {
325
+ return varargSymMap;
326
+ }
327
+
328
+ NodeID getReturnNode(const SVFFunction *func) const
329
+ {
330
+ FunToIDMapTy::const_iterator iter = returnSymMap.find(func);
331
+ assert(iter!=returnSymMap.end() && "ret sym not found");
332
+ return iter->second;
333
+ }
334
+
335
+ NodeID getVarargNode(const SVFFunction *func) const
336
+ {
337
+ FunToIDMapTy::const_iterator iter = varargSymMap.find(func);
338
+ assert(iter!=varargSymMap.end() && "vararg sym not found");
339
+ return iter->second;
340
+ }
341
+
302
342
  SVFBasicBlock* getSVFBasicBlock(const BasicBlock* bb)
303
343
  {
304
344
  LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
@@ -355,6 +395,9 @@ public:
355
395
  return nullptr;
356
396
  }
357
397
 
398
+ /// Get the corresponding Function based on its name
399
+ const FunObjVar* getFunObjVar(const std::string& name);
400
+
358
401
  ICFGNode* getICFGNode(const Instruction* inst);
359
402
 
360
403
  bool hasICFGNode(const Instruction* inst);
@@ -429,13 +472,46 @@ public:
429
472
 
430
473
  ObjTypeInference* getTypeInference();
431
474
 
432
- inline ICFG* getICFG()
433
- {
434
- return icfg;
435
- }
436
-
437
475
  DominatorTree& getDomTree(const Function* fun);
438
476
 
477
+ std::string getExtFuncAnnotation(const SVFFunction* fun, const std::string& funcAnnotation);
478
+
479
+ const std::vector<std::string>& getExtFuncAnnotations(const SVFFunction* fun);
480
+
481
+ // Does (F) have some annotation?
482
+ bool hasExtFuncAnnotation(const SVFFunction* fun, const std::string& funcAnnotation);
483
+
484
+ // Does (F) have a static var X (unavailable to us) that its return points to?
485
+ bool has_static(const SVFFunction *F);
486
+
487
+ // Does (F) have a memcpy_like operation?
488
+ bool is_memcpy(const SVFFunction *F);
489
+
490
+ // Does (F) have a memset_like operation?
491
+ bool is_memset(const SVFFunction *F);
492
+
493
+ // Does (F) allocate a new object and return it?
494
+ bool is_alloc(const SVFFunction *F);
495
+
496
+ // Does (F) allocate a new object and assign it to one of its arguments?
497
+ bool is_arg_alloc(const SVFFunction *F);
498
+
499
+ // Does (F) allocate a new stack object and return it?
500
+ bool is_alloc_stack_ret(const SVFFunction *F);
501
+
502
+ // Get the position of argument which holds the new object
503
+ s32_t get_alloc_arg_pos(const SVFFunction *F);
504
+
505
+ // Does (F) reallocate a new object?
506
+ bool is_realloc(const SVFFunction *F);
507
+
508
+ // Should (F) be considered "external" (either not defined in the program
509
+ // or a user-defined version of a known alloc or no-op)?
510
+ bool is_ext(const SVFFunction *F);
511
+
512
+ // Set the annotation of (F)
513
+ void setExtFuncAnnotations(const SVFFunction* fun, const std::vector<std::string>& funcAnnotations);
514
+
439
515
  private:
440
516
  /// Create SVFTypes
441
517
  SVFType* addSVFTypeInfo(const Type* t);
@@ -355,8 +355,16 @@ std::vector<const Function *> getCalledFunctions(const Function *F);
355
355
  // Converts a mangled name to C naming style to match functions in extapi.c.
356
356
  std::string restoreFuncName(std::string funcName);
357
357
 
358
- /// Get the corresponding Function based on its name
358
+ bool isExtCall(const SVFFunction* fun);
359
+
360
+ bool isMemcpyExtFun(const SVFFunction *fun);
361
+
362
+ bool isMemsetExtFun(const SVFFunction* fun);
363
+
364
+ u32_t getHeapAllocHoldingArgPosition(const SVFFunction* fun);
365
+
359
366
  const SVFFunction* getFunction(const std::string& name);
367
+ const FunObjVar* getFunObjVar(const std::string&name);
360
368
 
361
369
  /// Return true if the value refers to constant data, e.g., i32 0
362
370
  inline bool isConstDataOrAggData(const Value* val)
@@ -74,6 +74,9 @@ public:
74
74
  /// Initialize nodes and edges
75
75
  //@{
76
76
  void initialiseNodes();
77
+ void initialiseBaseObjVars();
78
+ void initialiseValVars();
79
+ void initialiseFunObjVars();
77
80
  void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
78
81
  APOffset offset = 0, Instruction* cs = nullptr);
79
82
  // @}
@@ -102,13 +105,13 @@ public:
102
105
  }
103
106
 
104
107
  /// getReturnNode - Return the node representing the unique return value of a function.
105
- inline NodeID getReturnNode(const SVFFunction *func)
108
+ inline NodeID getReturnNode(const FunObjVar *func)
106
109
  {
107
110
  return pag->getReturnNode(func);
108
111
  }
109
112
 
110
113
  /// getVarargNode - Return the node representing the unique variadic argument of a function.
111
- inline NodeID getVarargNode(const SVFFunction *func)
114
+ inline NodeID getVarargNode(const FunObjVar *func)
112
115
  {
113
116
  return pag->getVarargNode(func);
114
117
  }