svf-lib 1.0.803 → 1.0.807

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.
@@ -290,7 +290,7 @@ protected:
290
290
  virtual inline void buildSVFG(SVFIR* pag)
291
291
  {
292
292
  _ander = AndersenWaveDiff::createAndersenWaveDiff(pag);
293
- _svfg = svfgBuilder.buildPTROnlySVFGWithoutOPT(_ander);
293
+ _svfg = svfgBuilder.buildPTROnlySVFG(_ander);
294
294
  _pag = _svfg->getPAG();
295
295
  }
296
296
  /// Reset visited map for next points-to query
@@ -67,7 +67,7 @@ protected:
67
67
 
68
68
  void destroy();
69
69
 
70
- PAGEdge::SVFStmtSetTy& getPAGEdgeSet(PAGEdge::PEDGEK kind)
70
+ SVFStmt::SVFStmtSetTy& getPAGEdgeSet(SVFStmt::PEDGEK kind)
71
71
  {
72
72
  return pag->getPTASVFStmtSet(kind);
73
73
  }
@@ -291,7 +291,7 @@ public:
291
291
  inline bool isZeroOffsettedGepCGEdge(ConstraintEdge *edge) const
292
292
  {
293
293
  if (NormalGepCGEdge *normalGepCGEdge = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
294
- if (0 == normalGepCGEdge->getFieldOffset())
294
+ if (0 == normalGepCGEdge->getConstantFieldIdx())
295
295
  return true;
296
296
  return false;
297
297
  }
@@ -304,7 +304,7 @@ public:
304
304
  }
305
305
 
306
306
  /// Get location set of the gep edge
307
- inline s64_t getFieldOffset() const
307
+ inline s64_t getConstantFieldIdx() const
308
308
  {
309
309
  return ls.accumulateConstantFieldIdx();
310
310
  }
@@ -427,7 +427,7 @@ protected:
427
427
  void addVFGNodes();
428
428
 
429
429
  /// Get PAGEdge set
430
- virtual inline PAGEdge::SVFStmtSetTy& getPAGEdgeSet(PAGEdge::PEDGEK kind)
430
+ virtual inline SVFStmt::SVFStmtSetTy& getPAGEdgeSet(SVFStmt::PEDGEK kind)
431
431
  {
432
432
  if (isPtrOnlySVFG())
433
433
  return pag->getPTASVFStmtSet(kind);
@@ -435,7 +435,7 @@ protected:
435
435
  return pag->getSVFStmtSet(kind);
436
436
  }
437
437
 
438
- virtual inline bool isInterestedPAGNode(const PAGNode* node) const
438
+ virtual inline bool isInterestedPAGNode(const SVFVar* node) const
439
439
  {
440
440
  if (isPtrOnlySVFG())
441
441
  return node->isPointer();
@@ -74,9 +74,7 @@ public:
74
74
  static SVFG* globalSvfg;
75
75
 
76
76
  SVFG* buildPTROnlySVFG(BVDataPTAImpl* pta);
77
- SVFG* buildPTROnlySVFGWithoutOPT(BVDataPTAImpl* pta);
78
77
  SVFG* buildFullSVFG(BVDataPTAImpl* pta);
79
- SVFG* buildFullSVFGWithoutOPT(BVDataPTAImpl* pta);
80
78
 
81
79
  /// Clean up
82
80
  static void releaseSVFG()
@@ -649,9 +649,9 @@ private:
649
649
  /// Add Gep edge
650
650
  GepStmt* addGepStmt(NodeID src, NodeID dst, const LocationSet& ls, bool constGep);
651
651
  /// Add Offset(Gep) edge
652
- NormalGepStmt* addNormalGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
652
+ GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
653
653
  /// Add Variant(Gep) edge
654
- VariantGepStmt* addVariantGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
654
+ GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
655
655
  /// Add Thread fork edge for parameter passing
656
656
  TDForkPE* addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode* cs);
657
657
  /// Add Thread join edge for parameter passing
@@ -53,7 +53,7 @@ public:
53
53
  /// ThreadFork/ThreadJoin is to model parameter passings between thread spawners and spawnees.
54
54
  enum PEDGEK
55
55
  {
56
- Addr, Copy, Store, Load, Call, Ret, NormalGep, VariantGep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
56
+ Addr, Copy, Store, Load, Call, Ret, Gep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
57
57
  };
58
58
 
59
59
  private:
@@ -85,8 +85,7 @@ public:
85
85
  edge->getEdgeKind() == SVFStmt::Load ||
86
86
  edge->getEdgeKind() == SVFStmt::Call ||
87
87
  edge->getEdgeKind() == SVFStmt::Ret ||
88
- edge->getEdgeKind() == SVFStmt::NormalGep ||
89
- edge->getEdgeKind() == SVFStmt::VariantGep ||
88
+ edge->getEdgeKind() == SVFStmt::Gep ||
90
89
  edge->getEdgeKind() == SVFStmt::Cmp ||
91
90
  edge->getEdgeKind() == SVFStmt::BinaryOp ||
92
91
  edge->getEdgeKind() == SVFStmt::UnaryOp ||
@@ -227,8 +226,7 @@ public:
227
226
  edge->getEdgeKind() == SVFStmt::Load ||
228
227
  edge->getEdgeKind() == SVFStmt::Call ||
229
228
  edge->getEdgeKind() == SVFStmt::Ret ||
230
- edge->getEdgeKind() == SVFStmt::NormalGep ||
231
- edge->getEdgeKind() == SVFStmt::VariantGep ||
229
+ edge->getEdgeKind() == SVFStmt::Gep ||
232
230
  edge->getEdgeKind() == SVFStmt::ThreadFork ||
233
231
  edge->getEdgeKind() == SVFStmt::ThreadJoin;
234
232
  }
@@ -240,8 +238,7 @@ public:
240
238
  edge->getEdgeKind() == SVFStmt::Load ||
241
239
  edge->getEdgeKind() == SVFStmt::Call ||
242
240
  edge->getEdgeKind() == SVFStmt::Ret ||
243
- edge->getEdgeKind() == SVFStmt::NormalGep ||
244
- edge->getEdgeKind() == SVFStmt::VariantGep ||
241
+ edge->getEdgeKind() == SVFStmt::Gep ||
245
242
  edge->getEdgeKind() == SVFStmt::ThreadFork ||
246
243
  edge->getEdgeKind() == SVFStmt::ThreadJoin;
247
244
  }
@@ -417,7 +414,7 @@ private:
417
414
  void operator=(const GepStmt &); ///< place holder
418
415
 
419
416
  LocationSet ls; ///< location set of the gep edge
420
-
417
+ bool variantField; ///< Gep statement with a variant field index (pointer arithmetic) for struct field access (e.g., p = &(q + f), where f is a variable)
421
418
  public:
422
419
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
423
420
  //@{
@@ -427,111 +424,37 @@ public:
427
424
  }
428
425
  static inline bool classof(const SVFStmt *edge)
429
426
  {
430
- return edge->getEdgeKind() == SVFStmt::NormalGep ||
431
- edge->getEdgeKind() == SVFStmt::VariantGep;
427
+ return edge->getEdgeKind() == SVFStmt::Gep;
432
428
  }
433
429
  static inline bool classof(const GenericPAGEdgeTy *edge)
434
430
  {
435
- return edge->getEdgeKind() == SVFStmt::NormalGep ||
436
- edge->getEdgeKind() == SVFStmt::VariantGep;
431
+ return edge->getEdgeKind() == SVFStmt::Gep;
437
432
  }
438
433
  //@}
439
434
 
440
435
  inline const LocationSet& getLocationSet() const
441
436
  {
437
+ assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
442
438
  return ls;
443
439
  }
444
440
 
445
- protected:
446
- /// constructor
447
- GepStmt(SVFVar* s, SVFVar* d, const LocationSet& l, PEDGEK k) : AssignStmt(s,d,k), ls(l)
448
- {
449
- }
450
-
451
- virtual const std::string toString() const;
452
-
453
- };
454
-
455
-
456
- /*!
457
- * Gep statement with a fixed field index for struct field access
458
- */
459
- class NormalGepStmt : public GepStmt
460
- {
461
- private:
462
- NormalGepStmt(); ///< place holder
463
- NormalGepStmt(const NormalGepStmt&); ///< place holder
464
- void operator=(const NormalGepStmt&); ///< place holder
465
-
466
- public:
467
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
468
- //@{
469
- static inline bool classof(const NormalGepStmt *)
441
+ /// offset of the gep statement
442
+ inline s64_t getConstantFieldIdx() const
470
443
  {
471
- return true;
472
- }
473
- static inline bool classof(const GepStmt *edge)
474
- {
475
- return edge->getEdgeKind() == SVFStmt::NormalGep;
476
- }
477
- static inline bool classof(const SVFStmt *edge)
478
- {
479
- return edge->getEdgeKind() == SVFStmt::NormalGep;
444
+ return getLocationSet().accumulateConstantFieldIdx();
480
445
  }
481
- static inline bool classof(const GenericPAGEdgeTy *edge)
446
+ /// Gep statement with a variant field index (pointer arithmetic) for struct field access
447
+ inline bool isVariantFieldGep() const
482
448
  {
483
- return edge->getEdgeKind() == SVFStmt::NormalGep;
484
- }
485
- //@}
449
+ return variantField;
450
+ }
486
451
 
487
452
  /// constructor
488
- NormalGepStmt(SVFVar* s, SVFVar* d, const LocationSet& l) : GepStmt(s,d,l, SVFStmt::NormalGep)
489
- {}
490
-
491
- /// offset of the gep edge
492
- inline s64_t getFieldOffset() const
453
+ GepStmt(SVFVar* s, SVFVar* d, const LocationSet& l, bool varfld=false) : AssignStmt(s,d,SVFStmt::Gep), ls(l), variantField(varfld)
493
454
  {
494
- return getLocationSet().accumulateConstantFieldIdx();
495
455
  }
496
456
 
497
- virtual const std::string toString() const override;
498
- };
499
-
500
- /*!
501
- * Gep statement with a variant field index for struct field access
502
- */
503
- class VariantGepStmt : public GepStmt
504
- {
505
- private:
506
- VariantGepStmt(); ///< place holder
507
- VariantGepStmt(const VariantGepStmt&); ///< place holder
508
- void operator=(const VariantGepStmt&); ///< place holder
509
-
510
- public:
511
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
512
- //@{
513
- static inline bool classof(const VariantGepStmt *)
514
- {
515
- return true;
516
- }
517
- static inline bool classof(const GepStmt *edge)
518
- {
519
- return edge->getEdgeKind() == SVFStmt::VariantGep;
520
- }
521
- static inline bool classof(const SVFStmt *edge)
522
- {
523
- return edge->getEdgeKind() == SVFStmt::VariantGep;
524
- }
525
- static inline bool classof(const GenericPAGEdgeTy *edge)
526
- {
527
- return edge->getEdgeKind() == SVFStmt::VariantGep;
528
- }
529
- //@}
530
-
531
- /// constructor
532
- VariantGepStmt(SVFVar* s, SVFVar* d, const LocationSet& l) : GepStmt(s,d,l, SVFStmt::VariantGep) {}
533
-
534
- virtual const std::string toString() const override;
457
+ virtual const std::string toString() const;
535
458
 
536
459
  };
537
460
 
@@ -241,10 +241,13 @@ private:
241
241
  /// Has incoming VariantGepEdges
242
242
  inline bool hasIncomingVariantGepEdge() const
243
243
  {
244
- SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::VariantGep);
244
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::Gep);
245
245
  if (it != InEdgeKindToSetMap.end())
246
246
  {
247
- return (!it->second.empty());
247
+ for(auto gep : it->second){
248
+ if(SVFUtil::cast<GepStmt>(gep)->isVariantFieldGep())
249
+ return true;
250
+ }
248
251
  }
249
252
  return false;
250
253
  }
@@ -422,7 +425,7 @@ public:
422
425
  }
423
426
 
424
427
  /// offset of the base value variable
425
- inline s64_t getFieldOffset() const
428
+ inline s64_t getConstantFieldIdx() const
426
429
  {
427
430
  return ls.accumulateConstantFieldIdx();
428
431
  }
@@ -431,8 +434,8 @@ public:
431
434
  inline const std::string getValueName() const
432
435
  {
433
436
  if (value && value->hasName())
434
- return value->getName().str() + "_" + llvm::utostr(getFieldOffset());
435
- return "offset_" + llvm::utostr(getFieldOffset());
437
+ return value->getName().str() + "_" + llvm::utostr(getConstantFieldIdx());
438
+ return "offset_" + llvm::utostr(getConstantFieldIdx());
436
439
  }
437
440
 
438
441
  inline const Type* getType() const
@@ -497,7 +500,7 @@ public:
497
500
  }
498
501
 
499
502
  /// offset of the mem object
500
- inline s64_t getFieldOffset() const
503
+ inline s64_t getConstantFieldIdx() const
501
504
  {
502
505
  return ls.accumulateConstantFieldIdx();
503
506
  }
@@ -46,7 +46,7 @@ public:
46
46
  {
47
47
  }
48
48
 
49
- u32_t getFieldOffset(void) const
49
+ u32_t getConstantFieldIdx(void) const
50
50
  {
51
51
  return offset;
52
52
  }
@@ -72,7 +72,7 @@ public:
72
72
  /// Initialize nodes and edges
73
73
  //@{
74
74
  void initialiseNodes();
75
- void addEdge(NodeID src, NodeID dst, PAGEdge::PEDGEK kind,
75
+ void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
76
76
  s64_t offset = 0, Instruction* cs = nullptr);
77
77
  // @}
78
78
 
@@ -377,16 +377,16 @@ public:
377
377
  return edge;
378
378
  }
379
379
  /// Add Offset(Gep) edge
380
- inline NormalGepStmt* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
380
+ inline GepStmt* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
381
381
  {
382
- NormalGepStmt *edge = pag->addNormalGepStmt(src, dst, ls);
382
+ GepStmt *edge = pag->addNormalGepStmt(src, dst, ls);
383
383
  setCurrentBBAndValueForPAGEdge(edge);
384
384
  return edge;
385
385
  }
386
386
  /// Add Variant(Gep) edge
387
- inline VariantGepStmt* addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
387
+ inline GepStmt* addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
388
388
  {
389
- VariantGepStmt *edge = pag->addVariantGepStmt(src, dst, ls);
389
+ GepStmt *edge = pag->addVariantGepStmt(src, dst, ls);
390
390
  setCurrentBBAndValueForPAGEdge(edge);
391
391
  return edge;
392
392
  }
@@ -64,7 +64,7 @@ private:
64
64
  void writePAGgepNode(SVF::NodeID nodeId, GepObjVar* gepNode)
65
65
  {
66
66
  auto baseNodeId = gepNode->getBaseNode();
67
- auto locationSetOffset = gepNode->getFieldOffset();
67
+ auto locationSetOffset = gepNode->getConstantFieldIdx();
68
68
 
69
69
  LLVMContext &context = mainModule->getContext();
70
70
  llvm::SmallVector<llvm::Metadata *, 32> operands;
Binary file
@@ -290,7 +290,7 @@ protected:
290
290
  virtual inline void buildSVFG(SVFIR* pag)
291
291
  {
292
292
  _ander = AndersenWaveDiff::createAndersenWaveDiff(pag);
293
- _svfg = svfgBuilder.buildPTROnlySVFGWithoutOPT(_ander);
293
+ _svfg = svfgBuilder.buildPTROnlySVFG(_ander);
294
294
  _pag = _svfg->getPAG();
295
295
  }
296
296
  /// Reset visited map for next points-to query
@@ -67,7 +67,7 @@ protected:
67
67
 
68
68
  void destroy();
69
69
 
70
- PAGEdge::SVFStmtSetTy& getPAGEdgeSet(PAGEdge::PEDGEK kind)
70
+ SVFStmt::SVFStmtSetTy& getPAGEdgeSet(SVFStmt::PEDGEK kind)
71
71
  {
72
72
  return pag->getPTASVFStmtSet(kind);
73
73
  }
@@ -291,7 +291,7 @@ public:
291
291
  inline bool isZeroOffsettedGepCGEdge(ConstraintEdge *edge) const
292
292
  {
293
293
  if (NormalGepCGEdge *normalGepCGEdge = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
294
- if (0 == normalGepCGEdge->getFieldOffset())
294
+ if (0 == normalGepCGEdge->getConstantFieldIdx())
295
295
  return true;
296
296
  return false;
297
297
  }
@@ -304,7 +304,7 @@ public:
304
304
  }
305
305
 
306
306
  /// Get location set of the gep edge
307
- inline s64_t getFieldOffset() const
307
+ inline s64_t getConstantFieldIdx() const
308
308
  {
309
309
  return ls.accumulateConstantFieldIdx();
310
310
  }
@@ -427,7 +427,7 @@ protected:
427
427
  void addVFGNodes();
428
428
 
429
429
  /// Get PAGEdge set
430
- virtual inline PAGEdge::SVFStmtSetTy& getPAGEdgeSet(PAGEdge::PEDGEK kind)
430
+ virtual inline SVFStmt::SVFStmtSetTy& getPAGEdgeSet(SVFStmt::PEDGEK kind)
431
431
  {
432
432
  if (isPtrOnlySVFG())
433
433
  return pag->getPTASVFStmtSet(kind);
@@ -435,7 +435,7 @@ protected:
435
435
  return pag->getSVFStmtSet(kind);
436
436
  }
437
437
 
438
- virtual inline bool isInterestedPAGNode(const PAGNode* node) const
438
+ virtual inline bool isInterestedPAGNode(const SVFVar* node) const
439
439
  {
440
440
  if (isPtrOnlySVFG())
441
441
  return node->isPointer();
@@ -74,9 +74,7 @@ public:
74
74
  static SVFG* globalSvfg;
75
75
 
76
76
  SVFG* buildPTROnlySVFG(BVDataPTAImpl* pta);
77
- SVFG* buildPTROnlySVFGWithoutOPT(BVDataPTAImpl* pta);
78
77
  SVFG* buildFullSVFG(BVDataPTAImpl* pta);
79
- SVFG* buildFullSVFGWithoutOPT(BVDataPTAImpl* pta);
80
78
 
81
79
  /// Clean up
82
80
  static void releaseSVFG()
@@ -649,9 +649,9 @@ private:
649
649
  /// Add Gep edge
650
650
  GepStmt* addGepStmt(NodeID src, NodeID dst, const LocationSet& ls, bool constGep);
651
651
  /// Add Offset(Gep) edge
652
- NormalGepStmt* addNormalGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
652
+ GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
653
653
  /// Add Variant(Gep) edge
654
- VariantGepStmt* addVariantGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
654
+ GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
655
655
  /// Add Thread fork edge for parameter passing
656
656
  TDForkPE* addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode* cs);
657
657
  /// Add Thread join edge for parameter passing
@@ -53,7 +53,7 @@ public:
53
53
  /// ThreadFork/ThreadJoin is to model parameter passings between thread spawners and spawnees.
54
54
  enum PEDGEK
55
55
  {
56
- Addr, Copy, Store, Load, Call, Ret, NormalGep, VariantGep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
56
+ Addr, Copy, Store, Load, Call, Ret, Gep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
57
57
  };
58
58
 
59
59
  private:
@@ -85,8 +85,7 @@ public:
85
85
  edge->getEdgeKind() == SVFStmt::Load ||
86
86
  edge->getEdgeKind() == SVFStmt::Call ||
87
87
  edge->getEdgeKind() == SVFStmt::Ret ||
88
- edge->getEdgeKind() == SVFStmt::NormalGep ||
89
- edge->getEdgeKind() == SVFStmt::VariantGep ||
88
+ edge->getEdgeKind() == SVFStmt::Gep ||
90
89
  edge->getEdgeKind() == SVFStmt::Cmp ||
91
90
  edge->getEdgeKind() == SVFStmt::BinaryOp ||
92
91
  edge->getEdgeKind() == SVFStmt::UnaryOp ||
@@ -227,8 +226,7 @@ public:
227
226
  edge->getEdgeKind() == SVFStmt::Load ||
228
227
  edge->getEdgeKind() == SVFStmt::Call ||
229
228
  edge->getEdgeKind() == SVFStmt::Ret ||
230
- edge->getEdgeKind() == SVFStmt::NormalGep ||
231
- edge->getEdgeKind() == SVFStmt::VariantGep ||
229
+ edge->getEdgeKind() == SVFStmt::Gep ||
232
230
  edge->getEdgeKind() == SVFStmt::ThreadFork ||
233
231
  edge->getEdgeKind() == SVFStmt::ThreadJoin;
234
232
  }
@@ -240,8 +238,7 @@ public:
240
238
  edge->getEdgeKind() == SVFStmt::Load ||
241
239
  edge->getEdgeKind() == SVFStmt::Call ||
242
240
  edge->getEdgeKind() == SVFStmt::Ret ||
243
- edge->getEdgeKind() == SVFStmt::NormalGep ||
244
- edge->getEdgeKind() == SVFStmt::VariantGep ||
241
+ edge->getEdgeKind() == SVFStmt::Gep ||
245
242
  edge->getEdgeKind() == SVFStmt::ThreadFork ||
246
243
  edge->getEdgeKind() == SVFStmt::ThreadJoin;
247
244
  }
@@ -417,7 +414,7 @@ private:
417
414
  void operator=(const GepStmt &); ///< place holder
418
415
 
419
416
  LocationSet ls; ///< location set of the gep edge
420
-
417
+ bool variantField; ///< Gep statement with a variant field index (pointer arithmetic) for struct field access (e.g., p = &(q + f), where f is a variable)
421
418
  public:
422
419
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
423
420
  //@{
@@ -427,111 +424,37 @@ public:
427
424
  }
428
425
  static inline bool classof(const SVFStmt *edge)
429
426
  {
430
- return edge->getEdgeKind() == SVFStmt::NormalGep ||
431
- edge->getEdgeKind() == SVFStmt::VariantGep;
427
+ return edge->getEdgeKind() == SVFStmt::Gep;
432
428
  }
433
429
  static inline bool classof(const GenericPAGEdgeTy *edge)
434
430
  {
435
- return edge->getEdgeKind() == SVFStmt::NormalGep ||
436
- edge->getEdgeKind() == SVFStmt::VariantGep;
431
+ return edge->getEdgeKind() == SVFStmt::Gep;
437
432
  }
438
433
  //@}
439
434
 
440
435
  inline const LocationSet& getLocationSet() const
441
436
  {
437
+ assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
442
438
  return ls;
443
439
  }
