svf-lib 1.0.2010 → 1.0.2012

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.
Binary file
Binary file
@@ -183,20 +183,6 @@ public:
183
183
  return _varToAbsVal.at(varId);
184
184
  }
185
185
 
186
- /// get memory addresses of variable
187
- AbstractValue &getAddrs(u32_t id)
188
- {
189
- if (_varToAbsVal.find(id)!= _varToAbsVal.end())
190
- {
191
- return _varToAbsVal[id];
192
- }
193
- else
194
- {
195
- _varToAbsVal[id] = AddressValue();
196
- return _varToAbsVal[id];
197
- }
198
- }
199
-
200
186
  /// whether the variable is in varToAddrs table
201
187
  inline bool inVarToAddrsTable(u32_t id) const
202
188
  {
@@ -289,31 +275,6 @@ public:
289
275
  return (s32_t) e.lb().getNumeral();
290
276
  }
291
277
 
292
- /// Return true if map has bottom value
293
- inline bool has_bottom()
294
- {
295
- for (auto it = _varToAbsVal.begin(); it != _varToAbsVal.end(); ++it)
296
- {
297
- if (it->second.isInterval())
298
- {
299
- if (it->second.getInterval().isBottom())
300
- {
301
- return true;
302
- }
303
- }
304
- }
305
- for (auto it = _addrToAbsVal.begin(); it != _addrToAbsVal.end(); ++it)
306
- {
307
- if (it->second.isInterval())
308
- {
309
- if (it->second.getInterval().isBottom())
310
- {
311
- return true;
312
- }
313
- }
314
- }
315
- return false;
316
- }
317
278
 
318
279
  u32_t hash() const;
319
280
 
@@ -330,14 +291,8 @@ public:
330
291
  {
331
292
  assert(isVirtualMemAddress(addr) && "not virtual address?");
332
293
  u32_t objId = getInternalID(addr);
333
- auto it = _addrToAbsVal.find(objId);
334
- if(it != _addrToAbsVal.end())
335
- return it->second;
336
- else
337
- {
338
- _addrToAbsVal[objId] = IntervalValue::top();
339
- return _addrToAbsVal[objId];
340
- }
294
+ return _addrToAbsVal[objId];
295
+
341
296
  }
342
297
 
343
298
 
@@ -351,6 +306,7 @@ public:
351
306
 
352
307
  bool equals(const AbstractState&other) const;
353
308
 
309
+
354
310
  static bool eqVarToValMap(const VarToAbsValMap&lhs, const VarToAbsValMap&rhs)
355
311
  {
356
312
  if (lhs.size() != rhs.size()) return false;
@@ -359,32 +315,15 @@ public:
359
315
  auto it = rhs.find(item.first);
360
316
  if (it == rhs.end())
361
317
  return false;
362
- if (item.second.getType() == it->second.getType())
363
- {
364
- if (item.second.isInterval())
365
- {
366
- if (!item.second.getInterval().equals(it->second.getInterval()))
367
- {
368
- return false;
369
- }
370
- }
371
- else if (item.second.isAddr())
372
- {
373
- if (!item.second.getAddrs().equals(it->second.getAddrs()))
374
- {
375
- return false;
376
- }
377
- }
378
- }
318
+ if (!item.second.equals(it->second))
319
+ return false;
379
320
  else
380
321
  {
381
- return false;
382
322
  }
383
323
  }
384
324
  return true;
385
325
  }
386
326
 
387
-
388
327
  static bool lessThanVarToValMap(const VarToAbsValMap&lhs, const VarToAbsValMap&rhs)
389
328
  {
390
329
  if (lhs.empty()) return !rhs.empty();
@@ -407,12 +346,9 @@ public:
407
346
  auto it = lhs.find(item.first);
408
347
  if (it == lhs.end()) return false;
409
348
  // judge from expr id
410
- if (it->second.isInterval() && item.second.isInterval())
411
- {
412
- if (!it->second.getInterval().contain(
413
- item.second.getInterval()))
414
- return false;
415
- }
349
+ if (!it->second.getInterval().contain(
350
+ item.second.getInterval()))
351
+ return false;
416
352
 
417
353
  }
418
354
  return true;
@@ -22,6 +22,7 @@
22
22
 
23
23
  #include "AE/Core/IntervalValue.h"
24
24
  #include "AE/Core/AddressValue.h"
25
+ #include "Util/SVFUtil.h"
25
26
 
26
27
  namespace SVF
27
28
  {
@@ -30,126 +31,71 @@ class AbstractValue
30
31
  {
31
32
 
32
33
  public:
33
-
34
- enum DataType
35
- {
36
- IntervalType,
37
- AddressType,
38
- UnknownType,
39
- };
40
- DataType type;
41
34
  IntervalValue interval;
42
35
  AddressValue addrs;
43
36
 
44
- AbstractValue() : type(IntervalType)
45
- {
46
- interval = IntervalValue::top();
47
- }
48
- AbstractValue(DataType type) : type(type)
37
+ AbstractValue()
49
38
  {
50
- switch (type)
51
- {
52
- case IntervalType:
53
- interval = IntervalValue::top();
54
- break;
55
- case AddressType:
56
- addrs = AddressValue();
57
- break;
58
- case UnknownType:
59
- break;
60
- }
39
+ interval = IntervalValue::bottom();
40
+ addrs = AddressValue();
61
41
  }
62
42
 
63
- AbstractValue(const AbstractValue& other): type(other.type)
43
+ AbstractValue(const AbstractValue& other)
64
44
  {
65
- switch (type)
66
- {
67
- case IntervalType:
68
- interval = other.interval;
69
- break;
70
- case AddressType:
71
- addrs = other.addrs;
72
- break;
73
- case UnknownType:
74
- break;
75
- }
45
+ interval = other.interval;
46
+ addrs = other.addrs;
76
47
  }
77
48
 
78
49
  inline bool isInterval() const
79
50
  {
80
- return type == IntervalType;
51
+ return !interval.isBottom();
81
52
  }
82
53
  inline bool isAddr() const
83
54
  {
84
- return type == AddressType;
85
- }
86
- inline bool isUnknown() const
87
- {
88
- return type == UnknownType;
55
+ return !addrs.isBottom();
89
56
  }
90
57
 
91
- inline DataType getType() const
58
+ AbstractValue(AbstractValue &&other)
92
59
  {
93
- return type;
60
+ interval = SVFUtil::move(other.interval);
61
+ addrs = SVFUtil::move(other.addrs);
94
62
  }
95
63
 
96
- AbstractValue(AbstractValue &&other) : type(other.type)
64
+ // operator overload, supporting both interval and address
65
+ AbstractValue& operator=(const AbstractValue& other)
97
66
  {
98
- switch (type)
99
- {
100
- case IntervalType:
101
- interval = other.interval;
102
- break;
103
- case AddressType:
104
- addrs = other.addrs;
105
- break;
106
- case UnknownType:
107
- break;
108
- }
67
+ interval = other.interval;
68
+ addrs = other.addrs;
69
+ return *this;
109
70
  }
110
71
 
111
- // operator overload, supporting both interval and address
112
- AbstractValue& operator=(const AbstractValue& other)
72
+ AbstractValue& operator=(const AbstractValue&& other)
113
73
  {
114
- type = other.type;
115
- switch (type)
116
- {
117
- case IntervalType:
118
- interval = other.interval;
119
- break;
120
- case AddressType:
121
- addrs = other.addrs;
122
- break;
123
- case UnknownType:
124
- break;
125
- }
74
+ interval = SVFUtil::move(other.interval);
75
+ addrs = SVFUtil::move(other.addrs);
126
76
  return *this;
127
77
  }
128
78
 
129
79
  AbstractValue& operator=(const IntervalValue& other)
130
80
  {
131
- type = IntervalType;
132
81
  interval = other;
82
+ addrs = AddressValue();
133
83
  return *this;
134
84
  }
135
85
 
136
86
  AbstractValue& operator=(const AddressValue& other)
137
87
  {
138
- type = AddressType;
139
88
  addrs = other;
89
+ interval = IntervalValue::bottom();
140
90
  return *this;
141
91
  }
142
92
 
143
- AbstractValue(const IntervalValue& ival) : type(IntervalType), interval(ival) {}
93
+ AbstractValue(const IntervalValue& ival) : interval(ival), addrs(AddressValue()) {}
144
94
 
145
- AbstractValue(const AddressValue& addr) : type(AddressType), addrs(addr) {}
95
+ AbstractValue(const AddressValue& addr) : interval(IntervalValue::bottom()), addrs(addr) {}
146
96
 
147
97
  IntervalValue& getInterval()
148
98
  {
149
- if (isUnknown())
150
- {
151
- interval = IntervalValue::top();
152
- }
153
99
  return interval;
154
100
  }
155
101
 
@@ -172,90 +118,36 @@ public:
172
118
 
173
119
  bool equals(const AbstractValue &rhs) const
174
120
  {
175
- if (type != rhs.type)
176
- {
177
- return false;
178
- }
179
- if (isInterval())
180
- {
181
- return interval.equals(rhs.interval);
182
- }
183
- if (isAddr())
184
- {
185
- return addrs.equals(rhs.addrs);
186
- }
187
- return false;
121
+ return interval.equals(rhs.interval) && addrs.equals(rhs.addrs);
188
122
  }
189
123
 
190
124
  void join_with(const AbstractValue &other)
191
125
  {
192
- if (isUnknown())
193
- {
194
- *this = other;
195
- return;
196
- }
197
- else if (type != other.type)
198
- {
199
- return;
200
- }
201
- if (isInterval() && other.isInterval())
202
- {
203
- interval.join_with(other.interval);
204
- }
205
- if (isAddr() && other.isAddr())
206
- {
207
- addrs.join_with(other.addrs);
208
- }
209
- return;
126
+ interval.join_with(other.interval);
127
+ addrs.join_with(other.addrs);
210
128
  }
211
129
 
212
130
  void meet_with(const AbstractValue &other)
213
131
  {
214
- if (type != other.type)
215
- {
216
- return;
217
- }
218
- if (isInterval() && other.isInterval())
219
- {
220
- interval.meet_with(other.interval);
221
- }
222
- if (isAddr() && other.isAddr())
223
- {
224
- addrs.meet_with(other.addrs);
225
- }
226
- return;
132
+ interval.meet_with(other.interval);
133
+ addrs.meet_with(other.addrs);
227
134
  }
228
135
 
229
136
  void widen_with(const AbstractValue &other)
230
137
  {
231
- // widen_with only in interval
232
- if (isInterval() && other.isInterval())
233
- {
234
- interval.widen_with(other.interval);
235
- }
138
+ interval.widen_with(other.interval);
139
+ // TODO: widen Addrs
236
140
  }
237
141
 
238
142
  void narrow_with(const AbstractValue &other)
239
143
  {
240
- // narrow_with only in interval
241
- if (isInterval() && other.isInterval())
242
- {
243
- interval.narrow_with(other.interval);
244
- }
144
+ interval.narrow_with(other.interval);
145
+ // TODO: narrow Addrs
245
146
  }
246
147
 
247
148
  std::string toString() const
248
149
  {
249
- if (isInterval())
250
- {
251
- return interval.toString();
252
- }
253
- else if (isAddr())
254
- {
255
- return addrs.toString();
256
- }
257
- return "";
150
+ return "<" + interval.toString() + ", " + addrs.toString() + ">";
258
151
  }
259
-
260
152
  };
261
153
  }
@@ -62,19 +62,19 @@ public:
62
62
  void narrowAddrs(AbstractState& es, AbstractState&lhs, const AbstractState&rhs);
63
63
 
64
64
  /// Return the field address given a pointer points to a struct object and an offset
65
- AbstractValue getGepObjAddress(AbstractState& es, u32_t pointer, APOffset offset);
65
+ AddressValue getGepObjAddress(AbstractState& es, u32_t pointer, APOffset offset);
66
66
 
67
67
  /// Return the value range of Integer SVF Type, e.g. unsigned i8 Type->[0, 255], signed i8 Type->[-128, 127]
68
- AbstractValue getRangeLimitFromType(const SVFType* type);
68
+ IntervalValue getRangeLimitFromType(const SVFType* type);
69
69
 
70
- AbstractValue getZExtValue(const AbstractState& es, const SVFVar* var);
71
- AbstractValue getSExtValue(const AbstractState& es, const SVFVar* var);
72
- AbstractValue getFPToSIntValue(const AbstractState& es, const SVFVar* var);
73
- AbstractValue getFPToUIntValue(const AbstractState& es, const SVFVar* var);
74
- AbstractValue getSIntToFPValue(const AbstractState& es, const SVFVar* var);
75
- AbstractValue getUIntToFPValue(const AbstractState& es, const SVFVar* var);
76
- AbstractValue getTruncValue(const AbstractState& es, const SVFVar* var, const SVFType* dstType);
77
- AbstractValue getFPTruncValue(const AbstractState& es, const SVFVar* var, const SVFType* dstType);
70
+ IntervalValue getZExtValue(const AbstractState& es, const SVFVar* var);
71
+ IntervalValue getSExtValue(const AbstractState& es, const SVFVar* var);
72
+ IntervalValue getFPToSIntValue(const AbstractState& es, const SVFVar* var);
73
+ IntervalValue getFPToUIntValue(const AbstractState& es, const SVFVar* var);
74
+ IntervalValue getSIntToFPValue(const AbstractState& es, const SVFVar* var);
75
+ IntervalValue getUIntToFPValue(const AbstractState& es, const SVFVar* var);
76
+ IntervalValue getTruncValue(const AbstractState& es, const SVFVar* var, const SVFType* dstType);
77
+ IntervalValue getFPTruncValue(const AbstractState& es, const SVFVar* var, const SVFType* dstType);
78
78
 
79
79
  /// Return the byte offset expression of a GepStmt
80
80
  /// elemBytesize is the element byte size of an static alloc or heap alloc array
@@ -102,7 +102,7 @@ public:
102
102
  inline AbstractValue &getAddrs(AbstractState& es, u32_t id)
103
103
  {
104
104
  if (inVarToAddrsTable(es, id))
105
- return es.getAddrs(id);
105
+ return es[id];
106
106
  else
107
107
  return globalNulladdrs;
108
108
  }
Binary file
@@ -41,8 +41,8 @@ namespace SVF
41
41
  {
42
42
 
43
43
  typedef WTOComponent<ICFG> ICFGWTOComp;
44
- typedef WTONode<ICFG> ICFGWTONode;
45
- typedef WTOCycle<ICFG> ICFGWTOCycle;
44
+ typedef WTONode<ICFG> ICFGSingletonWTO;
45
+ typedef WTOCycle<ICFG> ICFGCycleWTO;
46
46
 
47
47
  class ICFGWTO : public WTO<ICFG>
48
48
  {
@@ -157,11 +157,11 @@ protected:
157
157
  bool isBranchFeasible(const IntraCFGEdge* intraEdge, AbstractState& as);
158
158
 
159
159
  /**
160
- * handle instructions in ICFGNode
160
+ * handle instructions in ICFGSingletonWTO
161
161
  *
162
- * @param block basic block that has a series of instructions
162
+ * @param block basic block that has one instruction or a series of instructions
163
163
  */
164
- virtual void handleWTONode(const ICFGNode* node);
164
+ virtual void handleWTONode(const ICFGSingletonWTO *icfgSingletonWto);
165
165
 
166
166
  /**
167
167
  * handle one instruction in ICFGNode
@@ -182,7 +182,7 @@ protected:
182
182
  *
183
183
  * @param cycle WTOCycle which has weak topo order of basic blocks and nested cycles
184
184
  */
185
- virtual void handleCycle(const ICFGWTOCycle* cycle);
185
+ virtual void handleCycle(const ICFGCycleWTO* cycle);
186
186
 
187
187
  /**
188
188
  * handle user defined function, ext function is not included.
@@ -395,21 +395,21 @@ public:
395
395
 
396
396
  private:
397
397
  /// Head of the cycle
398
- const NodeT* _head;
398
+ const WTONode<GraphT>* _head;
399
399
 
400
400
  /// List of components
401
401
  WTOComponentRefList _components;
402
402
 
403
403
  public:
404
404
  /// Constructor
405
- WTOCycle(const NodeT* head, WTOComponentRefList components)
405
+ WTOCycle(const WTONode<GraphT>* head, WTOComponentRefList components)
406
406
  : WTOComponent<GraphT>(WTOComponent<GraphT>::Cycle), _head(head),
407
407
  _components(std::move(components))
408
408
  {
409
409
  }
410
410
 
411
411
  /// Return the head of the cycle
412
- const NodeT* head() const
412
+ const WTONode<GraphT>* head() const
413
413
  {
414
414
  return _head;
415
415
  }
@@ -451,7 +451,7 @@ public:
451
451
  std::string str;
452
452
  std::stringstream rawstr(str);
453
453
  rawstr << "(";
454
- rawstr << _head->getId() << ", ";
454
+ rawstr << _head->node()->getId() << ", ";
455
455
  for (auto it = begin(), et = end(); it != et;)
456
456
  {
457
457
  rawstr << (*it)->toString();
@@ -687,7 +687,7 @@ protected:
687
687
 
688
688
  void visit(const WTOCycleT& cycle) override
689
689
  {
690
- const NodeT* head = cycle.head();
690
+ const NodeT* head = cycle.head()->node();
691
691
  WTOCycleDepthPtr previous_cycleDepth = _wtoCycleDepth;
692
692
  _nodeToWTOCycleDepth.insert(std::make_pair(head, _wtoCycleDepth));
693
693
  _wtoCycleDepth =
@@ -765,7 +765,7 @@ protected:
765
765
  return ptr;
766
766
  }
767
767
 
768
- const WTOCycleT* newCycle(const NodeT* node,
768
+ const WTOCycleT* newCycle(const WTONodeT* node,
769
769
  const WTOComponentRefList& partition)
770
770
  {
771
771
  const WTOCycleT* ptr = new WTOCycleT(node, std::move(partition));
@@ -784,7 +784,8 @@ protected:
784
784
  visit(succ, partition);
785
785
  }
786
786
  });
787
- const WTOCycleT* ptr = newCycle(node, partition);
787
+ const WTONodeT* head = newNode(node);
788
+ const WTOCycleT* ptr = newCycle(head, partition);
788
789
  headRefToCycle.emplace(node, ptr);
789
790
  return ptr;
790
791
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2010",
3
+ "version": "1.0.2012",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {