svf-tools 1.0.673 → 1.0.674

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.673",
3
+ "version": "1.0.674",
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": {
@@ -58,7 +58,8 @@ public:
58
58
  NonOverlap, Overlap, Subset, Superset, Same
59
59
  };
60
60
 
61
- typedef std::vector<const SVFVar*> OffsetVarVec;
61
+ typedef std::pair<const SVFVar*, const SVFType*> VarAndGepTypePair;
62
+ typedef std::vector<VarAndGepTypePair> OffsetVarAndGepTypePairs;
62
63
 
63
64
  /// Constructor
64
65
  LocationSet(s32_t o = 0) : fldIdx(o)
@@ -66,7 +67,7 @@ public:
66
67
 
67
68
  /// Copy Constructor
68
69
  LocationSet(const LocationSet& ls)
69
- : fldIdx(ls.fldIdx), offsetVars(ls.getOffsetVarVec())
70
+ : fldIdx(ls.fldIdx), offsetVarAndGepTypePairs(ls.getOffsetVarAndGepTypePairVec())
70
71
  {
71
72
  }
72
73
 
@@ -79,13 +80,13 @@ public:
79
80
  inline const LocationSet& operator= (const LocationSet& rhs)
80
81
  {
81
82
  fldIdx = rhs.fldIdx;
82
- offsetVars = rhs.getOffsetVarVec();
83
+ offsetVarAndGepTypePairs = rhs.getOffsetVarAndGepTypePairVec();
83
84
  return *this;
84
85
  }
85
86
  inline bool operator==(const LocationSet& rhs) const
86
87
  {
87
88
  return this->fldIdx == rhs.fldIdx
88
- && this->offsetVars == rhs.offsetVars;
89
+ && this->offsetVarAndGepTypePairs == rhs.offsetVarAndGepTypePairs;
89
90
  }
90
91
  //@}
91
92
 
@@ -99,9 +100,9 @@ public:
99
100
  {
100
101
  fldIdx = idx;
101
102
  }
102
- inline const OffsetVarVec& getOffsetVarVec() const
103
+ inline const OffsetVarAndGepTypePairs& getOffsetVarAndGepTypePairVec() const
103
104
  {
104
- return offsetVars;
105
+ return offsetVarAndGepTypePairs;
105
106
  }
106
107
  //@}
107
108
 
@@ -112,7 +113,7 @@ public:
112
113
  u32_t getElementNum(const SVFType* type) const;
113
114
 
114
115
 
115
- bool addOffsetVar(const SVFVar* var);
116
+ bool addOffsetVarAndGepTypePair(const SVFVar* var, const SVFType* gepIterType);
116
117
 
117
118
  /// Return TRUE if this is a constant location set.
118
119
  bool isConstantOffset() const;
@@ -135,7 +136,7 @@ private:
135
136
  NodeBS computeAllLocations() const;
136
137
 
137
138
  s32_t fldIdx; ///< Accumulated Constant Offsets
138
- OffsetVarVec offsetVars; ///< a vector of actual offset in the form of SVF Vars
139
+ OffsetVarAndGepTypePairs offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
139
140
  };
140
141
 
141
142
  } // End namespace SVF
@@ -145,8 +146,8 @@ template <> struct std::hash<SVF::LocationSet>
145
146
  size_t operator()(const SVF::LocationSet &ls) const
146
147
  {
147
148
  SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
148
- std::hash<SVF::LocationSet::OffsetVarVec> v;
149
- return h(std::make_pair(ls.accumulateConstantFieldIdx(), v(ls.getOffsetVarVec())));
149
+ std::hash<SVF::LocationSet::OffsetVarAndGepTypePairs> v;
150
+ return h(std::make_pair(ls.accumulateConstantFieldIdx(), v(ls.getOffsetVarAndGepTypePairVec())));
150
151
  }
151
152
  };
152
153
 
@@ -444,9 +444,9 @@ public:
444
444
  {
445
445
  return ls;
446
446
  }
447
- inline const LocationSet::OffsetVarVec getOffsetVarVec() const
447
+ inline const LocationSet::OffsetVarAndGepTypePairs getOffsetVarAndGepTypePairVec() const
448
448
  {
449
- return getLocationSet().getOffsetVarVec();
449
+ return getLocationSet().getOffsetVarAndGepTypePairVec();
450
450
  }
451
451
  /// Return TRUE if this is a constant location set.
452
452
  inline bool isConstantOffset() const
@@ -104,15 +104,15 @@ SVFIR2ItvExeState::VAddrs SVFIR2ItvExeState::getGepObjAddress(u32_t pointer, u32
104
104
 
105
105
  std::pair<s32_t, s32_t> SVFIR2ItvExeState::getGepOffset(const GepStmt *gep)
106
106
  {
107
- if (gep->getOffsetVarVec().empty())
107
+ if (gep->getOffsetVarAndGepTypePairVec().empty())
108
108
  return std::make_pair(gep->getConstantFieldIdx(), gep->getConstantFieldIdx());
109
109
 
110
110
  s32_t totalOffsetLb = 0;
111
111
  s32_t totalOffsetUb = 0;
112
- for (int i = gep->getOffsetVarVec().size() - 1; i >= 0; i--)
112
+ for (int i = gep->getOffsetVarAndGepTypePairVec().size() - 1; i >= 0; i--)
113
113
  {
114
- const SVFValue *value = gep->getOffsetVarVec()[i]->getValue();
115
- const SVFType *type = gep->getOffsetVarVec()[i]->getType();
114
+ const SVFValue *value = gep->getOffsetVarAndGepTypePairVec()[i].first->getValue();
115
+ const SVFType *type = gep->getOffsetVarAndGepTypePairVec()[i].second;
116
116
  const SVFConstantInt *op = SVFUtil::dyn_cast<SVFConstantInt>(value);
117
117
  s32_t offsetLb = 0;
118
118
  s32_t offsetUb = 0;
@@ -757,11 +757,11 @@ void VFG::connectDirectVFGEdges()
757
757
  addIntraDirectVFEdge(getDef(stmtNode->getPAGSrcNode()), nodeId);
758
758
  if (const GepStmt* gepStmt = SVFUtil::dyn_cast<GepStmt>(stmtNode->getPAGEdge()))
759
759
  {
760
- for (const auto &var: gepStmt->getOffsetVarVec())
760
+ for (const auto &varType: gepStmt->getOffsetVarAndGepTypePairVec())
761
761
  {
762
- if(var->isConstDataOrAggDataButNotNullPtr() || isInterestedPAGNode(var) == false)
762
+ if(varType.first->isConstDataOrAggDataButNotNullPtr() || isInterestedPAGNode(varType.first) == false)
763
763
  continue;
764
- addIntraDirectVFEdge(getDef(var), nodeId);
764
+ addIntraDirectVFEdge(getDef(varType.first), nodeId);
765
765
  }
766
766
  }
767
767
  /// for store, connect the RHS/LHS pointer to its def
@@ -37,20 +37,20 @@ using namespace SVF;
37
37
  using namespace SVFUtil;
38
38
 
39
39
  /*!
40
- * Add offset value to vector offsetVars
40
+ * Add offset value to vector offsetVarAndGepTypePairs
41
41
  */
42
- bool LocationSet::addOffsetVar(const SVFVar* var)
42
+ bool LocationSet::addOffsetVarAndGepTypePair(const SVFVar* var, const SVFType* gepIterType)
43
43
  {
44
- offsetVars.push_back(var);
44
+ offsetVarAndGepTypePairs.emplace_back(var, gepIterType);
45
45
  return true;
46
46
  }
47
47
 
48
48
  /// Return true if all offset values are constants
49
49
  bool LocationSet::isConstantOffset() const
50
50
  {
51
- for(auto it : offsetVars)
51
+ for(auto it : offsetVarAndGepTypePairs)
52
52
  {
53
- if(SVFUtil::isa<SVFConstantInt>(it->getValue()) == false)
53
+ if(SVFUtil::isa<SVFConstantInt>(it.first->getValue()) == false)
54
54
  return false;
55
55
  }
56
56
  return true;
@@ -120,14 +120,14 @@ s32_t LocationSet::accumulateConstantOffset() const
120
120
 
121
121
  assert(isConstantOffset() && "not a constant offset");
122
122
 
123
- if(offsetVars.empty())
123
+ if(offsetVarAndGepTypePairs.empty())
124
124
  return accumulateConstantFieldIdx();
125
125
 
126
126
  s32_t totalConstOffset = 0;
127
- for(int i = offsetVars.size() - 1; i >= 0; i--)
127
+ for(int i = offsetVarAndGepTypePairs.size() - 1; i >= 0; i--)
128
128
  {
129
- const SVFValue* value = offsetVars[i]->getValue();
130
- const SVFType* type = offsetVars[i]->getType();
129
+ const SVFValue* value = offsetVarAndGepTypePairs[i].first->getValue();
130
+ const SVFType* type = offsetVarAndGepTypePairs[i].second;
131
131
  const SVFConstantInt* op = SVFUtil::dyn_cast<SVFConstantInt>(value);
132
132
  assert(op && "not a constant offset?");
133
133
  if(type==nullptr)
@@ -161,10 +161,10 @@ LocationSet LocationSet::operator+ (const LocationSet& rhs) const
161
161
  {
162
162
  LocationSet ls(rhs);
163
163
  ls.fldIdx += accumulateConstantFieldIdx();
164
- OffsetVarVec::const_iterator it = getOffsetVarVec().begin();
165
- OffsetVarVec::const_iterator eit = getOffsetVarVec().end();
164
+ OffsetVarAndGepTypePairs::const_iterator it = getOffsetVarAndGepTypePairVec().begin();
165
+ OffsetVarAndGepTypePairs::const_iterator eit = getOffsetVarAndGepTypePairVec().end();
166
166
  for (; it != eit; ++it)
167
- ls.addOffsetVar(*it);
167
+ ls.addOffsetVarAndGepTypePair(it->first, it->second);
168
168
 
169
169
  return ls;
170
170
  }
@@ -176,14 +176,14 @@ bool LocationSet::operator< (const LocationSet& rhs) const
176
176
  return (fldIdx < rhs.fldIdx);
177
177
  else
178
178
  {
179
- const OffsetVarVec& pairVec = getOffsetVarVec();
180
- const OffsetVarVec& rhsPairVec = rhs.getOffsetVarVec();
179
+ const OffsetVarAndGepTypePairs& pairVec = getOffsetVarAndGepTypePairVec();
180
+ const OffsetVarAndGepTypePairs& rhsPairVec = rhs.getOffsetVarAndGepTypePairVec();
181
181
  if (pairVec.size() != rhsPairVec.size())
182
182
  return (pairVec.size() < rhsPairVec.size());
183
183
  else
184
184
  {
185
- OffsetVarVec::const_iterator it = pairVec.begin();
186
- OffsetVarVec::const_iterator rhsIt = rhsPairVec.begin();
185
+ OffsetVarAndGepTypePairs::const_iterator it = pairVec.begin();
186
+ OffsetVarAndGepTypePairs::const_iterator rhsIt = rhsPairVec.begin();
187
187
  for (; it != pairVec.end() && rhsIt != rhsPairVec.end(); ++it, ++rhsIt)
188
188
  {
189
189
  return (*it) < (*rhsIt);
@@ -223,12 +223,12 @@ std::string LocationSet::dump() const
223
223
 
224
224
  rawstr << "LocationSet\tField_Index: " << accumulateConstantFieldIdx();
225
225
  rawstr << ",\tNum-Stride: {";
226
- const OffsetVarVec& vec = getOffsetVarVec();
227
- OffsetVarVec::const_iterator it = vec.begin();
228
- OffsetVarVec::const_iterator eit = vec.end();
226
+ const OffsetVarAndGepTypePairs& vec = getOffsetVarAndGepTypePairVec();
227
+ OffsetVarAndGepTypePairs::const_iterator it = vec.begin();
228
+ OffsetVarAndGepTypePairs::const_iterator eit = vec.end();
229
229
  for (; it != eit; ++it)
230
230
  {
231
- rawstr << " (var: " << (*it)->toString() << ")";
231
+ rawstr << " (Svf var: " << it->first->toString() << ", Iter type: " << it->second->toString() << ")";
232
232
  }
233
233
  rawstr << " }\n";
234
234
  return rawstr.str();
@@ -276,9 +276,11 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
276
276
  gi != ge; ++gi)
277
277
  {
278
278
  const Type* gepTy = *gi;
279
+ const SVFType* svfGepTy = LLVMModuleSet::getLLVMModuleSet()->getSVFType(gepTy);
279
280
  const Value* offsetVal = gi.getOperand();
280
281
  const SVFValue* offsetSvfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(offsetVal);
281
- ls.addOffsetVar(getPAG()->getGNode(getPAG()->getValueNode(offsetSvfVal)));
282
+ assert(gepTy != offsetVal->getType() && "iteration and operand have the same type?");
283
+ ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(offsetSvfVal)), svfGepTy);
282
284
 
283
285
  //The int value of the current index operand
284
286
  const ConstantInt* op = SVFUtil::dyn_cast<ConstantInt>(offsetVal);
@@ -1132,7 +1134,7 @@ const Type* SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value* V, std::vec
1132
1134
  builder.collectSym(offset);
1133
1135
  pag->addValNode(svfOffset, pag->getSymbolInfo()->getValSym(svfOffset));
1134
1136
  }
1135
- ls.addOffsetVar(getPAG()->getGNode(getPAG()->getValueNode(svfOffset)));
1137
+ ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(svfOffset)), nullptr);
1136
1138
  fields.push_back(ls);
1137
1139
  }
1138
1140
  return T;