444
440
 
445
- protected:
446
- /// constructor
447
- GepStmt(SVFVar* s, SVFVar* d, const LocationSet& l, PEDGEK k) : AssignStmt(s,d,k), ls(l)
448
- {
449
- }
450
-
451
- virtual const std::string toString() const;
452
-
453
- };
454
-
455
-
456
- /*!
457
- * Gep statement with a fixed field index for struct field access
458
- */
459
- class NormalGepStmt : public GepStmt
460
- {
461
- private:
462
- NormalGepStmt(); ///< place holder
463
- NormalGepStmt(const NormalGepStmt&); ///< place holder
464
- void operator=(const NormalGepStmt&); ///< place holder
465
-
466
- public:
467
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
468
- //@{
469
- static inline bool classof(const NormalGepStmt *)
441
+ /// offset of the gep statement
442
+ inline s64_t getConstantFieldIdx() const
470
443
  {
471
- return true;
472
- }
473
- static inline bool classof(const GepStmt *edge)
474
- {
475
- return edge->getEdgeKind() == SVFStmt::NormalGep;
476
- }
477
- static inline bool classof(const SVFStmt *edge)
478
- {
479
- return edge->getEdgeKind() == SVFStmt::NormalGep;
444
+ return getLocationSet().accumulateConstantFieldIdx();
480
445
  }
481
- static inline bool classof(const GenericPAGEdgeTy *edge)
446
+ /// Gep statement with a variant field index (pointer arithmetic) for struct field access
447
+ inline bool isVariantFieldGep() const
482
448
  {
483
- return edge->getEdgeKind() == SVFStmt::NormalGep;
484
- }
485
- //@}
449
+ return variantField;
450
+ }
486
451
 
487
452
  /// constructor
488
- NormalGepStmt(SVFVar* s, SVFVar* d, const LocationSet& l) : GepStmt(s,d,l, SVFStmt::NormalGep)
489
- {}
490
-
491
- /// offset of the gep edge
492
- inline s64_t getFieldOffset() const
453
+ GepStmt(SVFVar* s, SVFVar* d, const LocationSet& l, bool varfld=false) : AssignStmt(s,d,SVFStmt::Gep), ls(l), variantField(varfld)
493
454
  {
494
- return getLocationSet().accumulateConstantFieldIdx();
495
455
  }
496
456
 
497
- virtual const std::string toString() const override;
498
- };
499
-
500
- /*!
501
- * Gep statement with a variant field index for struct field access
502
- */
503
- class VariantGepStmt : public GepStmt
504
- {
505
- private:
506
- VariantGepStmt(); ///< place holder
507
- VariantGepStmt(const VariantGepStmt&); ///< place holder
508
- void operator=(const VariantGepStmt&); ///< place holder
509
-
510
- public:
511
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
512
- //@{
513
- static inline bool classof(const VariantGepStmt *)
514
- {
515
- return true;
516
- }
517
- static inline bool classof(const GepStmt *edge)
518
- {
519
- return edge->getEdgeKind() == SVFStmt::VariantGep;
520
- }
521
- static inline bool classof(const SVFStmt *edge)
522
- {
523
- return edge->getEdgeKind() == SVFStmt::VariantGep;
524
- }
525
- static inline bool classof(const GenericPAGEdgeTy *edge)
526
- {
527
- return edge->getEdgeKind() == SVFStmt::VariantGep;
528
- }
529
- //@}
530
-
531
- /// constructor
532
- VariantGepStmt(SVFVar* s, SVFVar* d, const LocationSet& l) : GepStmt(s,d,l, SVFStmt::VariantGep) {}
533
-
534
- virtual const std::string toString() const override;
457
+ virtual const std::string toString() const;
535
458
 
536
459
  };
537
460
 
@@ -241,10 +241,13 @@ private:
241
241
  /// Has incoming VariantGepEdges
242
242
  inline bool hasIncomingVariantGepEdge() const
243
243
  {
244
- SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::VariantGep);
244
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::Gep);
245
245
  if (it != InEdgeKindToSetMap.end())
246
246
  {
247
- return (!it->second.empty());
247
+ for(auto gep : it->second){
248
+ if(SVFUtil::cast<GepStmt>(gep)->isVariantFieldGep())
249
+ return true;
250
+ }
248
251
  }
249
252
  return false;
250
253
  }
@@ -422,7 +425,7 @@ public:
422
425
  }
423
426
 
424
427
  /// offset of the base value variable
425
- inline s64_t getFieldOffset() const
428
+ inline s64_t getConstantFieldIdx() const
426
429
  {
427
430
  return ls.accumulateConstantFieldIdx();
428
431
  }
@@ -431,8 +434,8 @@ public:
431
434
  inline const std::string getValueName() const
432
435
  {
433
436
  if (value && value->hasName())
434
- return value->getName().str() + "_" + llvm::utostr(getFieldOffset());
435
- return "offset_" + llvm::utostr(getFieldOffset());
437
+ return value->getName().str() + "_" + llvm::utostr(getConstantFieldIdx());
438
+ return "offset_" + llvm::utostr(getConstantFieldIdx());
436
439
  }
437
440
 
438
441
  inline const Type* getType() const
@@ -497,7 +500,7 @@ public:
497
500
  }
498
501
 
499
502
  /// offset of the mem object
500
- inline s64_t getFieldOffset() const
503
+ inline s64_t getConstantFieldIdx() const
501
504
  {
502
505
  return ls.accumulateConstantFieldIdx();
503
506
  }
@@ -46,7 +46,7 @@ public:
46
46
  {
47
47
  }
48
48
 
49
- u32_t getFieldOffset(void) const
49
+ u32_t getConstantFieldIdx(void) const
50
50
  {
51
51
  return offset;
52
52
  }
@@ -72,7 +72,7 @@ public:
72
72
  /// Initialize nodes and edges
73
73
  //@{
74
74
  void initialiseNodes();
75
- void addEdge(NodeID src, NodeID dst, PAGEdge::PEDGEK kind,
75
+ void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
76
76
  s64_t offset = 0, Instruction* cs = nullptr);
77
77
  // @}
78
78
 
@@ -377,16 +377,16 @@ public:
377
377
  return edge;
378
378
  }
379
379
  /// Add Offset(Gep) edge
380
- inline NormalGepStmt* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
380
+ inline GepStmt* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
381
381
  {
382
- NormalGepStmt *edge = pag->addNormalGepStmt(src, dst, ls);
382
+ GepStmt *edge = pag->addNormalGepStmt(src, dst, ls);
383
383
  setCurrentBBAndValueForPAGEdge(edge);
384
384
  return edge;
385
385
  }
386
386
  /// Add Variant(Gep) edge
387
- inline VariantGepStmt* addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
387
+ inline GepStmt* addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
388
388
  {
389
- VariantGepStmt *edge = pag->addVariantGepStmt(src, dst, ls);
389
+ GepStmt *edge = pag->addVariantGepStmt(src, dst, ls);
390
390
  setCurrentBBAndValueForPAGEdge(edge);
391
391
  return edge;
392
392
  }
@@ -64,7 +64,7 @@ private:
64
64
  void writePAGgepNode(SVF::NodeID nodeId, GepObjVar* gepNode)
65
65
  {
66
66
  auto baseNodeId = gepNode->getBaseNode();
67
- auto locationSetOffset = gepNode->getFieldOffset();
67
+ auto locationSetOffset = gepNode->getConstantFieldIdx();
68
68
 
69
69
  LLVMContext &context = mainModule->getContext();
70
70
  llvm::SmallVector<llvm::Metadata *, 32> operands;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.803",
3
+ "version": "1.0.807",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {