svf-lib 1.0.2004 → 1.0.2006

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.
@@ -393,7 +393,7 @@ public:
393
393
  auto it = rhs.find(item.first);
394
394
  if (it == rhs.end()) return false;
395
395
  // judge from expr id
396
- if (item.second.getInterval().geq(it->second.getInterval())) return false;
396
+ if (item.second.getInterval().contain(it->second.getInterval())) return false;
397
397
  }
398
398
  return true;
399
399
  }
@@ -409,7 +409,8 @@ public:
409
409
  // judge from expr id
410
410
  if (it->second.isInterval() && item.second.isInterval())
411
411
  {
412
- if (!it->second.getInterval().geq(item.second.getInterval()))
412
+ if (!it->second.getInterval().contain(
413
+ item.second.getInterval()))
413
414
  return false;
414
415
  }
415
416
 
@@ -298,8 +298,11 @@ public:
298
298
  this->_ub = plus_infinity();
299
299
  }
300
300
 
301
- /// Check current IntervalValue is smaller than or equal to the other
302
- bool leq(const IntervalValue &other) const
301
+ /// Determines if the current IntervalValue is fully contained within another IntervalValue.
302
+ /// Example: this: [2, 3], other: [1, 4] -> returns true
303
+ /// Note: If the current interval is 'bottom', it is considered contained within any interval.
304
+ /// If the other interval is 'bottom', it cannot contain any interval.
305
+ bool containedWithin(const IntervalValue &other) const
303
306
  {
304
307
  if (this->isBottom())
305
308
  {
@@ -316,8 +319,11 @@ public:
316
319
 
317
320
  }
318
321
 
319
- /// Check current IntervalValue is greater than or equal to the other
320
- bool geq(const IntervalValue &other) const
322
+ /// Determines if the current IntervalValue fully contains another IntervalValue.
323
+ /// Example: this: [1, 4], other: [2, 3] -> returns true
324
+ /// Note: If the current interval is 'bottom', it is considered to contain any interval.
325
+ /// If the other interval is 'bottom', it cannot be contained by any interval.
326
+ bool contain(const IntervalValue &other) const
321
327
  {
322
328
  if (this->isBottom())
323
329
  {
@@ -333,6 +339,42 @@ public:
333
339
  }
334
340
  }
335
341
 
342
+ /// Check the upper bound of this Interval is less than or equal to the lower bound
343
+ /// e.g. [1, 3] < [3, 5] return true, lhs.ub <= rhs.lb
344
+ bool leq(const IntervalValue &other) const
345
+ {
346
+ if (this->isBottom())
347
+ {
348
+ return true;
349
+ }
350
+ else if (other.isBottom())
351
+ {
352
+ return false;
353
+ }
354
+ else
355
+ {
356
+ return this->_ub.leq(other._lb);
357
+ }
358
+ }
359
+
360
+ /// Check the lower bound of this Interval is greater than or equal to the upper bound
361
+ /// e.g. [3, 5] > [1, 3] return true, lhs.lb >= rhs.ub
362
+ bool geq(const IntervalValue &other) const
363
+ {
364
+ if (this->isBottom())
365
+ {
366
+ return true;
367
+ }
368
+ else if (other.isBottom())
369
+ {
370
+ return false;
371
+ }
372
+ else
373
+ {
374
+ return this->_lb.geq(other._ub);
375
+ }
376
+ }
377
+
336
378
 
337
379
  /// Equality comparison
338
380
  bool equals(const IntervalValue &other) const
Binary file
Binary file
@@ -224,7 +224,7 @@ public:
224
224
  }
225
225
 
226
226
  /// whether the memory address stores memory addresses
227
- inline bool inLocToAddrsTable(u32_t id) const
227
+ inline bool inAddrToAddrsTable(u32_t id) const
228
228
  {
229
229
  if (_addrToAbsVal.find(id)!= _addrToAbsVal.end())
230
230
  {
@@ -237,7 +237,7 @@ public:
237
237
  }
238
238
 
239
239
  /// whether the memory address stores abstract value
240
- inline virtual bool inLocToValTable(u32_t id) const
240
+ inline virtual bool inAddrToValTable(u32_t id) const
241
241
  {
242
242
  if (_addrToAbsVal.find(id) != _addrToAbsVal.end())
243
243
  {
@@ -39,7 +39,7 @@ public:
39
39
  };
40
40
  DataType type;
41
41
  IntervalValue interval;
42
- AddressValue addr;
42
+ AddressValue addrs;
43
43
 
44
44
  AbstractValue() : type(IntervalType)
45
45
  {
@@ -53,7 +53,7 @@ public:
53
53
  interval = IntervalValue::top();
54
54
  break;
55
55
  case AddressType:
56
- addr = AddressValue();
56
+ addrs = AddressValue();
57
57
  break;
58
58
  case UnknownType:
59
59
  break;
@@ -68,7 +68,7 @@ public:
68
68
  interval = other.interval;
69
69
  break;
70
70
  case AddressType:
71
- addr = other.addr;
71
+ addrs = other.addrs;
72
72
  break;
73
73
  case UnknownType:
74
74
  break;
@@ -101,7 +101,7 @@ public:
101
101
  interval = other.interval;
102
102
  break;
103
103
  case AddressType:
104
- addr = other.addr;
104
+ addrs = other.addrs;
105
105
  break;
106
106
  case UnknownType:
107
107
  break;
@@ -118,7 +118,7 @@ public:
118
118
  interval = other.interval;
119
119
  break;
120
120
  case AddressType:
121
- addr = other.addr;
121
+ addrs = other.addrs;
122
122
  break;
123
123
  case UnknownType:
124
124
  break;
@@ -136,38 +136,13 @@ public:
136
136
  AbstractValue& operator=(const AddressValue& other)
137
137
  {
138
138
  type = AddressType;
139
- addr = other;
139
+ addrs = other;
140
140
  return *this;
141
141
  }
142
142
 
143
- AbstractValue operator==(const AbstractValue& other) const
144
- {
145
- assert(isInterval() && other.isInterval());
146
- return interval == other.interval;
147
- }
148
-
149
- AbstractValue operator==(const IntervalValue& other) const
150
- {
151
- assert(isInterval());
152
- return interval == other;
153
- }
154
-
155
- AbstractValue operator!=(const AbstractValue& other) const
156
- {
157
- assert(isInterval());
158
- return interval != other.interval;
159
- }
160
-
161
- AbstractValue operator!=(const IntervalValue& other) const
162
- {
163
- assert(isInterval());
164
- return interval != other;
165
- }
166
-
167
-
168
143
  AbstractValue(const IntervalValue& ival) : type(IntervalType), interval(ival) {}
169
144
 
170
- AbstractValue(const AddressValue& addr) : type(AddressType), addr(addr) {}
145
+ AbstractValue(const AddressValue& addr) : type(AddressType), addrs(addr) {}
171
146
 
172
147
  IntervalValue& getInterval()
173
148
  {
@@ -175,26 +150,22 @@ public:
175
150
  {
176
151
  interval = IntervalValue::top();
177
152
  }
178
- assert(isInterval() && "Attempting to retrieve an AbstractValue that is not an Interval!");
179
153
  return interval;
180
154
  }
181
155
 
182
156
  const IntervalValue getInterval() const
183
157
  {
184
- assert(isInterval() && "Attempting to retrieve an AbstractValue that is not an Interval!");
185
158
  return interval;
186
159
  }
187
160
 
188
161
  AddressValue& getAddrs()
189
162
  {
190
- assert(isAddr() && "Attempting to retrieve an AbstractValue that is not an Address!");
191
- return addr;
163
+ return addrs;
192
164
  }
193
165
 
194
166
  const AddressValue getAddrs() const
195
167
  {
196
- assert(isAddr() && "Attempting to retrieve an AbstractValue that is not an Address!");
197
- return addr;
168
+ return addrs;
198
169
  }
199
170
 
200
171
  ~AbstractValue() {};
@@ -211,7 +182,7 @@ public:
211
182
  }
212
183
  if (isAddr())
213
184
  {
214
- return addr.equals(rhs.addr);
185
+ return addrs.equals(rhs.addrs);
215
186
  }
216
187
  return false;
217
188
  }
@@ -233,7 +204,7 @@ public:
233
204
  }
234
205
  if (isAddr() && other.isAddr())
235
206
  {
236
- addr.join_with(other.addr);
207
+ addrs.join_with(other.addrs);
237
208
  }
238
209
  return;
239
210
  }
@@ -250,7 +221,7 @@ public:
250
221
  }
251
222
  if (isAddr() && other.isAddr())
252
223
  {
253
- addr.meet_with(other.addr);
224
+ addrs.meet_with(other.addrs);
254
225
  }
255
226
  return;
256
227
  }
@@ -281,7 +252,7 @@ public:
281
252
  }
282
253
  else if (isAddr())
283
254
  {
284
- return addr.toString();
255
+ return addrs.toString();
285
256
  }
286
257
  return "";
287
258
  }
@@ -211,13 +211,15 @@ public:
211
211
  /// The physical address starts with 0x7f...... + idx
212
212
  static inline u32_t getVirtualMemAddress(u32_t idx)
213
213
  {
214
+ // 0 is the null address, should not be used as a virtual address
215
+ assert(idx != 0 && "idx can’t be 0 because it represents a nullptr");
214
216
  return AddressMask + idx;
215
217
  }
216
218
 
217
219
  /// Check bit value of val start with 0x7F000000, filter by 0xFF000000
218
220
  static inline bool isVirtualMemAddress(u32_t val)
219
221
  {
220
- return (val & 0xff000000) == AddressMask;
222
+ return (val & 0xff000000) == AddressMask && val != AddressMask + 0;
221
223
  }
222
224
 
223
225
  /// Return the internal index if idx is an address otherwise return the value of idx
@@ -175,6 +175,8 @@ public:
175
175
  /// Check bit value of val start with 0x7F000000, filter by 0xFF000000
176
176
  static inline bool isVirtualMemAddress(u32_t val)
177
177
  {
178
+ if (val == 0)
179
+ assert(false && "val cannot be 0");
178
180
  return AddressValue::isVirtualMemAddress(val);
179
181
  }
180
182
 
@@ -109,6 +109,15 @@ public:
109
109
  return globalNulladdrs;
110
110
  }
111
111
 
112
+ inline bool inVarTable(const AbstractState& es, u32_t id) const
113
+ {
114
+ return es.inVarToValTable(id) || es.inVarToAddrsTable(id);
115
+ }
116
+
117
+ inline bool inAddrTable(const AbstractState& es, u32_t id) const
118
+ {
119
+ return es.inAddrToValTable(id) || es.inAddrToAddrsTable(id);
120
+ }
112
121
 
113
122
  /// whether the variable is in varToVal table
114
123
  inline bool inVarToValTable(const AbstractState& es, u32_t id) const
@@ -126,13 +135,13 @@ public:
126
135
  /// whether the memory address stores a interval value
127
136
  inline bool inLocToValTable(const AbstractState& es, u32_t id) const
128
137
  {
129
- return es.inLocToValTable(id);
138
+ return es.inAddrToValTable(id);
130
139
  }
131
140
 
132
141
  /// whether the memory address stores memory addresses
133
142
  inline bool inLocToAddrsTable(const AbstractState& es, u32_t id) const
134
143
  {
135
- return es.inLocToAddrsTable(id);
144
+ return es.inAddrToAddrsTable(id);
136
145
  }
137
146
 
138
147
  void handleAddr(AbstractState& es, const AddrStmt *addr);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2004",
3
+ "version": "1.0.2006",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {