svf-lib 1.0.1648 → 1.0.1650

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.
@@ -178,6 +178,10 @@ typedef llvm::BinaryOperator BinaryOperator;
178
178
  typedef llvm::UnaryOperator UnaryOperator;
179
179
  typedef llvm::UndefValue UndefValue;
180
180
 
181
+ // Related to Switch Case
182
+ typedef std::pair<const BasicBlock*, const ConstantInt*> SuccBBAndCondValPair;
183
+ typedef std::vector<SuccBBAndCondValPair> SuccBBAndCondValPairVec;
184
+
181
185
  // LLVM Intrinsic Instructions
182
186
  #if LLVM_VERSION_MAJOR >= 13
183
187
  typedef llvm::IntrinsicInst IntrinsicInst;
@@ -519,6 +519,55 @@ std::string llvmToString(const T& val)
519
519
  llvm::raw_string_ostream(str) << val;
520
520
  return str;
521
521
  }
522
+
523
+ /**
524
+ * See more: https://github.com/SVF-tools/SVF/pull/1191
525
+ *
526
+ * Given the code:
527
+ *
528
+ * switch (a) {
529
+ * case 0: printf("0\n"); break;
530
+ * case 1:
531
+ * case 2:
532
+ * case 3: printf("a >=1 && a <= 3\n"); break;
533
+ * case 4:
534
+ * case 6:
535
+ * case 7: printf("a >= 4 && a <=7\n"); break;
536
+ * default: printf("a < 0 || a > 7"); break;
537
+ * }
538
+ *
539
+ * Generate the IR:
540
+ *
541
+ * switch i32 %0, label %sw.default [
542
+ * i32 0, label %sw.bb
543
+ * i32 1, label %sw.bb1
544
+ * i32 2, label %sw.bb1
545
+ * i32 3, label %sw.bb1
546
+ * i32 4, label %sw.bb3
547
+ * i32 6, label %sw.bb3
548
+ * i32 7, label %sw.bb3
549
+ * ]
550
+ *
551
+ * We can get every case basic block and related case value:
552
+ * [
553
+ * {%sw.default, -1},
554
+ * {%sw.bb, 0},
555
+ * {%sw.bb1, 1},
556
+ * {%sw.bb1, 2},
557
+ * {%sw.bb1, 3},
558
+ * {%sw.bb3, 4},
559
+ * {%sw.bb3, 6},
560
+ * {%sw.bb3, 7},
561
+ * ]
562
+ * Note: default case value is nullptr
563
+ */
564
+ void getSuccBBandCondValPairVec(const SwitchInst &switchInst, SuccBBAndCondValPairVec &vec);
565
+
566
+ /**
567
+ * Note: default case value is nullptr
568
+ */
569
+ s64_t getCaseValue(const SwitchInst &switchInst, SuccBBAndCondValPair &succBB2CondVal);
570
+
522
571
  } // End namespace LLVMUtil
523
572
 
524
573
  } // End namespace SVF
@@ -71,23 +71,23 @@ public:
71
71
  void narrowVAddrs(IntervalExeState &lhs, const IntervalExeState &rhs);
72
72
 
73
73
  /// Return the field address given a pointer points to a struct object and an offset
74
- VAddrs getGepObjAddress(u32_t pointer, s32_t offset);
74
+ VAddrs getGepObjAddress(u32_t pointer, APOffset offset);
75
75
 
76
76
  /// Return the byte offset from one gep param offset
77
- std::pair<s32_t, s32_t> getBytefromGepTypePair(const AccessPath::VarAndGepTypePair& gep_pair, const GepStmt *gep, s32_t elem_bytesize);
77
+ std::pair<APOffset, APOffset> getBytefromGepTypePair(const AccessPath::VarAndGepTypePair& gep_pair, const GepStmt *gep, APOffset elem_bytesize);
78
78
 
79
79
  /// Return the Index offset from one gep param offset
80
- std::pair<s32_t, s32_t> getIndexfromGepTypePair(const AccessPath::VarAndGepTypePair& gep_pair, const GepStmt *gep);
80
+ std::pair<APOffset, APOffset> getIndexfromGepTypePair(const AccessPath::VarAndGepTypePair& 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 = **,
85
85
  /// s32_t elemBytesize = LLVMUtil::SVFType2ByteSize(gep->getRHSVar()->getValue()->getType());
86
86
  /// std::pair<s32_t, s32_t> byteOffset = getGepByteOffset(gep, elemBytesize);
87
- std::pair<s32_t, s32_t> getGepByteOffset(const GepStmt *gep, s32_t elemBytesize);
87
+ std::pair<APOffset, APOffset> getGepByteOffset(const GepStmt *gep, APOffset elemBytesize);
88
88
 
89
89
  /// Return the offset expression of a GepStmt
90
- std::pair<s32_t, s32_t> getGepOffset(const GepStmt *gep);
90
+ std::pair<APOffset, APOffset> getGepOffset(const GepStmt *gep);
91
91
 
92
92
  static z3::context &getContext()
93
93
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1648",
3
+ "version": "1.0.1650",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {