svf-tools 1.0.697 → 1.0.698

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.697",
3
+ "version": "1.0.698",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -140,11 +140,11 @@ public:
140
140
 
141
141
  VAddrs &getVAddrs(u32_t id) override
142
142
  {
143
- auto it = globalES._varToVAddrs.find(id);
144
- if (it != globalES._varToVAddrs.end())
143
+ auto it = _varToVAddrs.find(id);
144
+ if (it != _varToVAddrs.end())
145
145
  return it->second;
146
146
  else
147
- return _varToVAddrs[id];
147
+ return globalES._varToVAddrs[id];
148
148
  }
149
149
 
150
150
  inline bool inVarToIValTable(u32_t id) const
@@ -201,14 +201,24 @@ public:
201
201
  /// [], call getValueExpr()
202
202
  inline IntervalValue &operator[](u32_t varId)
203
203
  {
204
- auto it = globalES._varToItvVal.find(varId);
205
- if (it != globalES._varToItvVal.end())
204
+ auto localIt = _varToItvVal.find(varId);
205
+ if(localIt != _varToItvVal.end())
206
+ return localIt->second;
207
+ else
206
208
  {
207
- return it->second;
209
+ return globalES._varToItvVal[varId];
208
210
  }
209
- else
211
+ }
212
+
213
+ inline void cpyItvToLocal(u32_t varId)
214
+ {
215
+ auto localIt = _varToItvVal.find(varId);
216
+ // local already have varId
217
+ if (localIt != _varToItvVal.end()) return;
218
+ auto globIt = globalES._varToItvVal.find(varId);
219
+ if (globIt != globalES._varToItvVal.end())
210
220
  {
211
- return _varToItvVal[varId];
221
+ _varToItvVal[varId] = globIt->second;
212
222
  }
213
223
  }
214
224
 
@@ -370,16 +380,29 @@ public:
370
380
 
371
381
  static bool lessThanVarToValMap(const VarToValMap &lhs, const VarToValMap &rhs)
372
382
  {
383
+ if (lhs.empty()) return !rhs.empty();
373
384
  for (const auto &item: lhs)
374
385
  {
375
386
  auto it = rhs.find(item.first);
387
+ if (it == rhs.end()) return false;
376
388
  // judge from expr id
377
- if (!item.second.equals(it->second))
378
- {
379
- return !item.second.geq(it->second);
380
- }
389
+ if (item.second.geq(it->second)) return false;
381
390
  }
382
- return false;
391
+ return true;
392
+ }
393
+
394
+ // lhs >= rhs
395
+ static bool geqVarToValMap(const VarToValMap &lhs, const VarToValMap &rhs)
396
+ {
397
+ if (rhs.empty()) return true;
398
+ for (const auto &item: rhs)
399
+ {
400
+ auto it = lhs.find(item.first);
401
+ if (it == lhs.end()) return false;
402
+ // judge from expr id
403
+ if (!it->second.geq(item.second)) return false;
404
+ }
405
+ return true;
383
406
  }
384
407
 
385
408
  bool operator==(const IntervalExeState &rhs) const
@@ -395,15 +418,13 @@ public:
395
418
 
396
419
  bool operator<(const IntervalExeState &rhs) const
397
420
  {
398
- // judge from path constraint
399
- return (lessThanVarToValMap(_varToItvVal, rhs.getVarToVal()) ||
400
- lessThanVarToValMap(_locToItvVal, rhs.getLocToVal()));
421
+ return !(*this >= rhs);
401
422
  }
402
423
 
403
424
 
404
425
  bool operator>=(const IntervalExeState &rhs) const
405
426
  {
406
- return !(*this < rhs);
427
+ return geqVarToValMap(_varToItvVal, rhs.getVarToVal()) && geqVarToValMap(_locToItvVal, rhs.getLocToVal());
407
428
  }
408
429
 
409
430
  void clear()
@@ -438,9 +438,19 @@ public:
438
438
  }
439
439
  }
440
440
 
441
- std::string toString() const
441
+ const std::string toString() const
442
442
  {
443
- return "[" + lb().to_string() + ", " + ub().to_string() + "]";
443
+ std::string str;
444
+ std::stringstream rawStr(str);
445
+ if (this->isBottom())
446
+ {
447
+ rawStr << "⊥";
448
+ }
449
+ else
450
+ {
451
+ rawStr << "[" << lb().to_string() << ", " << ub().to_string() << "]";
452
+ }
453
+ return rawStr.str();
444
454
  }
445
455
 
446
456
  }; // end class IntervalValue
@@ -600,7 +600,7 @@ void SVFIR2ItvExeState::translateLoad(const LoadStmt *load)
600
600
  if (inLocToIValTable(objId))
601
601
  _es[lhs] = IntervalValue::bottom();
602
602
  else if (inLocToAddrsTable(objId))
603
- getVAddrs(lhs).setBottom();
603
+ _es.getVAddrs(lhs).setBottom();
604
604
  break;
605
605
  }
606
606
  for (const auto &addr: addrs)
@@ -621,11 +621,11 @@ void SVFIR2ItvExeState::translateLoad(const LoadStmt *load)
621
621
  {
622
622
  if (!inVarToAddrsTable(lhs))
623
623
  {
624
- getEs().getVAddrs(lhs) = _es.loadVAddrs(addr);
624
+ _es.getVAddrs(lhs) = _es.loadVAddrs(addr);
625
625
  }
626
626
  else
627
627
  {
628
- getVAddrs(lhs).join_with(_es.loadVAddrs(addr));
628
+ _es.getVAddrs(lhs).join_with(_es.loadVAddrs(addr));
629
629
  }
630
630
  }
631
631
  }
@@ -678,7 +678,7 @@ void SVFIR2ItvExeState::translateCopy(const CopyStmt *copy)
678
678
  else if (inVarToAddrsTable(rhs))
679
679
  {
680
680
  assert(!getVAddrs(rhs).empty());
681
- getEs().getVAddrs(lhs) = getVAddrs(rhs);
681
+ _es.getVAddrs(lhs) = getVAddrs(rhs);
682
682
  }
683
683
  }
684
684
  }
@@ -738,7 +738,7 @@ void SVFIR2ItvExeState::translateSelect(const SelectStmt *select)
738
738
  {
739
739
  assert(!getVAddrs(fval).empty());
740
740
  assert(!getVAddrs(tval).empty());
741
- getEs().getVAddrs(res) = _es[cond].is_zero() ? getVAddrs(fval) : getVAddrs(tval);
741
+ _es.getVAddrs(res) = _es[cond].is_zero() ? getVAddrs(fval) : getVAddrs(tval);
742
742
  }
743
743
  }
744
744
  }
@@ -767,11 +767,11 @@ void SVFIR2ItvExeState::translatePhi(const PhiStmt *phi)
767
767
  const VAddrs &cur = getVAddrs(curId);
768
768
  if (!inVarToAddrsTable(res))
769
769
  {
770
- getEs().getVAddrs(res) = cur;
770
+ _es.getVAddrs(res) = cur;
771
771
  }
772
772
  else
773
773
  {
774
- getVAddrs(res).join_with(cur);
774
+ _es.getVAddrs(res).join_with(cur);
775
775
  }
776
776
  }
777
777
  }
@@ -789,7 +789,7 @@ void SVFIR2ItvExeState::translateCall(const CallPE *callPE)
789
789
  else if (inVarToAddrsTable(rhs))
790
790
  {
791
791
  assert(!getVAddrs(rhs).empty());
792
- getEs().getVAddrs(lhs) = getVAddrs(rhs);
792
+ _es.getVAddrs(lhs) = getVAddrs(rhs);
793
793
  }
794
794
  }
795
795
 
@@ -804,6 +804,6 @@ void SVFIR2ItvExeState::translateRet(const RetPE *retPE)
804
804
  else if (inVarToAddrsTable(rhs))
805
805
  {
806
806
  assert(!getVAddrs(rhs).empty());
807
- getEs().getVAddrs(lhs) = getVAddrs(rhs);
807
+ _es.getVAddrs(lhs) = getVAddrs(rhs);
808
808
  }
809
809
  }