svf-lib 1.0.1721 → 1.0.1723

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.
@@ -661,9 +661,9 @@ inline IntervalValue operator<(const IntervalValue &lhs, const IntervalValue &rh
661
661
  }
662
662
  // Return [0,0] means lhs is totally impossible to be less than rhs
663
663
  // i.e., lhs is totally greater than or equal to rhs
664
- // When lhs.ub >= rhs.lb, e.g., lhs:[3, 4] rhs:[4,5]
665
- // lhs.ub(4) >= rhs.lb(4)
666
- else if (rhs.ub().geq(lhs.lb()))
664
+ // When lhs.lb >= rhs.ub, e.g., lhs:[4,5] rhs:[3,4]
665
+ // lhs.lb(4) >= rhs.ub(4)
666
+ else if (lhs.lb().geq(rhs.ub()))
667
667
  {
668
668
  return IntervalValue(0, 0);
669
669
  }
@@ -74,20 +74,20 @@ public:
74
74
  VAddrs getGepObjAddress(u32_t pointer, APOffset offset);
75
75
 
76
76
  /// Return the byte offset from one gep param offset
77
- std::pair<APOffset, APOffset> getBytefromGepTypePair(const AccessPath::VarAndGepTypePair& gep_pair, const GepStmt *gep);
77
+ IntervalValue getByteOffsetfromGepTypePair(const AccessPath::IdxVarAndGepTypePair& gep_pair, const GepStmt *gep);
78
78
 
79
79
  /// Return the Index offset from one gep param offset
80
- std::pair<APOffset, APOffset> getIndexfromGepTypePair(const AccessPath::VarAndGepTypePair& gep_pair, const GepStmt *gep);
80
+ IntervalValue getItvOfFlattenedElemIndexFromGepTypePair(const AccessPath::IdxVarAndGepTypePair& gep_pair, const GepStmt *gep);
81
81
 
82
82
  /// Return the byte offset expression of a GepStmt
83
83
  /// elemBytesize is the element byte size of an static alloc or heap alloc array
84
84
  /// e.g. GepStmt* gep = [i32*10], x, and x is [0,3]
85
- /// std::pair<s32_t, s32_t> byteOffset = getGepByteOffset(gep);
85
+ /// std::pair<s32_t, s32_t> byteOffset = getByteOffset(gep);
86
86
  /// byteOffset should be [0, 12] since i32 is 4 bytes.
87
- std::pair<APOffset, APOffset> getGepByteOffset(const GepStmt *gep);
87
+ IntervalValue getByteOffset(const GepStmt *gep);
88
88
 
89
89
  /// Return the offset expression of a GepStmt
90
- std::pair<APOffset, APOffset> getGepOffset(const GepStmt *gep);
90
+ IntervalValue getItvOfFlattenedElemIndex(const GepStmt *gep);
91
91
 
92
92
 
93
93
  static z3::context &getContext()
@@ -61,8 +61,8 @@ public:
61
61
  NonOverlap, Overlap, Subset, Superset, Same
62
62
  };
63
63
 
64
- typedef std::pair<const SVFVar*, const SVFType*> VarAndGepTypePair;
65
- typedef std::vector<VarAndGepTypePair> OffsetVarAndGepTypePairs;
64
+ typedef std::pair<const SVFVar*, const SVFType*> IdxVarAndGepTypePair;
65
+ typedef std::vector<IdxVarAndGepTypePair> IdxVarAndGepTypePairs;
66
66
 
67
67
  /// Constructor
68
68
  AccessPath(APOffset o = 0) : fldIdx(o) {}
@@ -103,7 +103,7 @@ public:
103
103
  {
104
104
  fldIdx = idx;
105
105
  }
106
- inline const OffsetVarAndGepTypePairs& getOffsetVarAndGepTypePairVec() const
106
+ inline const IdxVarAndGepTypePairs& getOffsetVarAndGepTypePairVec() const
107
107
  {
108
108
  return offsetVarAndGepTypePairs;
109
109
  }
