svf-tools 1.0.995 → 1.0.997

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 (43) hide show
  1. package/package.json +1 -1
  2. package/setup.sh +0 -1
  3. package/svf/include/Graphs/CDG.h +1 -1
  4. package/svf/include/Graphs/CHG.h +10 -8
  5. package/svf/include/Graphs/GenericGraph.h +22 -1
  6. package/svf/include/Graphs/ICFGNode.h +37 -62
  7. package/svf/include/MSSA/MSSAMuChi.h +2 -2
  8. package/svf/include/MTA/LockAnalysis.h +2 -2
  9. package/svf/include/MTA/MHP.h +3 -3
  10. package/svf/include/Util/SVFUtil.h +1 -8
  11. package/svf/include/Util/ThreadAPI.h +6 -6
  12. package/svf/lib/AE/Svfexe/AEDetector.cpp +14 -20
  13. package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +49 -45
  14. package/svf/lib/CFL/CFLAlias.cpp +1 -1
  15. package/svf/lib/DDA/DDAClient.cpp +2 -2
  16. package/svf/lib/Graphs/CHG.cpp +17 -17
  17. package/svf/lib/Graphs/CallGraph.cpp +2 -1
  18. package/svf/lib/Graphs/ICFG.cpp +9 -9
  19. package/svf/lib/Graphs/SVFG.cpp +6 -6
  20. package/svf/lib/Graphs/ThreadCallGraph.cpp +8 -8
  21. package/svf/lib/Graphs/VFG.cpp +2 -2
  22. package/svf/lib/MTA/MTAStat.cpp +1 -1
  23. package/svf/lib/MTA/TCT.cpp +3 -3
  24. package/svf/lib/MemoryModel/PointerAnalysis.cpp +11 -11
  25. package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +1 -1
  26. package/svf/lib/SABER/DoubleFreeChecker.cpp +8 -8
  27. package/svf/lib/SABER/LeakChecker.cpp +10 -10
  28. package/svf/lib/SVFIR/SVFFileSystem.cpp +8 -8
  29. package/svf/lib/Util/CallGraphBuilder.cpp +2 -1
  30. package/svf/lib/Util/SVFUtil.cpp +10 -3
  31. package/svf/lib/Util/ThreadAPI.cpp +14 -16
  32. package/svf/lib/WPA/Andersen.cpp +1 -1
  33. package/svf-llvm/include/SVF-LLVM/CHGBuilder.h +5 -0
  34. package/svf-llvm/include/SVF-LLVM/DCHG.h +2 -2
  35. package/svf-llvm/include/SVF-LLVM/LLVMModule.h +10 -0
  36. package/svf-llvm/lib/CHGBuilder.cpp +23 -17
  37. package/svf-llvm/lib/DCHG.cpp +18 -18
  38. package/svf-llvm/lib/ICFGBuilder.cpp +9 -2
  39. package/svf-llvm/lib/LLVMModule.cpp +6 -0
  40. package/svf-llvm/lib/LLVMUtil.cpp +25 -8
  41. package/svf-llvm/lib/SVFIRBuilder.cpp +2 -2
  42. package/svf-llvm/lib/SVFIRExtAPI.cpp +1 -1
  43. package/svf-llvm/lib/SymbolTableBuilder.cpp +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.995",
3
+ "version": "1.0.997",
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": {
package/setup.sh CHANGED
@@ -27,7 +27,6 @@ function set_llvm {
27
27
 
28
28
  if set_llvm; then
29
29
  export LLVM_DIR
30
- export PATH="$LLVM_DIR/bin:$PATH"
31
30
  echo "LLVM_DIR=$LLVM_DIR"
32
31
  else
33
32
  echo "- LLVM_DIR not set, probably system-wide installation"
@@ -371,7 +371,7 @@ struct DOTGraphTraits<SVF::CDG *> : public DOTGraphTraits<SVF::PAG *>
371
371
  SVF::PAG::SVFStmtList &edges = SVF::PAG::getPAG()->getPTASVFStmtList(bNode);
372
372
  if (edges.empty())
373
373
  {
374
- rawstr << bNode->getInst()->toString() << " \t";
374
+ rawstr << (bNode)->toString() << " \t";
375
375
  }
376
376
  else
377
377
  {
@@ -61,7 +61,7 @@ public:
61
61
  virtual const VFunSet &getCSVFsBasedonCHA(const CallICFGNode* cs) = 0;
62
62
  virtual bool csHasVtblsBasedonCHA(const CallICFGNode* cs) = 0;
63
63
  virtual const VTableSet &getCSVtblsBasedonCHA(const CallICFGNode* cs) = 0;
64
- virtual void getVFnsFromVtbls(const SVFCallInst* cs, const VTableSet& vtbls,
64
+ virtual void getVFnsFromVtbls(const CallICFGNode* cs, const VTableSet& vtbls,
65
65
  VFunSet& virtualFunctions) = 0;
66
66
 
67
67
  CHGKind getKind(void) const
@@ -240,9 +240,10 @@ public:
240
240
  typedef Set<const CHNode*> CHNodeSetTy;
241
241
  typedef FIFOWorkList<const CHNode*> WorkList;
242
242
  typedef Map<std::string, CHNodeSetTy> NameToCHNodesMap;
243
- typedef Map<const SVFInstruction*, CHNodeSetTy> CallSiteToCHNodesMap;
244
- typedef Map<const SVFInstruction*, VTableSet> CallSiteToVTableSetMap;
245
- typedef Map<const SVFInstruction*, VFunSet> CallSiteToVFunSetMap;
243
+
244
+ typedef Map<const ICFGNode*, CHNodeSetTy> CallNodeToCHNodesMap;
245
+ typedef Map<const ICFGNode*, VTableSet> CallNodeToVTableSetMap;
246
+ typedef Map<const ICFGNode*, VFunSet> CallNodeToVFunSetMap;
246
247
 
247
248
  typedef enum
248
249
  {
@@ -260,7 +261,7 @@ public:
260
261
  const std::string baseClassName,
261
262
  CHEdge::CHEDGETYPE edgeType);
262
263
  CHNode *getNode(const std::string name) const;
263
- void getVFnsFromVtbls(const SVFCallInst* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
264
+ void getVFnsFromVtbls(const CallICFGNode* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
264
265
  void dump(const std::string& filename);
265
266
  void view();
266
267
  void printCH();
@@ -325,11 +326,12 @@ private:
325
326
  NameToCHNodesMap classNameToAncestorsMap;
326
327
  NameToCHNodesMap classNameToInstAndDescsMap;
327
328
  NameToCHNodesMap templateNameToInstancesMap;
328
- CallSiteToCHNodesMap csToClassesMap;
329
+ CallNodeToCHNodesMap callNodeToClassesMap;
329
330
 
330
331
  Map<const SVFFunction*, u32_t> virtualFunctionToIDMap;
331
- CallSiteToVTableSetMap csToCHAVtblsMap;
332
- CallSiteToVFunSetMap csToCHAVFnsMap;
332
+
333
+ CallNodeToVTableSetMap callNodeToCHAVtblsMap;
334
+ CallNodeToVFunSetMap callNodeToCHAVFnsMap;
333
335
  };
334
336
 
335
337
  } // End namespace SVF
@@ -251,7 +251,7 @@ public:
251
251
 
252
252
 
253
253
 
254
- SVFBaseNode(NodeID i, GNodeK k): id(i), nodeKind(k)
254
+ SVFBaseNode(NodeID i, GNodeK k, SVFType* ty = nullptr): id(i),nodeKind(k), type(ty)
255
255
  {
256
256
 
257
257
  }
@@ -268,9 +268,30 @@ public:
268
268
  return nodeKind;
269
269
  }
270
270
 
271
+ virtual const SVFType* getType() const
272
+ {
273
+ return type;
274
+ }
275
+
276
+ inline virtual void setSourceLoc(const std::string& sourceCodeInfo)
277
+ {
278
+ sourceLoc = sourceCodeInfo;
279
+ }
280
+
281
+ virtual const std::string getSourceLoc() const
282
+ {
283
+ return sourceLoc;
284
+ }
285
+
286
+ virtual const std::string toString() const;
287
+
288
+
271
289
  protected:
272
290
  NodeID id; ///< Node ID
273
291
  GNodeK nodeKind; ///< Node kind
292
+ const SVFType* type; ///< SVF type
293
+
294
+ std::string sourceLoc; ///< Source code information of this value
274
295
 
275
296
  /// Helper functions to check node kinds
276
297
  //{@ Check node kind
@@ -122,7 +122,7 @@ public:
122
122
 
123
123
  virtual const std::string toString() const;
124
124
 
125
- virtual const std::string getSourceLoc() const = 0;
125
+
126
126
 
127
127
  void dump() const;
128
128
 
@@ -142,6 +142,8 @@ public:
142
142
  return isICFGNodeKinds(node->getNodeKind());
143
143
  }
144
144
 
145
+
146
+
145
147
  protected:
146
148
  const SVFFunction* fun;
147
149
  const SVFBasicBlock* bb;
@@ -179,9 +181,9 @@ public:
179
181
  }
180
182
  //@}
181
183
 
182
- virtual const std::string toString() const;
184
+ const std::string toString() const override;
183
185
 
184
- virtual const std::string getSourceLoc() const
186
+ const std::string getSourceLoc() const override
185
187
  {
186
188
  return "Global ICFGNode";
187
189
  }
@@ -195,21 +197,16 @@ class IntraICFGNode : public ICFGNode
195
197
  friend class SVFIRWriter;
196
198
  friend class SVFIRReader;
197
199
  private:
198
- const SVFInstruction *inst;
200
+ bool isRet;
199
201
 
200
202
  /// Constructor to create empty IntraICFGNode (for SVFIRReader/deserialization)
201
- IntraICFGNode(NodeID id) : ICFGNode(id, IntraBlock), inst(nullptr) {}
203
+ IntraICFGNode(NodeID id) : ICFGNode(id, IntraBlock), isRet(false) {}
202
204
 
203
205
  public:
204
- IntraICFGNode(NodeID id, const SVFInstruction *i) : ICFGNode(id, IntraBlock), inst(i)
206
+ IntraICFGNode(NodeID id, const SVFBasicBlock* b, bool isReturn) : ICFGNode(id, IntraBlock), isRet(isReturn)
205
207
  {
206
- fun = inst->getFunction();
207
- bb = inst->getParent();
208
- }
209
-
210
- inline const SVFInstruction *getInst() const
211
- {
212
- return inst;
208
+ fun = b->getFunction();
209
+ bb = b;
213
210
  }
214
211
 
215
212
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -230,11 +227,11 @@ public:
230
227
  }
231
228
  //@}
232
229
 
233
- const std::string toString() const;
230
+ const std::string toString() const override;
234
231
 
235
- virtual const std::string getSourceLoc() const
232
+ inline bool isRetInst() const
236
233
  {
237
- return inst->getSourceLoc();
234
+ return isRet;
238
235
  }
239
236
  };
240
237
 
@@ -270,7 +267,6 @@ public:
270
267
  }
271
268
 
272
269
  //@}
273
- virtual const std::string getSourceLoc() const = 0;
274
270
  };
275
271
 
276
272
 
@@ -296,7 +292,7 @@ public:
296
292
  FunEntryICFGNode(NodeID id, const SVFFunction* f);
297
293
 
298
294
  /// Return function
299
- inline const SVFFunction* getFun() const
295
+ inline const SVFFunction* getFun() const override
300
296
  {
301
297
  return fun;
302
298
  }
@@ -341,9 +337,9 @@ public:
341
337
  }
342
338
  //@}
343
339
 
344
- const virtual std::string toString() const;
340
+ const std::string toString() const override;
345
341
 
346
- virtual const std::string getSourceLoc() const
342
+ const std::string getSourceLoc() const override
347
343
  {
348
344
  return "function entry: " + fun->getSourceLoc();
349
345
  }
@@ -367,7 +363,7 @@ public:
367
363
  FunExitICFGNode(NodeID id, const SVFFunction* f);
368
364
 
369
365
  /// Return function
370
- inline const SVFFunction* getFun() const
366
+ inline const SVFFunction* getFun() const override
371
367
  {
372
368
  return fun;
373
369
  }
@@ -412,9 +408,9 @@ public:
412
408
  }
413
409
  //@}
414
410
 
415
- virtual const std::string toString() const;
411
+ const std::string toString() const override;
416
412
 
417
- virtual const std::string getSourceLoc() const
413
+ const std::string getSourceLoc() const override
418
414
  {
419
415
  return "function ret: " + fun->getSourceLoc();
420
416
  }
@@ -430,7 +426,8 @@ class CallICFGNode : public InterICFGNode
430
426
 
431
427
  public:
432
428
  typedef std::vector<const SVFVar *> ActualParmNodeVec;
433
- private:
429
+
430
+ protected:
434
431
  const SVFInstruction* cs;
435
432
  const RetICFGNode* ret;
436
433
  ActualParmNodeVec APNodes;
@@ -439,17 +436,12 @@ private:
439
436
  CallICFGNode(NodeID id) : InterICFGNode(id, FunCallBlock), cs{}, ret{} {}
440
437
 
441
438
  public:
442
- CallICFGNode(NodeID id, const SVFInstruction* c)
439
+ CallICFGNode(NodeID id, const SVFInstruction* c, const SVFType* ty)
443
440
  : InterICFGNode(id, FunCallBlock), cs(c), ret(nullptr)
444
441
  {
445
442
  fun = cs->getFunction();
446
443
  bb = cs->getParent();
447
- }
448
-
449
- /// Return callsite
450
- inline const SVFInstruction* getCallSite() const
451
- {
452
- return cs;
444
+ type = ty;
453
445
  }
454
446
 
455
447
  /// Return callsite
@@ -468,13 +460,13 @@ public:
468
460
  /// Return callsite
469
461
  inline const SVFFunction* getCaller() const
470
462
  {
471
- return cs->getFunction();
463
+ return getFun();
472
464
  }
473
465
 
474
466
  /// Return Basic Block
475
467
  inline const SVFBasicBlock* getParent() const
476
468
  {
477
- return cs->getParent();
469
+ return getBB();
478
470
  }
479
471
 
480
472
  /// Return true if this is an indirect call
@@ -496,35 +488,23 @@ public:
496
488
  }
497
489
  /// Parameter operations
498
490
  //@{
499
- const SVFValue* getArgument(u32_t ArgNo) const
500
- {
501
- return SVFUtil::cast<SVFCallInst>(cs)->getArgOperand(ArgNo);
502
- }
503
-
504
- const SVFVar* getArgumentVar(u32_t ArgNo) const
491
+ const SVFVar* getArgument(u32_t ArgNo) const
505
492
  {
506
493
  return getActualParms()[ArgNo];
507
494
  }
508
495
 
509
- const SVFType* getType() const
510
- {
511
- return SVFUtil::cast<SVFCallInst>(cs)->getType();
512
- }
513
496
  u32_t arg_size() const
514
497
  {
515
- return SVFUtil::cast<SVFCallInst>(cs)->arg_size();
498
+ return APNodes.size();
516
499
  }
517
500
  bool arg_empty() const
518
501
  {
519
- return SVFUtil::cast<SVFCallInst>(cs)->arg_empty();
520
- }
521
- const SVFValue* getArgOperand(u32_t i) const
522
- {
523
- return SVFUtil::cast<SVFCallInst>(cs)->getArgOperand(i);
502
+ return APNodes.empty();
524
503
  }
504
+
525
505
  u32_t getNumArgOperands() const
526
506
  {
527
- return SVFUtil::cast<SVFCallInst>(cs)->arg_size();
507
+ return arg_size();
528
508
  }
529
509
  const SVFFunction* getCalledFunction() const
530
510
  {
@@ -587,11 +567,11 @@ public:
587
567
  }
588
568
  //@}
589
569
 
590
- virtual const std::string toString() const;
570
+ const std::string toString() const override;
591
571
 
592
- virtual const std::string getSourceLoc() const
572
+ const std::string getSourceLoc() const override
593
573
  {
594
- return "CallICFGNode: " + cs->getSourceLoc();
574
+ return "CallICFGNode: " + ICFGNode::getSourceLoc();
595
575
  }
596
576
  };
597
577
 
@@ -621,12 +601,7 @@ public:
621
601
  {
622
602
  fun = cs->getFunction();
623
603
  bb = cs->getParent();
624
- }
625
-
626
- /// Return callsite
627
- inline const SVFInstruction* getCallSite() const
628
- {
629
- return cs;
604
+ type = callBlockNode->getType();
630
605
  }
631
606
 
632
607
  inline const CallICFGNode* getCallICFGNode() const
@@ -672,11 +647,11 @@ public:
672
647
  }
673
648
  //@}
674
649
 
675
- virtual const std::string toString() const;
650
+ const std::string toString() const override;
676
651
 
677
- virtual const std::string getSourceLoc() const
652
+ const std::string getSourceLoc() const override
678
653
  {
679
- return "RetICFGNode: " + cs->getSourceLoc();
654
+ return "RetICFGNode: " + ICFGNode::getSourceLoc();
680
655
  }
681
656
  };
682
657
 
@@ -246,7 +246,7 @@ public:
246
246
  /// Return basic block
247
247
  inline const SVFBasicBlock* getBasicBlock() const
248
248
  {
249
- return callsite->getCallSite()->getParent();
249
+ return callsite->getBB();
250
250
  }
251
251
 
252
252
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -537,7 +537,7 @@ public:
537
537
  /// Return basic block
538
538
  inline const SVFBasicBlock* getBasicBlock() const
539
539
  {
540
- return callsite->getCallSite()->getParent();
540
+ return callsite->getBB();
541
541
  }
542
542
 
543
543
  /// Return callsite
@@ -349,7 +349,7 @@ private:
349
349
  bool isAliasedLocks(const ICFGNode* i1, const ICFGNode* i2)
350
350
  {
351
351
  /// todo: must alias
352
- return tct->getPTA()->alias(getLockVal(i1), getLockVal(i2));
352
+ return tct->getPTA()->alias(getLockVal(i1)->getId(), getLockVal(i2)->getId());
353
353
  }
354
354
 
355
355
  /// Mark thread flags for cxtStmt
@@ -466,7 +466,7 @@ private:
466
466
  return tct->isExtCall(inst);
467
467
  }
468
468
  /// Get lock value
469
- inline const SVFValue* getLockVal(const ICFGNode* call)
469
+ inline const SVFVar* getLockVal(const ICFGNode* call)
470
470
  {
471
471
  return getTCG()->getThreadAPI()->getLockVal(call);
472
472
  }
@@ -381,7 +381,7 @@ private:
381
381
  /// Whether it is a matched fork join pair
382
382
  bool isAliasedForkJoin(const CallICFGNode* forkSite, const CallICFGNode* joinSite)
383
383
  {
384
- return tct->getPTA()->alias(getForkedThread(forkSite), getJoinedThread(joinSite)) && isSameSCEV(forkSite,joinSite);
384
+ return tct->getPTA()->alias(getForkedThread(forkSite)->getId(), getJoinedThread(joinSite)->getId()) && isSameSCEV(forkSite,joinSite);
385
385
  }
386
386
  /// Mark thread flags for cxtStmt
387
387
  //@{
@@ -473,12 +473,12 @@ private:
473
473
  return join && getTCG()->getThreadAPI()->isTDJoin(join);
474
474
  }
475
475
  /// Get forked thread
476
- inline const SVFValue* getForkedThread(const CallICFGNode* call)
476
+ inline const SVFVar* getForkedThread(const CallICFGNode* call)
477
477
  {
478
478
  return getTCG()->getThreadAPI()->getForkedThread(call);
479
479
  }
480
480
  /// Get joined thread
481
- inline const SVFValue* getJoinedThread(const CallICFGNode* call)
481
+ inline const SVFVar* getJoinedThread(const CallICFGNode* call)
482
482
  {
483
483
  return getTCG()->getThreadAPI()->getJoinedThread(call);
484
484
  }
@@ -184,13 +184,6 @@ bool isCallSite(const ICFGNode* inst);
184
184
 
185
185
  bool isRetInstNode(const ICFGNode* node);
186
186
 
187
- /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
188
- inline bool isNonInstricCallSite(const SVFInstruction* inst)
189
- {
190
- if(isIntrinsicInst(inst))
191
- return false;
192
- return isCallSite(inst);
193
- }
194
187
 
195
188
  /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
196
189
  inline bool isNonInstricCallSite(const ICFGNode* inst)
@@ -378,7 +371,7 @@ inline bool isArgOfUncalledFunction(const SVFValue* svfval)
378
371
 
379
372
  /// Return thread fork function
380
373
  //@{
381
- inline const SVFValue* getForkedFun(const CallICFGNode *inst)
374
+ inline const SVFVar* getForkedFun(const CallICFGNode *inst)
382
375
  {
383
376
  return ThreadAPI::getThreadAPI()->getForkedFun(inst);
384
377
  }
@@ -124,12 +124,12 @@ public:
124
124
  //@{
125
125
  /// Return the first argument of the call,
126
126
  /// Note that, it is the pthread_t pointer
127
- const SVFValue* getForkedThread(const CallICFGNode *inst) const;
127
+ const SVFVar* getForkedThread(const CallICFGNode *inst) const;
128
128
  /// Return the third argument of the call,
129
129
  /// Note that, it could be function type or a void* pointer
130
- const SVFValue* getForkedFun(const CallICFGNode *inst) const;
130
+ const SVFVar* getForkedFun(const CallICFGNode *inst) const;
131
131
 
132
- /// Return the actual param of forksite
132
+ /// Return the forth argument of the call,
133
133
  /// Note that, it is the sole argument of start routine ( a void* pointer )
134
134
  const SVFVar* getActualParmAtForkSite(const CallICFGNode *inst) const;
135
135
 
@@ -153,10 +153,10 @@ public:
153
153
  //@{
154
154
  /// Return the first argument of the call,
155
155
  /// Note that, it is the pthread_t pointer
156
- const SVFValue* getJoinedThread(const CallICFGNode *inst) const;
156
+ const SVFVar* getJoinedThread(const CallICFGNode *inst) const;
157
157
  /// Return the send argument of the call,
158
158
  /// Note that, it is the pthread_t pointer
159
- const SVFValue* getRetParmAtJoinedSite(const CallICFGNode *inst) const;
159
+ const SVFVar* getRetParmAtJoinedSite(const CallICFGNode *inst) const;
160
160
  //@}
161
161
 
162
162
 
@@ -178,7 +178,7 @@ public:
178
178
  /// Return lock value
179
179
  //@{
180
180
  /// First argument of pthread_mutex_lock/pthread_mutex_unlock
181
- const SVFValue* getLockVal(const ICFGNode *inst) const;
181
+ const SVFVar* getLockVal(const ICFGNode *inst) const;
182
182
  //@}
183
183
 
184
184
  /// Return true if this call waits for a barrier
@@ -114,7 +114,6 @@ void BufOverflowDetector::detect(AbstractState& as, const ICFGNode* node)
114
114
  void BufOverflowDetector::handleStubFunctions(const SVF::CallICFGNode* callNode)
115
115
  {
116
116
  // get function name
117
- SVFIR* svfir = PAG::getPAG();
118
117
  std::string funcName = callNode->getCalledFunction()->getName();
119
118
  if (funcName == "SAFE_BUFACCESS")
120
119
  {
@@ -125,16 +124,14 @@ void BufOverflowDetector::handleStubFunctions(const SVF::CallICFGNode* callNode)
125
124
  AbstractState& as =
126
125
  AbstractInterpretation::getAEInstance().getAbsStateFromTrace(
127
126
  callNode);
128
- u32_t size_id = svfir->getValueNode(callNode->getArgument(1));
127
+ u32_t size_id = callNode->getArgument(1)->getId();
129
128
  IntervalValue val = as[size_id].getInterval();
130
129
  if (val.isBottom())
131
130
  {
132
131
  val = IntervalValue(0);
133
132
  assert(false && "SAFE_BUFACCESS size is bottom");
134
133
  }
135
- const SVFVar* arg0Val =
136
- AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(
137
- callNode->getArgument(0));
134
+ const SVFVar* arg0Val = callNode->getArgument(0);
138
135
  bool isSafe = canSafelyAccessMemory(as, arg0Val, val);
139
136
  if (isSafe)
140
137
  {
@@ -157,15 +154,13 @@ void BufOverflowDetector::handleStubFunctions(const SVF::CallICFGNode* callNode)
157
154
  AbstractInterpretation::getAEInstance().checkpoints.erase(callNode);
158
155
  if (callNode->arg_size() < 2) return;
159
156
  AbstractState&as = AbstractInterpretation::getAEInstance().getAbsStateFromTrace(callNode);
160
- u32_t size_id = svfir->getValueNode(callNode->getArgument(1));
157
+ u32_t size_id = callNode->getArgument(1)->getId();
161
158
  IntervalValue val = as[size_id].getInterval();
162
159
  if (val.isBottom())
163
160
  {
164
161
  assert(false && "UNSAFE_BUFACCESS size is bottom");
165
162
  }
166
- const SVFVar* arg0Val =
167
- AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(
168
- callNode->getArgument(0));
163
+ const SVFVar* arg0Val = callNode->getArgument(0);
169
164
  bool isSafe = canSafelyAccessMemory(as, arg0Val, val);
170
165
  if (!isSafe)
171
166
  {
@@ -225,7 +220,6 @@ void BufOverflowDetector::initExtAPIBufOverflowCheckRules()
225
220
  void BufOverflowDetector::detectExtAPI(AbstractState& as,
226
221
  const CallICFGNode* call)
227
222
  {
228
- SVFIR* svfir = PAG::getPAG();
229
223
  assert(call->getCalledFunction() && "SVFFunction* is nullptr");
230
224
 
231
225
  AbsExtAPI::ExtAPIType extType = AbsExtAPI::UNCLASSIFIED;
@@ -255,8 +249,8 @@ void BufOverflowDetector::detectExtAPI(AbstractState& as,
255
249
  extAPIBufOverflowCheckRules.at(call->getCalledFunction()->getName());
256
250
  for (auto arg : args)
257
251
  {
258
- IntervalValue offset = as[svfir->getValueNode(call->getArgument(arg.second))].getInterval() - IntervalValue(1);
259
- const SVFVar* argVar = AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(call->getArgument(arg.first));
252
+ IntervalValue offset = as[call->getArgument(arg.second)->getId()].getInterval() - IntervalValue(1);
253
+ const SVFVar* argVar = call->getArgument(arg.first);
260
254
  if (!canSafelyAccessMemory(as, argVar, offset))
261
255
  {
262
256
  AEException bug(call->toString());
@@ -275,8 +269,8 @@ void BufOverflowDetector::detectExtAPI(AbstractState& as,
275
269
  extAPIBufOverflowCheckRules.at(call->getCalledFunction()->getName());
276
270
  for (auto arg : args)
277
271
  {
278
- IntervalValue offset = as[svfir->getValueNode(call->getArgument(arg.second))].getInterval() - IntervalValue(1);
279
- const SVFVar* argVar = AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(call->getArgument(arg.first));
272
+ IntervalValue offset = as[call->getArgument(arg.second)->getId()].getInterval() - IntervalValue(1);
273
+ const SVFVar* argVar = call->getArgument(arg.first);
280
274
  if (!canSafelyAccessMemory(as, argVar, offset))
281
275
  {
282
276
  AEException bug(call->toString());
@@ -402,8 +396,8 @@ void BufOverflowDetector::updateGepObjOffsetFromBase(SVF::AddressValue gepAddrs,
402
396
  */
403
397
  bool BufOverflowDetector::detectStrcpy(AbstractState& as, const CallICFGNode *call)
404
398
  {
405
- const SVFVar* arg0Val = AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(call->getArgument(0));
406
- const SVFVar* arg1Val = AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(call->getArgument(1));
399
+ const SVFVar* arg0Val = call->getArgument(0);
400
+ const SVFVar* arg1Val = call->getArgument(1);
407
401
  IntervalValue strLen = AbstractInterpretation::getAEInstance().getUtils()->getStrlen(as, arg1Val);
408
402
  return canSafelyAccessMemory(as, arg0Val, strLen);
409
403
  }
@@ -425,8 +419,8 @@ bool BufOverflowDetector::detectStrcat(AbstractState& as, const CallICFGNode *ca
425
419
 
426
420
  if (std::find(strcatGroup.begin(), strcatGroup.end(), call->getCalledFunction()->getName()) != strcatGroup.end())
427
421
  {
428
- const SVFVar* arg0Val = AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(call->getArgument(0));
429
- const SVFVar* arg1Val = AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(call->getArgument(1));
422
+ const SVFVar* arg0Val = call->getArgument(0);
423
+ const SVFVar* arg1Val = call->getArgument(1);
430
424
  IntervalValue strLen0 = AbstractInterpretation::getAEInstance().getUtils()->getStrlen(as, arg0Val);
431
425
  IntervalValue strLen1 = AbstractInterpretation::getAEInstance().getUtils()->getStrlen(as, arg1Val);
432
426
  IntervalValue totalLen = strLen0 + strLen1;
@@ -434,8 +428,8 @@ bool BufOverflowDetector::detectStrcat(AbstractState& as, const CallICFGNode *ca
434
428
  }
435
429
  else if (std::find(strncatGroup.begin(), strncatGroup.end(), call->getCalledFunction()->getName()) != strncatGroup.end())
436
430
  {
437
- const SVFVar* arg0Val = AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(call->getArgument(0));
438
- const SVFVar* arg2Val = AbstractInterpretation::getAEInstance().getUtils()->getSVFVar(call->getArgument(2));
431
+ const SVFVar* arg0Val = call->getArgument(0);
432
+ const SVFVar* arg2Val = call->getArgument(2);
439
433
  IntervalValue arg2Num = as[arg2Val->getId()].getInterval();
440
434
  IntervalValue strLen0 = AbstractInterpretation::getAEInstance().getUtils()->getStrlen(as, arg0Val);
441
435
  IntervalValue totalLen = strLen0 + arg2Num;