svf-tools 1.0.984 → 1.0.986

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 (53) hide show
  1. package/package.json +1 -1
  2. package/svf/include/CFL/CFLAlias.h +3 -3
  3. package/svf/include/Graphs/CHG.h +13 -31
  4. package/svf/include/Graphs/ICFG.h +2 -2
  5. package/svf/include/Graphs/ICFGEdge.h +4 -16
  6. package/svf/include/Graphs/ICFGNode.h +59 -1
  7. package/svf/include/Graphs/ThreadCallGraph.h +6 -6
  8. package/svf/include/MTA/LockAnalysis.h +9 -3
  9. package/svf/include/MTA/MHP.h +13 -9
  10. package/svf/include/MTA/TCT.h +4 -4
  11. package/svf/include/SABER/SaberCheckerAPI.h +4 -4
  12. package/svf/include/SVFIR/SVFFileSystem.h +0 -2
  13. package/svf/include/SVFIR/SVFValue.h +0 -131
  14. package/svf/include/Util/SVFUtil.h +18 -72
  15. package/svf/include/Util/ThreadAPI.h +15 -59
  16. package/svf/include/WPA/Andersen.h +3 -3
  17. package/svf/include/WPA/Steensgaard.h +3 -3
  18. package/svf/include/WPA/WPAPass.h +3 -3
  19. package/svf/lib/AE/Svfexe/AEDetector.cpp +25 -32
  20. package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +59 -79
  21. package/svf/lib/CFL/CFLAlias.cpp +12 -13
  22. package/svf/lib/DDA/DDAClient.cpp +2 -2
  23. package/svf/lib/Graphs/CHG.cpp +33 -9
  24. package/svf/lib/Graphs/CallGraph.cpp +2 -2
  25. package/svf/lib/Graphs/ICFG.cpp +13 -10
  26. package/svf/lib/MSSA/MemRegion.cpp +3 -3
  27. package/svf/lib/MTA/LockAnalysis.cpp +2 -2
  28. package/svf/lib/MTA/MHP.cpp +10 -8
  29. package/svf/lib/MemoryModel/PointerAnalysis.cpp +23 -25
  30. package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +2 -2
  31. package/svf/lib/SABER/DoubleFreeChecker.cpp +1 -1
  32. package/svf/lib/SABER/LeakChecker.cpp +1 -1
  33. package/svf/lib/SABER/SaberCondAllocator.cpp +1 -1
  34. package/svf/lib/SABER/SaberSVFGBuilder.cpp +1 -1
  35. package/svf/lib/SVFIR/SVFFileSystem.cpp +2 -20
  36. package/svf/lib/Util/CallGraphBuilder.cpp +4 -4
  37. package/svf/lib/Util/SVFBugReport.cpp +2 -1
  38. package/svf/lib/Util/SVFUtil.cpp +52 -21
  39. package/svf/lib/Util/ThreadAPI.cpp +58 -21
  40. package/svf/lib/WPA/Andersen.cpp +9 -10
  41. package/svf/lib/WPA/AndersenSCD.cpp +1 -2
  42. package/svf/lib/WPA/Steensgaard.cpp +9 -13
  43. package/svf/lib/WPA/TypeAnalysis.cpp +2 -3
  44. package/svf/lib/WPA/WPAPass.cpp +6 -13
  45. package/svf-llvm/include/SVF-LLVM/DCHG.h +7 -7
  46. package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +0 -8
  47. package/svf-llvm/lib/CHGBuilder.cpp +4 -4
  48. package/svf-llvm/lib/DCHG.cpp +8 -7
  49. package/svf-llvm/lib/ICFGBuilder.cpp +3 -3
  50. package/svf-llvm/lib/LLVMModule.cpp +0 -2
  51. package/svf-llvm/lib/LLVMUtil.cpp +0 -58
  52. package/svf-llvm/lib/SVFIRExtAPI.cpp +2 -2
  53. package/svf-llvm/lib/SymbolTableBuilder.cpp +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.984",
3
+ "version": "1.0.986",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,7 +42,7 @@ class CFLAlias : public CFLBase
42
42
  {
43
43
 
44
44
  public:
45
- typedef OrderedMap<CallSite, NodeID> CallSite2DummyValPN;
45
+ typedef OrderedMap<const CallICFGNode*, NodeID> CallSite2DummyValPN;
46
46
 
47
47
  CFLAlias(SVFIR* ir) : CFLBase(ir, PointerAnalysis::CFLFICI_WPA)
48
48
  {
@@ -143,9 +143,9 @@ public:
143
143
  virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap& callsites, CallEdgeMap& newEdges);
144
144
 
145
145
  /// Connect formal and actual parameters for indirect callsites
146
- void connectCaller2CalleeParams(CallSite cs, const SVFFunction* F);
146
+ void connectCaller2CalleeParams(const CallICFGNode* cs, const SVFFunction* F);
147
147
 
148
- void heapAllocatorViaIndCall(CallSite cs);
148
+ void heapAllocatorViaIndCall(const CallICFGNode* cs);
149
149
 
150
150
  private:
151
151
  CallSite2DummyValPN callsite2DummyValPN; ///< Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator
@@ -57,11 +57,11 @@ public:
57
57
  DI
58
58
  };
59
59
 
60
- virtual bool csHasVFnsBasedonCHA(CallSite cs) = 0;
61
- virtual const VFunSet &getCSVFsBasedonCHA(CallSite cs) = 0;
62
- virtual bool csHasVtblsBasedonCHA(CallSite cs) = 0;
63
- virtual const VTableSet &getCSVtblsBasedonCHA(CallSite cs) = 0;
64
- virtual void getVFnsFromVtbls(CallSite cs, const VTableSet& vtbls,
60
+ virtual bool csHasVFnsBasedonCHA(const CallICFGNode* cs) = 0;
61
+ virtual const VFunSet &getCSVFsBasedonCHA(const CallICFGNode* cs) = 0;
62
+ virtual bool csHasVtblsBasedonCHA(const CallICFGNode* cs) = 0;
63
+ virtual const VTableSet &getCSVtblsBasedonCHA(const CallICFGNode* cs) = 0;
64
+ virtual void getVFnsFromVtbls(const SVFCallInst* cs, const VTableSet& vtbls,
65
65
  VFunSet& virtualFunctions) = 0;
66
66
 
67
67
  CHGKind getKind(void) const
@@ -222,9 +222,9 @@ public:
222
222
  typedef Set<const CHNode*> CHNodeSetTy;
223
223
  typedef FIFOWorkList<const CHNode*> WorkList;
224
224
  typedef Map<std::string, CHNodeSetTy> NameToCHNodesMap;
225
- typedef Map<CallSite, CHNodeSetTy> CallSiteToCHNodesMap;
226
- typedef Map<CallSite, VTableSet> CallSiteToVTableSetMap;
227
- typedef Map<CallSite, VFunSet> CallSiteToVFunSetMap;
225
+ typedef Map<const SVFInstruction*, CHNodeSetTy> CallSiteToCHNodesMap;
226
+ typedef Map<const SVFInstruction*, VTableSet> CallSiteToVTableSetMap;
227
+ typedef Map<const SVFInstruction*, VFunSet> CallSiteToVFunSetMap;
228
228
 
229
229
  typedef enum
230
230
  {
@@ -242,7 +242,7 @@ public:
242
242
  const std::string baseClassName,
243
243
  CHEdge::CHEDGETYPE edgeType);
244
244
  CHNode *getNode(const std::string name) const;
245
- void getVFnsFromVtbls(CallSite cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
245
+ void getVFnsFromVtbls(const SVFCallInst* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
246
246
  void dump(const std::string& filename);
247
247
  void view();
248
248
  void printCH();
@@ -286,28 +286,10 @@ public:
286
286
  return templateNameToInstancesMap[className];
287
287
  }
288
288
 
289
- inline bool csHasVtblsBasedonCHA(CallSite cs) override
290
- {
291
- CallSiteToVTableSetMap::const_iterator it = csToCHAVtblsMap.find(cs);
292
- return it != csToCHAVtblsMap.end();
293
- }
294
- inline bool csHasVFnsBasedonCHA(CallSite cs) override
295
- {
296
- CallSiteToVFunSetMap::const_iterator it = csToCHAVFnsMap.find(cs);
297
- return it != csToCHAVFnsMap.end();
298
- }
299
- inline const VTableSet &getCSVtblsBasedonCHA(CallSite cs) override
300
- {
301
- CallSiteToVTableSetMap::const_iterator it = csToCHAVtblsMap.find(cs);
302
- assert(it != csToCHAVtblsMap.end() && "cs does not have vtabls based on CHA.");
303
- return it->second;
304
- }
305
- inline const VFunSet &getCSVFsBasedonCHA(CallSite cs) override
306
- {
307
- CallSiteToVFunSetMap::const_iterator it = csToCHAVFnsMap.find(cs);
308
- assert(it != csToCHAVFnsMap.end() && "cs does not have vfns based on CHA.");
309
- return it->second;
310
- }
289
+ bool csHasVtblsBasedonCHA(const CallICFGNode* cs) override;
290
+ bool csHasVFnsBasedonCHA(const CallICFGNode* cs) override;
291
+ const VTableSet &getCSVtblsBasedonCHA(const CallICFGNode* cs) override;
292
+ const VFunSet &getCSVFsBasedonCHA(const CallICFGNode* cs) override;
311
293
 
312
294
  static inline bool classof(const CommonCHGraph *chg)
313
295
  {
@@ -156,8 +156,8 @@ protected:
156
156
  //@{
157
157
  ICFGEdge* addIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode);
158
158
  ICFGEdge* addConditionalIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFValue* condition, s32_t branchCondVal);
159
- ICFGEdge* addCallEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFInstruction* cs);
160
- ICFGEdge* addRetEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFInstruction* cs);
159
+ ICFGEdge* addCallEdge(ICFGNode* srcNode, ICFGNode* dstNode);
160
+ ICFGEdge* addRetEdge(ICFGNode* srcNode, ICFGNode* dstNode);
161
161
  //@}
162
162
  /// Remove a ICFG edge
163
163
  inline void removeICFGEdge(ICFGEdge* edge)
@@ -179,20 +179,14 @@ class CallCFGEdge : public ICFGEdge
179
179
  friend class SVFIRReader;
180
180
 
181
181
  private:
182
- const SVFInstruction* cs;
183
182
  std::vector<const CallPE*> callPEs;
184
183
 
185
184
  public:
186
185
  /// Constructor
187
- CallCFGEdge(ICFGNode* s, ICFGNode* d, const SVFInstruction* c)
188
- : ICFGEdge(s, d, CallCF), cs(c)
186
+ CallCFGEdge(ICFGNode* s, ICFGNode* d)
187
+ : ICFGEdge(s, d, CallCF)
189
188
  {
190
189
  }
191
- /// Return callsite ID
192
- inline const SVFInstruction* getCallSite() const
193
- {
194
- return cs;
195
- }
196
190
  /// Add call parameter edge to this CallCFGEdge
197
191
  inline void addCallPE(const CallPE* callPE)
198
192
  {
@@ -230,19 +224,13 @@ class RetCFGEdge : public ICFGEdge
230
224
  friend class SVFIRReader;
231
225
 
232
226
  private:
233
- const SVFInstruction* cs;
234
227
  const RetPE* retPE;
235
228
 
236
229
  public:
237
230
  /// Constructor
238
- RetCFGEdge(ICFGNode* s, ICFGNode* d, const SVFInstruction* c)
239
- : ICFGEdge(s, d, RetCF), cs(c), retPE(nullptr)
240
- {
241
- }
242
- /// Return callsite ID
243
- inline const SVFInstruction* getCallSite() const
231
+ RetCFGEdge(ICFGNode* s, ICFGNode* d)
232
+ : ICFGEdge(s, d, RetCF), retPE(nullptr)
244
233
  {
245
- return cs;
246
234
  }
247
235
  /// Add call parameter edge to this CallCFGEdge
248
236
  inline void addRetPE(const RetPE* ret)
@@ -462,7 +462,7 @@ public:
462
462
  /// Return true if this is an indirect call
463
463
  inline bool isIndirectCall() const
464
464
  {
465
- return nullptr == SVFUtil::getCallee(cs);
465
+ return nullptr == SVFUtil::cast<SVFCallInst>(cs)->getCalledFunction();
466
466
  }
467
467
 
468
468
  /// Return the set of actual parameters
@@ -476,6 +476,64 @@ public:
476
476
  {
477
477
  APNodes.push_back(ap);
478
478
  }
479
+ /// Parameter operations
480
+ //@{
481
+ const SVFValue* getArgument(u32_t ArgNo) const
482
+ {
483
+ return SVFUtil::cast<SVFCallInst>(cs)->getArgOperand(ArgNo);
484
+ }
485
+ const SVFType* getType() const
486
+ {
487
+ return SVFUtil::cast<SVFCallInst>(cs)->getType();
488
+ }
489
+ u32_t arg_size() const
490
+ {
491
+ return SVFUtil::cast<SVFCallInst>(cs)->arg_size();
492
+ }
493
+ bool arg_empty() const
494
+ {
495
+ return SVFUtil::cast<SVFCallInst>(cs)->arg_empty();
496
+ }
497
+ const SVFValue* getArgOperand(u32_t i) const
498
+ {
499
+ return SVFUtil::cast<SVFCallInst>(cs)->getArgOperand(i);
500
+ }
501
+ u32_t getNumArgOperands() const
502
+ {
503
+ return SVFUtil::cast<SVFCallInst>(cs)->arg_size();
504
+ }
505
+ const SVFFunction* getCalledFunction() const
506
+ {
507
+ return SVFUtil::cast<SVFCallInst>(cs)->getCalledFunction();
508
+ }
509
+ const SVFValue* getCalledValue() const
510
+ {
511
+ return SVFUtil::cast<SVFCallInst>(cs)->getCalledOperand();
512
+ }
513
+ bool isVarArg() const
514
+ {
515
+ return SVFUtil::cast<SVFCallInst>(cs)->isVarArg();
516
+ }
517
+ bool isVirtualCall() const
518
+ {
519
+ return SVFUtil::isa<SVFVirtualCallInst>(cs);
520
+ }
521
+ const SVFValue* getVtablePtr() const
522
+ {
523
+ assert(isVirtualCall() && "not a virtual call?");
524
+ return SVFUtil::cast<SVFVirtualCallInst>(cs)->getVtablePtr();
525
+ }
526
+ s32_t getFunIdxInVtable() const
527
+ {
528
+ assert(isVirtualCall() && "not a virtual call?");
529
+ return SVFUtil::cast<SVFVirtualCallInst>(cs)->getFunIdxInVtable();
530
+ }
531
+ const std::string& getFunNameOfVirtualCall() const
532
+ {
533
+ assert(isVirtualCall() && "not a virtual call?");
534
+ return SVFUtil::cast<SVFVirtualCallInst>(cs)->getFunNameOfVirtualCall();
535
+ }
536
+ //@}
479
537
 
480
538
  ///Methods for support type inquiry through isa, cast, and dyn_cast:
481
539
  //@{
@@ -72,9 +72,9 @@ public:
72
72
  std::string str;
73
73
  std::stringstream rawstr(str);
74
74
  rawstr << "ThreadForkEdge ";
75
- rawstr << "CallSite ID: " << getCallSiteID();
76
- rawstr << " srcNode ID " << getSrcID() << " (fun: " << getSrcNode()->getFunction()->getName() << ")";
77
- rawstr << " dstNode ID " << getDstID() << " (fun: " << getDstNode()->getFunction()->getName() << ")";
75
+ rawstr << "CallSiteID: " << getCallSiteID();
76
+ rawstr << " srcNodeID " << getSrcID() << " (fun: " << getSrcNode()->getFunction()->getName() << ")";
77
+ rawstr << " dstNodeID " << getDstID() << " (fun: " << getDstNode()->getFunction()->getName() << ")";
78
78
  return rawstr.str();
79
79
  }
80
80
 
@@ -112,9 +112,9 @@ public:
112
112
  std::string str;
113
113
  std::stringstream rawstr(str);
114
114
  rawstr << "ThreadJoinEdge ";
115
- rawstr << "CallSite ID: " << getCallSiteID();
116
- rawstr << " srcNode ID " << getSrcID() << " (fun: " << getSrcNode()->getFunction()->getName() << ")";
117
- rawstr << " dstNode ID " << getDstID() << " (fun: " << getDstNode()->getFunction()->getName() << ")";
115
+ rawstr << "CallSiteID: " << getCallSiteID();
116
+ rawstr << " srcNodeID " << getSrcID() << " (fun: " << getSrcNode()->getFunction()->getName() << ")";
117
+ rawstr << " dstNodeID " << getDstID() << " (fun: " << getDstNode()->getFunction()->getName() << ")";
118
118
  return rawstr.str();
119
119
  }
120
120
 
@@ -437,17 +437,23 @@ private:
437
437
  /// Whether it is a lock site
438
438
  inline bool isTDFork(const ICFGNode* call)
439
439
  {
440
- return getTCG()->getThreadAPI()->isTDFork(call);
440
+ if(SVFUtil::isa<CallICFGNode>(call) == false)
441
+ return false;
442
+ return getTCG()->getThreadAPI()->isTDFork(SVFUtil::cast<CallICFGNode>(call));
441
443
  }
442
444
  /// Whether it is a lock site
443
445
  inline bool isTDAcquire(const ICFGNode* call)
444
446
  {
445
- return getTCG()->getThreadAPI()->isTDAcquire(call);
447
+ if(SVFUtil::isa<CallICFGNode>(call) == false)
448
+ return false;
449
+ return getTCG()->getThreadAPI()->isTDAcquire(SVFUtil::cast<CallICFGNode>(call));
446
450
  }
447
451
  /// Whether it is a unlock site
448
452
  inline bool isTDRelease(const ICFGNode* call)
449
453
  {
450
- return getTCG()->getThreadAPI()->isTDRelease(call);
454
+ if(SVFUtil::isa<CallICFGNode>(call) == false)
455
+ return false;
456
+ return getTCG()->getThreadAPI()->isTDRelease(SVFUtil::cast<CallICFGNode>(call));
451
457
  }
452
458
  /// Whether it is a callsite
453
459
  inline bool isCallSite(const ICFGNode* inst)
@@ -227,12 +227,14 @@ private:
227
227
  /// Whether it is a fork site
228
228
  inline bool isTDFork(const ICFGNode* call)
229
229
  {
230
- return tcg->getThreadAPI()->isTDFork(call);
230
+ const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
231
+ return fork && tcg->getThreadAPI()->isTDFork(fork);
231
232
  }
232
233
  /// Whether it is a join site
233
234
  inline bool isTDJoin(const ICFGNode* call)
234
235
  {
235
- return tcg->getThreadAPI()->isTDJoin(call);
236
+ const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
237
+ return join && tcg->getThreadAPI()->isTDJoin(join);
236
238
  }
237
239
 
238
240
  /// Return thread id(s) which are directly or indirectly joined at this join site
@@ -345,11 +347,11 @@ public:
345
347
  }
346
348
 
347
349
  /// Get loop for join site
348
- inline LoopBBs& getJoinLoop(const ICFGNode* inst)
350
+ inline LoopBBs& getJoinLoop(const CallICFGNode* inst)
349
351
  {
350
352
  return tct->getJoinLoop(inst);
351
353
  }
352
- inline bool hasJoinLoop(const ICFGNode* inst)
354
+ inline bool hasJoinLoop(const CallICFGNode* inst)
353
355
  {
354
356
  return tct->hasJoinLoop(inst);
355
357
  }
@@ -377,7 +379,7 @@ private:
377
379
  bool sameLoopTripCount(const ICFGNode* forkSite, const ICFGNode* joinSite);
378
380
 
379
381
  /// Whether it is a matched fork join pair
380
- bool isAliasedForkJoin(const ICFGNode* forkSite, const ICFGNode* joinSite)
382
+ bool isAliasedForkJoin(const CallICFGNode* forkSite, const CallICFGNode* joinSite)
381
383
  {
382
384
  return tct->getPTA()->alias(getForkedThread(forkSite), getJoinedThread(joinSite)) && isSameSCEV(forkSite,joinSite);
383
385
  }
@@ -461,20 +463,22 @@ private:
461
463
  /// Whether it is a fork site
462
464
  inline bool isTDFork(const ICFGNode* call)
463
465
  {
464
- return getTCG()->getThreadAPI()->isTDFork(call);
466
+ const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
467
+ return fork && getTCG()->getThreadAPI()->isTDFork(fork);
465
468
  }
466
469
  /// Whether it is a join site
467
470
  inline bool isTDJoin(const ICFGNode* call)
468
471
  {
469
- return getTCG()->getThreadAPI()->isTDJoin(call);
472
+ const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
473
+ return join && getTCG()->getThreadAPI()->isTDJoin(join);
470
474
  }
471
475
  /// Get forked thread
472
- inline const SVFValue* getForkedThread(const ICFGNode* call)
476
+ inline const SVFValue* getForkedThread(const CallICFGNode* call)
473
477
  {
474
478
  return getTCG()->getThreadAPI()->getForkedThread(call);
475
479
  }
476
480
  /// Get joined thread
477
- inline const SVFValue* getJoinedThread(const ICFGNode* call)
481
+ inline const SVFValue* getJoinedThread(const CallICFGNode* call)
478
482
  {
479
483
  return getTCG()->getThreadAPI()->getJoinedThread(call);
480
484
  }
@@ -246,7 +246,7 @@ public:
246
246
  inline bool isExtCall(const ICFGNode* inst)
247
247
  {
248
248
  if(const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst))
249
- return SVFUtil::isExtCall(call->getCallSite());
249
+ return SVFUtil::isExtCall(call);
250
250
  return false;
251
251
  }
252
252
  /// Whether it is a callsite
@@ -364,7 +364,7 @@ public:
364
364
  }
365
365
 
366
366
  /// Get loop for join site
367
- inline LoopBBs& getJoinLoop(const ICFGNode* join)
367
+ inline LoopBBs& getJoinLoop(const CallICFGNode* join)
368
368
  {
369
369
  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
370
370
  InstToLoopMap::iterator it = joinSiteToLoopMap.find(join);
@@ -372,7 +372,7 @@ public:
372
372
  return it->second;
373
373
  }
374
374
 
375
- inline bool hasJoinLoop(const ICFGNode* join) const
375
+ inline bool hasJoinLoop(const CallICFGNode* join) const
376
376
  {
377
377
  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
378
378
  InstToLoopMap::const_iterator it = joinSiteToLoopMap.find(join);
@@ -407,7 +407,7 @@ public:
407
407
  MaxCxtSize = cxt.size();
408
408
  }
409
409
  /// Whether a join site is in recursion
410
- inline bool isJoinSiteInRecursion(const ICFGNode* join) const
410
+ inline bool isJoinSiteInRecursion(const CallICFGNode* join) const
411
411
  {
412
412
  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
413
413
  return inRecurJoinSites.find(join)!=inRecurJoinSites.end();
@@ -103,7 +103,7 @@ public:
103
103
  }
104
104
  inline bool isMemAlloc(const CallICFGNode* cs) const
105
105
  {
106
- return isMemAlloc(SVFUtil::getCallee(cs->getCallSite()));
106
+ return isMemAlloc(cs->getCalledFunction());
107
107
  }
108
108
  //@}
109
109
 
@@ -115,7 +115,7 @@ public:
115
115
  }
116
116
  inline bool isMemDealloc(const CallICFGNode* cs) const
117
117
  {
118
- return isMemDealloc(SVFUtil::getCallee(cs->getCallSite()));
118
+ return isMemDealloc(cs->getCalledFunction());
119
119
  }
120
120
  //@}
121
121
 
@@ -127,7 +127,7 @@ public:
127
127
  }
128
128
  inline bool isFOpen(const CallICFGNode* cs) const
129
129
  {
130
- return isFOpen(SVFUtil::getCallee(cs->getCallSite()));
130
+ return isFOpen(cs->getCalledFunction());
131
131
  }
132
132
  //@}
133
133
 
@@ -139,7 +139,7 @@ public:
139
139
  }
140
140
  inline bool isFClose(const CallICFGNode* cs) const
141
141
  {
142
- return isFClose(SVFUtil::getCallee(cs->getCallSite()));
142
+ return isFClose(cs->getCalledFunction());
143
143
  }
144
144
  //@}
145
145
 
@@ -421,7 +421,6 @@ private:
421
421
  cJSON* toJson(const CHNode* node); // CHGraph Node
422
422
  cJSON* toJson(const CHEdge* edge); // CHGraph Edge
423
423
 
424
- cJSON* toJson(const CallSite& cs);
425
424
  cJSON* toJson(const AccessPath& ap);
426
425
  cJSON* toJson(const SVFLoop* loop);
427
426
  cJSON* toJson(const MemObj* memObj);
@@ -1104,7 +1103,6 @@ private:
1104
1103
  void readJson(const cJSON* obj, ICFGEdge*& edge); // ICFG Edge
1105
1104
  void readJson(const cJSON* obj, CHNode*& node); // CHGraph Node
1106
1105
  void readJson(const cJSON* obj, CHEdge*& edge); // CHGraph Edge
1107
- void readJson(const cJSON* obj, CallSite& cs); // CHGraph's csToClassMap
1108
1106
 
1109
1107
  void readJson(const cJSON* obj, AccessPath& ap);
1110
1108
  void readJson(const cJSON* obj, SVFLoop*& loop);
@@ -637,15 +637,11 @@ class SVFInstruction : public SVFValue
637
637
  {
638
638
  friend class SVFIRWriter;
639
639
  friend class SVFIRReader;
640
- public:
641
- typedef std::vector<const SVFInstruction*> InstVec;
642
640
 
643
641
  private:
644
642
  const SVFBasicBlock* bb; /// The BasicBlock where this Instruction resides
645
643
  bool terminator; /// return true if this is a terminator instruction
646
644
  bool ret; /// return true if this is an return instruction of a function
647
- InstVec succInsts; /// successor Instructions
648
- InstVec predInsts; /// predecessor Instructions
649
645
 
650
646
  public:
651
647
  /// Constructor without name, set name with setName()
@@ -665,36 +661,11 @@ public:
665
661
  return bb;
666
662
  }
667
663
 
668
- inline InstVec& getSuccInstructions()
669
- {
670
- return succInsts;
671
- }
672
-
673
- inline InstVec& getPredInstructions()
674
- {
675
- return predInsts;
676
- }
677
-
678
- inline const InstVec& getSuccInstructions() const
679
- {
680
- return succInsts;
681
- }
682
-
683
- inline const InstVec& getPredInstructions() const
684
- {
685
- return predInsts;
686
- }
687
-
688
664
  inline const SVFFunction* getFunction() const
689
665
  {
690
666
  return bb->getParent();
691
667
  }
692
668
 
693
- inline bool isTerminator() const
694
- {
695
- return terminator;
696
- }
697
-
698
669
  inline bool isRetInst() const
699
670
  {
700
671
  return ret;
@@ -1115,98 +1086,6 @@ public:
1115
1086
  };
1116
1087
 
1117
1088
 
1118
- class CallSite
1119
- {
1120
- friend class SVFIRReader;
1121
-
1122
- private:
1123
- const SVFCallInst* CB;
1124
-
1125
- /// Constructs empty CallSite (for SVFIRReader/deserialization)
1126
- CallSite() : CB{} {}
1127
-
1128
- public:
1129
- CallSite(const SVFInstruction* I) : CB(SVFUtil::dyn_cast<SVFCallInst>(I))
1130
- {
1131
- assert(CB && "not a callsite?");
1132
- }
1133
- const SVFInstruction* getInstruction() const
1134
- {
1135
- return CB;
1136
- }
1137
- const SVFValue* getArgument(u32_t ArgNo) const
1138
- {
1139
- return CB->getArgOperand(ArgNo);
1140
- }
1141
- const SVFType* getType() const
1142
- {
1143
- return CB->getType();
1144
- }
1145
- u32_t arg_size() const
1146
- {
1147
- return CB->arg_size();
1148
- }
1149
- bool arg_empty() const
1150
- {
1151
- return CB->arg_empty();
1152
- }
1153
- const SVFValue* getArgOperand(u32_t i) const
1154
- {
1155
- return CB->getArgOperand(i);
1156
- }
1157
- u32_t getNumArgOperands() const
1158
- {
1159
- return CB->arg_size();
1160
- }
1161
- const SVFFunction* getCalledFunction() const
1162
- {
1163
- return CB->getCalledFunction();
1164
- }
1165
- const SVFValue* getCalledValue() const
1166
- {
1167
- return CB->getCalledOperand();
1168
- }
1169
- const SVFFunction* getCaller() const
1170
- {
1171
- return CB->getCaller();
1172
- }
1173
- bool isVarArg() const
1174
- {
1175
- return CB->isVarArg();
1176
- }
1177
- bool isVirtualCall() const
1178
- {
1179
- return SVFUtil::isa<SVFVirtualCallInst>(CB);
1180
- }
1181
- const SVFValue* getVtablePtr() const
1182
- {
1183
- assert(isVirtualCall() && "not a virtual call?");
1184
- return SVFUtil::cast<SVFVirtualCallInst>(CB)->getVtablePtr();
1185
- }
1186
- s32_t getFunIdxInVtable() const
1187
- {
1188
- assert(isVirtualCall() && "not a virtual call?");
1189
- return SVFUtil::cast<SVFVirtualCallInst>(CB)->getFunIdxInVtable();
1190
- }
1191
- const std::string& getFunNameOfVirtualCall() const
1192
- {
1193
- assert(isVirtualCall() && "not a virtual call?");
1194
- return SVFUtil::cast<SVFVirtualCallInst>(CB)->getFunNameOfVirtualCall();
1195
- }
1196
- bool operator==(const CallSite& CS) const
1197
- {
1198
- return CB == CS.CB;
1199
- }
1200
- bool operator!=(const CallSite& CS) const
1201
- {
1202
- return CB != CS.CB;
1203
- }
1204
- bool operator<(const CallSite& CS) const
1205
- {
1206
- return getInstruction() < CS.getInstruction();
1207
- }
1208
- };
1209
-
1210
1089
  /// [FOR DEBUG ONLY, DON'T USE IT UNSIDE `svf`!]
1211
1090
  /// Converts an SVFValue to corresponding LLVM::Value, then get the string
1212
1091
  /// representation of it. Use it only when you are debugging. Don't use
@@ -1222,14 +1101,4 @@ OutStream& operator<< (OutStream &o, const std::pair<F, S> &var)
1222
1101
 
1223
1102
  } // End namespace SVF
1224
1103
 
1225
- /// Specialise hash for CallSites.
1226
- template <> struct std::hash<SVF::CallSite>
1227
- {
1228
- size_t operator()(const SVF::CallSite &cs) const
1229
- {
1230
- std::hash<const SVF::SVFInstruction *> h;
1231
- return h(cs.getInstruction());
1232
- }
1233
- };
1234
-
1235
1104
  #endif /* INCLUDE_SVFIR_SVFVALUE_H_ */