@@ -163,7 +163,8 @@ private:
163
163
  NodeBS computeAllLocations() const;
164
164
 
165
165
  APOffset fldIdx; ///< Accumulated Constant Offsets
166
- OffsetVarAndGepTypePairs offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
166
+ IdxVarAndGepTypePairs
167
+ offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
167
168
  };
168
169
 
169
170
  } // End namespace SVF
@@ -173,7 +174,7 @@ template <> struct std::hash<SVF::AccessPath>
173
174
  size_t operator()(const SVF::AccessPath &ap) const
174
175
  {
175
176
  SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
176
- std::hash<SVF::AccessPath::OffsetVarAndGepTypePairs> v;
177
+ std::hash<SVF::AccessPath::IdxVarAndGepTypePairs> v;
177
178
  return h(std::make_pair(ap.getConstantFieldIdx(),
178
179
  v(ap.getOffsetVarAndGepTypePairVec())));
179
180
  }
@@ -342,6 +342,7 @@ public:
342
342
  AddrStmt(SVFVar* s, SVFVar* d) : AssignStmt(s, d, SVFStmt::Addr) {}
343
343
 
344
344
  virtual const std::string toString() const override;
345
+
345
346
  };
346
347
 
347
348
  /*!
@@ -491,7 +492,8 @@ public:
491
492
  {
492
493
  return ap;
493
494
  }
494
- inline const AccessPath::OffsetVarAndGepTypePairs getOffsetVarAndGepTypePairVec() const
495
+ inline const AccessPath::IdxVarAndGepTypePairs
496
+ getOffsetVarAndGepTypePairVec() const
495
497
  {
496
498
  return getAccessPath().getOffsetVarAndGepTypePairVec();
497
499
  }
@@ -264,12 +264,13 @@ private:
264
264
  getPointerToTy; /// Return a pointer to the current type
265
265
  StInfo* typeinfo; ///< SVF's TypeInfo
266
266
  bool isSingleValTy; ///< The type represents a single value, not struct or
267
+ u32_t byteSize; ///< LLVM Byte Size
267
268
  ///< array
268
269
 
269
270
  protected:
270
- SVFType(bool svt, SVFTyKind k)
271
+ SVFType(bool svt, SVFTyKind k, u32_t Sz)
271
272
  : kind(k), getPointerToTy(nullptr), typeinfo(nullptr),
272
- isSingleValTy(svt)
273
+ isSingleValTy(svt), byteSize(Sz)
273
274
  {
274
275
  }
275
276
 
@@ -299,7 +300,6 @@ public:
299
300
  return getPointerToTy;
300
301
  }
301
302
 
302
- u32_t getLLVMByteSize() const;
303
303
 
304
304
  inline void setTypeInfo(StInfo* ti)
305
305
  {
@@ -318,6 +318,13 @@ public:
318
318
  return typeinfo;
319
319
  }
320
320
 
321
+ /// if Type is not sized, byteSize is 0
322
+ /// if Type is sized, byteSize is the LLVM Byte Size.
323
+ inline u32_t getByteSize() const
324
+ {
325
+ return byteSize;
326
+ }
327
+
321
328
  inline bool isPointerTy() const
322
329
  {
323
330
  return kind == SVFPointerTy;
@@ -350,8 +357,8 @@ private:
350
357
  const SVFType* ptrElementType;
351
358
 
352
359
  public:
353
- SVFPointerType()
354
- : SVFType(true, SVFPointerTy), ptrElementType(nullptr)
360
+ SVFPointerType(u32_t byteSize)
361
+ : SVFType(true, SVFPointerTy, byteSize), ptrElementType(nullptr)
355
362
  {
356
363
  }
357
364
 
@@ -382,7 +389,7 @@ private:
382
389
  short signAndWidth; ///< For printing
383
390
 
384
391
  public:
385
- SVFIntegerType() : SVFType(true, SVFIntegerTy) {}
392
+ SVFIntegerType(u32_t byteSize) : SVFType(true, SVFIntegerTy, byteSize) {}
386
393
  static inline bool classof(const SVFType* node)
387
394
  {
388
395
  return node->getKind() == SVFIntegerTy;
@@ -411,7 +418,7 @@ private:
411
418
 
412
419
  public:
413
420
  SVFFunctionType(const SVFType* rt)
414
- : SVFType(false, SVFFunctionTy), retTy(rt)
421
+ : SVFType(false, SVFFunctionTy, 0), retTy(rt)
415
422
  {
416
423
  }
417
424
  static inline bool classof(const SVFType* node)
@@ -436,7 +443,7 @@ private:
436
443
  std::string name;
437
444
 
438
445
  public:
439
- SVFStructType() : SVFType(false, SVFStructTy) {}
446
+ SVFStructType(u32_t byteSize) : SVFType(false, SVFStructTy, byteSize) {}
440
447
 
441
448
  static inline bool classof(const SVFType* node)
442
449
  {
@@ -469,8 +476,8 @@ private:
469
476
  const SVFType* typeOfElement; /// For printing & debugging
470
477
 
471
478
  public:
472
- SVFArrayType()
473
- : SVFType(false, SVFArrayTy), numOfElement(0), typeOfElement(nullptr)
479
+ SVFArrayType(u32_t byteSize)
480
+ : SVFType(false, SVFArrayTy, byteSize), numOfElement(0), typeOfElement(nullptr)
474
481
  {
475
482
  }
476
483
 
@@ -508,7 +515,7 @@ private:
508
515
  std::string repr; /// Field representation for printing
509
516
 
510
517
  public:
511
- SVFOtherType(bool isSingleValueTy) : SVFType(isSingleValueTy, SVFOtherTy) {}
518
+ SVFOtherType(u32_t byteSize, bool isSingleValueTy) : SVFType(isSingleValueTy, SVFOtherTy, byteSize) {}
512
519
 
513
520
  static inline bool classof(const SVFType* node)
514
521
  {
@@ -659,9 +659,9 @@ inline IntervalValue operator<(const IntervalValue &lhs, const IntervalValue &rh
659
659
  }
660
660
  // Return [0,0] means lhs is totally impossible to be less than rhs
661
661
  // i.e., lhs is totally greater than or equal to rhs
662
- // When lhs.ub >= rhs.lb, e.g., lhs:[3, 4] rhs:[4,5]
663
- // lhs.ub(4) >= rhs.lb(4)
664
- else if (rhs.ub().geq(lhs.lb()))
662
+ // When lhs.lb >= rhs.ub, e.g., lhs:[4,5] rhs:[3,4]
663
+ // lhs.lb(4) >= rhs.ub(4)
664
+ else if (lhs.lb().geq(rhs.ub()))
665
665
  {
666
666
  return IntervalValue(0, 0);
667
667
  }
@@ -74,20 +74,20 @@ public:
74
74
  VAddrs getGepObjAddress(u32_t pointer, APOffset offset);
75
75
 
76
76
  /// Return the byte offset from one gep param offset
77
- std::pair<APOffset, APOffset> getBytefromGepTypePair(const AccessPath::VarAndGepTypePair& gep_pair, const GepStmt *gep);
77
+ IntervalValue getByteOffsetfromGepTypePair(const AccessPath::IdxVarAndGepTypePair& gep_pair, const GepStmt *gep);
78
78
 
79
79
  /// Return the Index offset from one gep param offset
80
- std::pair<APOffset, APOffset> getIndexfromGepTypePair(const AccessPath::VarAndGepTypePair& gep_pair, const GepStmt *gep);
80
+ IntervalValue getItvOfFlattenedElemIndexFromGepTypePair(const AccessPath::IdxVarAndGepTypePair& gep_pair, const GepStmt *gep);
81
81
 
82
82
  /// Return the byte offset expression of a GepStmt
83
83
  /// elemBytesize is the element byte size of an static alloc or heap alloc array
84
84
  /// e.g. GepStmt* gep = [i32*10], x, and x is [0,3]
85
- /// std::pair<s32_t, s32_t> byteOffset = getGepByteOffset(gep);
85
+ /// std::pair<s32_t, s32_t> byteOffset = getByteOffset(gep);
86
86
  /// byteOffset should be [0, 12] since i32 is 4 bytes.
87
- std::pair<APOffset, APOffset> getGepByteOffset(const GepStmt *gep);
87
+ IntervalValue getByteOffset(const GepStmt *gep);
88
88
 
89
89
  /// Return the offset expression of a GepStmt
90
- std::pair<APOffset, APOffset> getGepOffset(const GepStmt *gep);
90
+ IntervalValue getItvOfFlattenedElemIndex(const GepStmt *gep);
91
91
 
92
92
  static z3::context &getContext()
93
93
  {
@@ -57,8 +57,8 @@ public:
57
57
  NonOverlap, Overlap, Subset, Superset, Same
58
58
  };
59
59
 
60
- typedef std::pair<const SVFVar*, const SVFType*> VarAndGepTypePair;
61
- typedef std::vector<VarAndGepTypePair> OffsetVarAndGepTypePairs;
60
+ typedef std::pair<const SVFVar*, const SVFType*> IdxVarAndGepTypePair;
61
+ typedef std::vector<IdxVarAndGepTypePair> IdxVarAndGepTypePairs;
62
62
 
63
63
  /// Constructor
64
64
  AccessPath(APOffset o = 0) : fldIdx(o) {}
@@ -99,7 +99,7 @@ public:
99
99
  {
100
100
  fldIdx = idx;
101
101
  }
102
- inline const OffsetVarAndGepTypePairs& getOffsetVarAndGepTypePairVec() const
102
+ inline const IdxVarAndGepTypePairs& getOffsetVarAndGepTypePairVec() const
103
103
  {
104
104
  return offsetVarAndGepTypePairs;
105
105
  }
@@ -158,7 +158,8 @@ private:
158
158
  NodeBS computeAllLocations() const;
159
159
 
160
160
  APOffset fldIdx; ///< Accumulated Constant Offsets
161
- OffsetVarAndGepTypePairs offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
161
+ IdxVarAndGepTypePairs
162
+ offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
162
163
  };
163
164
 
164
165
  } // End namespace SVF
@@ -168,7 +169,7 @@ template <> struct std::hash<SVF::AccessPath>
168
169
  size_t operator()(const SVF::AccessPath &ap) const
169
170
  {
170
171
  SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
171
- std::hash<SVF::AccessPath::OffsetVarAndGepTypePairs> v;
172
+ std::hash<SVF::AccessPath::IdxVarAndGepTypePairs> v;
172
173
  return h(std::make_pair(ap.getConstantFieldIdx(),
173
174
  v(ap.getOffsetVarAndGepTypePairVec())));
174
175
  }
@@ -341,6 +341,7 @@ public:
341
341
  AddrStmt(SVFVar* s, SVFVar* d) : AssignStmt(s, d, SVFStmt::Addr) {}
342
342
 
343
343
  virtual const std::string toString() const override;
344
+
344
345
  };
345
346
 
346
347
  /*!
@@ -490,7 +491,8 @@ public:
490
491
  {
491
492
  return ap;
492
493
  }
493
- inline const AccessPath::OffsetVarAndGepTypePairs getOffsetVarAndGepTypePairVec() const
494
+ inline const AccessPath::IdxVarAndGepTypePairs
495
+ getOffsetVarAndGepTypePairVec() const
494
496
  {
495
497
  return getAccessPath().getOffsetVarAndGepTypePairVec();
496
498
  }
@@ -264,12 +264,13 @@ private:
264
264
  getPointerToTy; /// Return a pointer to the current type
265
265
  StInfo* typeinfo; ///< SVF's TypeInfo
266
266
  bool isSingleValTy; ///< The type represents a single value, not struct or
267
+ u32_t byteSize; ///< LLVM Byte Size
267
268
  ///< array
268
269
 
269
270
  protected:
270
- SVFType(bool svt, SVFTyKind k)
271
+ SVFType(bool svt, SVFTyKind k, u32_t Sz)
271
272
  : kind(k), getPointerToTy(nullptr), typeinfo(nullptr),
272
- isSingleValTy(svt)
273
+ isSingleValTy(svt), byteSize(Sz)
273
274
  {
274
275
  }
275
276
 
@@ -299,8 +300,6 @@ public:
299
300
  return getPointerToTy;
300
301
  }
301
302
 
302
- u32_t getLLVMByteSize() const;
303
-
304
303
  inline void setTypeInfo(StInfo* ti)
305
304
  {
306
305
  typeinfo = ti;
@@ -318,6 +317,13 @@ public:
318
317
  return typeinfo;
319
318
  }
320
319
 
320
+ /// if Type is not sized, byteSize is 0
321
+ /// if Type is sized, byteSize is the LLVM Byte Size.
322
+ inline u32_t getByteSize() const
323
+ {
324
+ return byteSize;
325
+ }
326
+
321
327
  inline bool isPointerTy() const
322
328
  {
323
329
  return kind == SVFPointerTy;
@@ -350,8 +356,8 @@ private:
350
356
  const SVFType* ptrElementType;
351
357
 
352
358
  public:
353
- SVFPointerType()
354
- : SVFType(true, SVFPointerTy), ptrElementType(nullptr)
359
+ SVFPointerType(u32_t byteSize)
360
+ : SVFType(true, SVFPointerTy, byteSize), ptrElementType(nullptr)
355
361
  {
356
362
  }
357
363
 
@@ -382,7 +388,7 @@ private:
382
388
  short signAndWidth; ///< For printing
383
389
 
384
390
  public:
385
- SVFIntegerType() : SVFType(true, SVFIntegerTy) {}
391
+ SVFIntegerType(u32_t byteSize) : SVFType(true, SVFIntegerTy, byteSize) {}
386
392
  static inline bool classof(const SVFType* node)
387
393
  {
388
394
  return node->getKind() == SVFIntegerTy;
@@ -411,7 +417,7 @@ private:
411
417
 
412
418
  public:
413
419
  SVFFunctionType(const SVFType* rt)
414
- : SVFType(false, SVFFunctionTy), retTy(rt)
420
+ : SVFType(false, SVFFunctionTy, 0), retTy(rt)
415
421
  {
416
422
  }
417
423
  static inline bool classof(const SVFType* node)
@@ -436,7 +442,7 @@ private:
436
442
  std::string name;
437
443
 
438
444
  public:
439
- SVFStructType() : SVFType(false, SVFStructTy) {}
445
+ SVFStructType(u32_t byteSize) : SVFType(false, SVFStructTy, byteSize) {}
440
446
 
441
447
  static inline bool classof(const SVFType* node)
442
448
  {
@@ -469,8 +475,8 @@ private:
469
475
  const SVFType* typeOfElement; /// For printing & debugging
470
476
 
471
477
  public:
472
- SVFArrayType()
473
- : SVFType(false, SVFArrayTy), numOfElement(0), typeOfElement(nullptr)
478
+ SVFArrayType(u32_t byteSize)
479
+ : SVFType(false, SVFArrayTy, byteSize), numOfElement(0), typeOfElement(nullptr)
474
480
  {
475
481
  }
476
482
 
@@ -507,7 +513,7 @@ private:
507
513
  std::string repr; /// Field representation for printing
508
514
 
509
515
  public:
510
- SVFOtherType(bool isSingleValueTy) : SVFType(isSingleValueTy, SVFOtherTy) {}
516
+ SVFOtherType(u32_t byteSize, bool isSingleValueTy) : SVFType(isSingleValueTy, SVFOtherTy, byteSize) {}
511
517
 
512
518
  static inline bool classof(const SVFType* node)
513
519
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1721",
3
+ "version": "1.0.1723",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {