svf-tools 1.0.733 → 1.0.735

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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/svf/include/AbstractExecution/SVFIR2ConsExeState.h +1 -1
  3. package/svf/include/AbstractExecution/SVFIR2ItvExeState.h +1 -1
  4. package/svf/include/Graphs/ConsG.h +4 -4
  5. package/svf/include/Graphs/ConsGEdge.h +10 -8
  6. package/svf/include/MemoryModel/{LocationSet.h → AccessPath.h} +26 -25
  7. package/svf/include/MemoryModel/PointerAnalysis.h +2 -2
  8. package/svf/include/SVFIR/PAGBuilderFromFile.h +1 -1
  9. package/svf/include/SVFIR/SVFFileSystem.h +3 -3
  10. package/svf/include/SVFIR/SVFIR.h +16 -15
  11. package/svf/include/SVFIR/SVFStatements.h +14 -14
  12. package/svf/include/SVFIR/SVFType.h +1 -0
  13. package/svf/include/SVFIR/SVFVariables.h +13 -19
  14. package/svf/include/SVFIR/SymbolTableInfo.h +5 -4
  15. package/svf/include/Util/Options.h +1 -1
  16. package/svf/include/Util/Z3Expr.h +2 -2
  17. package/svf/include/WPA/AndersenPWC.h +1 -1
  18. package/svf/lib/AbstractExecution/SVFIR2ConsExeState.cpp +2 -2
  19. package/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp +3 -3
  20. package/svf/lib/DDA/ContextDDA.cpp +1 -1
  21. package/svf/lib/DDA/FlowDDA.cpp +1 -1
  22. package/svf/lib/Graphs/ConsG.cpp +8 -7
  23. package/svf/lib/MemoryModel/{LocationSet.cpp → AccessPath.cpp} +20 -23
  24. package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +4 -4
  25. package/svf/lib/SVFIR/PAGBuilderFromFile.cpp +4 -4
  26. package/svf/lib/SVFIR/SVFFileSystem.cpp +14 -14
  27. package/svf/lib/SVFIR/SVFIR.cpp +29 -28
  28. package/svf/lib/SVFIR/SVFVariables.cpp +1 -1
  29. package/svf/lib/SVFIR/SymbolTableInfo.cpp +8 -8
  30. package/svf/lib/Util/Options.cpp +1 -1
  31. package/svf/lib/Util/Z3Expr.cpp +2 -2
  32. package/svf/lib/WPA/Andersen.cpp +4 -4
  33. package/svf/lib/WPA/AndersenSFR.cpp +7 -7
  34. package/svf/lib/WPA/FlowSensitive.cpp +1 -1
  35. package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +17 -17
  36. package/svf-llvm/lib/SVFIRBuilder.cpp +30 -30
  37. package/svf-llvm/lib/SVFIRExtAPI.cpp +9 -9
  38. package/svf-llvm/tools/MTA/LockResultValidator.cpp +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.733",
3
+ "version": "1.0.735",
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": {
@@ -89,7 +89,7 @@ public:
89
89
  //%}
90
90
 
91
91
  /// Return the expr of gep object given a base and offset
92
- VAddrs getGepObjAddress(u32_t base, u32_t offset);
92
+ VAddrs getGepObjAddress(u32_t base, s32_t offset);
93
93
 
94
94
  /// Return the offset expression of a GepStmt
95
95
  std::pair<s32_t, s32_t> getGepOffset(const GepStmt *gep);
@@ -71,7 +71,7 @@ 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, u32_t offset);
74
+ VAddrs getGepObjAddress(u32_t pointer, s32_t offset);
75
75
 
76
76
  /// Return the offset expression of a GepStmt
77
77
  std::pair<s32_t, s32_t> getGepOffset(const GepStmt *gep);
@@ -52,7 +52,7 @@ public:
52
52
  typedef FIFOWorkList<NodeID> WorkList;
53
53
 
54
54
  protected:
55
- SVFIR*pag;
55
+ SVFIR* pag;
56
56
  NodeToRepMap nodeToRepMap;
57
57
  NodeToSubsMap nodeToSubsMap;
58
58
  WorkList nodesToBeCollapsed;
@@ -180,7 +180,7 @@ public:
180
180
  /// Add Copy edge
181
181
  CopyCGEdge* addCopyCGEdge(NodeID src, NodeID dst);
182
182
  /// Add Gep edge
183
- NormalGepCGEdge* addNormalGepCGEdge(NodeID src, NodeID dst, const LocationSet& ls);
183
+ NormalGepCGEdge* addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath& ap);
184
184
  VariantGepCGEdge* addVariantGepCGEdge(NodeID src, NodeID dst);
185
185
  /// Add Load edge
186
186
  LoadCGEdge* addLoadCGEdge(NodeID src, NodeID dst);
@@ -325,9 +325,9 @@ public:
325
325
  return (mem->getMaxFieldOffsetLimit() == 1);
326
326
  }
327
327
  /// Get a field of a memory object
328
- inline NodeID getGepObjVar(NodeID id, const LocationSet& ls)
328
+ inline NodeID getGepObjVar(NodeID id, const APOffset& apOffset)
329
329
  {
330
- NodeID gep = pag->getGepObjVar(id,ls);
330
+ NodeID gep = pag->getGepObjVar(id, apOffset);
331
331
  /// Create a node when it is (1) not exist on graph and (2) not merged
332
332
  if(sccRepNode(gep)==gep && hasConstraintNode(gep)==false)
333
333
  addConstraintNode(new ConstraintNode(gep),gep);
@@ -269,7 +269,7 @@ private:
269
269
  NormalGepCGEdge(const NormalGepCGEdge &); ///< place holder
270
270
  void operator=(const NormalGepCGEdge &); ///< place holder
271
271
 
272
- LocationSet ls; ///< location set of the gep edge
272
+ AccessPath ap; ///< Access path of the gep edge
273
273
 
274
274
  public:
275
275
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -293,20 +293,22 @@ public:
293
293
  //@}
294
294
 
295
295
  /// Constructor
296
- NormalGepCGEdge(ConstraintNode* s, ConstraintNode* d, const LocationSet& l, EdgeID id)
297
- : GepCGEdge(s,d,NormalGep,id), ls(l)
298
- {}
296
+ NormalGepCGEdge(ConstraintNode* s, ConstraintNode* d, const AccessPath& ap,
297
+ EdgeID id)
298
+ : GepCGEdge(s, d, NormalGep, id), ap(ap)
299
+ {
300
+ }
299
301
 
300
302
  /// Get location set of the gep edge
301
- inline const LocationSet& getLocationSet() const
303
+ inline const AccessPath& getAccessPath() const
302
304
  {
303
- return ls;
305
+ return ap;
304
306
  }
305
307
 
306
308
  /// Get location set of the gep edge
307
- inline s32_t getConstantFieldIdx() const
309
+ inline APOffset getConstantFieldIdx() const
308
310
  {
309
- return ls.getConstantFieldIdx();
311
+ return ap.getConstantFieldIdx();
310
312
  }
311
313
 
312
314
  };
@@ -1,4 +1,4 @@
1
- //===- LocationSet.h -- Location set of abstract object-----------------------//
1
+ //===- AccessPath.h -- Location set of abstract object-----------------------//
2
2
  //
3
3
  // SVF: Static Value-Flow Analysis
4
4
  //
@@ -21,7 +21,7 @@
21
21
  //===----------------------------------------------------------------------===//
22
22
 
23
23
  /*
24
- * @file: LocationSet.h
24
+ * @file: AccessPath.h
25
25
  * @author: yesen
26
26
  * @date: 26 Sep 2014
27
27
  *
@@ -30,8 +30,8 @@
30
30
  */
31
31
 
32
32
 
33
- #ifndef LOCATIONSET_H_
34
- #define LOCATIONSET_H_
33
+ #ifndef AccessPath_H_
34
+ #define AccessPath_H_
35
35
 
36
36
 
37
37
  #include "SVFIR/SVFValue.h"
@@ -49,7 +49,7 @@ class SVFVar;
49
49
  * where N is the size of number-stride pair vector, M_i (stride_i) is i-th number (stride)
50
50
  * in the number-stride pair vector.
51
51
  */
52
- class LocationSet
52
+ class AccessPath
53
53
  {
54
54
  friend class SymbolTableInfo;
55
55
  friend class SVFIRWriter;
@@ -65,28 +65,28 @@ public:
65
65
  typedef std::vector<VarAndGepTypePair> OffsetVarAndGepTypePairs;
66
66
 
67
67
  /// Constructor
68
- LocationSet(s32_t o = 0) : fldIdx(o) {}
68
+ AccessPath(APOffset o = 0) : fldIdx(o) {}
69
69
 
70
70
  /// Copy Constructor
71
- LocationSet(const LocationSet& ls)
72
- : fldIdx(ls.fldIdx),
73
- offsetVarAndGepTypePairs(ls.getOffsetVarAndGepTypePairVec())
71
+ AccessPath(const AccessPath& ap)
72
+ : fldIdx(ap.fldIdx),
73
+ offsetVarAndGepTypePairs(ap.getOffsetVarAndGepTypePairVec())
74
74
  {
75
75
  }
76
76
 
77
- ~LocationSet() {}
77
+ ~AccessPath() {}
78
78
 
79
79
  /// Overload operators
80
80
  //@{
81
- LocationSet operator+(const LocationSet& rhs) const;
82
- bool operator<(const LocationSet& rhs) const;
83
- inline const LocationSet& operator=(const LocationSet& rhs)
81
+ AccessPath operator+(const AccessPath& rhs) const;
82
+ bool operator<(const AccessPath& rhs) const;
83
+ inline const AccessPath& operator=(const AccessPath& rhs)
84
84
  {
85
85
  fldIdx = rhs.fldIdx;
86
86
  offsetVarAndGepTypePairs = rhs.getOffsetVarAndGepTypePairVec();
87
87
  return *this;
88
88
  }
89
- inline bool operator==(const LocationSet& rhs) const
89
+ inline bool operator==(const AccessPath& rhs) const
90
90
  {
91
91
  return this->fldIdx == rhs.fldIdx &&
92
92
  this->offsetVarAndGepTypePairs == rhs.offsetVarAndGepTypePairs;
@@ -95,11 +95,11 @@ public:
95
95
 
96
96
  /// Get methods
97
97
  //@{
98
- inline s32_t getConstantFieldIdx() const
98
+ inline APOffset getConstantFieldIdx() const
99
99
  {
100
100
  return fldIdx;
101
101
  }
102
- inline void setFldIdx(s32_t idx)
102
+ inline void setFldIdx(APOffset idx)
103
103
  {
104
104
  fldIdx = idx;
105
105
  }
@@ -110,7 +110,7 @@ public:
110
110
  //@}
111
111
 
112
112
  /// Return accumulated constant offset given OffsetVarVec
113
- s32_t computeConstantOffset() const;
113
+ APOffset computeConstantOffset() const;
114
114
 
115
115
  /// Return element number of a type.
116
116
  u32_t getElementNum(const SVFType* type) const;
@@ -122,7 +122,7 @@ public:
122
122
  bool isConstantOffset() const;
123
123
 
124
124
  /// Return TRUE if we share any location in common with RHS
125
- inline bool intersects(const LocationSet& RHS) const
125
+ inline bool intersects(const AccessPath& RHS) const
126
126
  {
127
127
  return computeAllLocations().intersects(RHS.computeAllLocations());
128
128
  }
@@ -133,25 +133,26 @@ public:
133
133
  private:
134
134
 
135
135
  /// Check relations of two location sets
136
- LSRelation checkRelation(const LocationSet& LHS, const LocationSet& RHS);
136
+ LSRelation checkRelation(const AccessPath& LHS, const AccessPath& RHS);
137
137
 
138
138
  /// Compute all possible locations according to offset and number-stride pairs.
139
139
  NodeBS computeAllLocations() const;
140
140
 
141
- s32_t fldIdx; ///< Accumulated Constant Offsets
141
+ APOffset fldIdx; ///< Accumulated Constant Offsets
142
142
  OffsetVarAndGepTypePairs offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
143
143
  };
144
144
 
145
145
  } // End namespace SVF
146
146
 
147
- template <> struct std::hash<SVF::LocationSet>
147
+ template <> struct std::hash<SVF::AccessPath>
148
148
  {
149
- size_t operator()(const SVF::LocationSet &ls) const
149
+ size_t operator()(const SVF::AccessPath &ap) const
150
150
  {
151
151
  SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
152
- std::hash<SVF::LocationSet::OffsetVarAndGepTypePairs> v;
153
- return h(std::make_pair(ls.getConstantFieldIdx(), v(ls.getOffsetVarAndGepTypePairVec())));
152
+ std::hash<SVF::AccessPath::OffsetVarAndGepTypePairs> v;
153
+ return h(std::make_pair(ap.getConstantFieldIdx(),
154
+ v(ap.getOffsetVarAndGepTypePairVec())));
154
155
  }
155
156
  };
156
157
 
157
- #endif /* LOCATIONSET_H_ */
158
+ #endif /* AccessPath_H_ */
@@ -338,9 +338,9 @@ public:
338
338
  {
339
339
  return pag->getFIObjVar(id);
340
340
  }
341
- inline NodeID getGepObjVar(NodeID id, const LocationSet& ls)
341
+ inline NodeID getGepObjVar(NodeID id, const APOffset& ap)
342
342
  {
343
- return pag->getGepObjVar(id,ls);
343
+ return pag->getGepObjVar(id, ap);
344
344
  }
345
345
  virtual inline const NodeBS& getAllFieldsObjVars(NodeID id)
346
346
  {
@@ -71,7 +71,7 @@ public:
71
71
  SVFIR* build();
72
72
 
73
73
  // Add edges
74
- void addEdge(NodeID nodeSrc, NodeID nodeDst, s32_t offset,
74
+ void addEdge(NodeID nodeSrc, NodeID nodeDst, APOffset offset,
75
75
  std::string edge);
76
76
  };
77
77
 
@@ -159,7 +159,7 @@ class SymbolTableInfo;
159
159
 
160
160
  class SVFModule;
161
161
 
162
- class LocationSet;
162
+ class AccessPath;
163
163
  class ObjTypeInfo; // Need SVFType
164
164
 
165
165
  class SVFVar;
@@ -422,7 +422,7 @@ private:
422
422
  cJSON* toJson(const CHEdge* edge); // CHGraph Edge
423
423
 
424
424
  cJSON* toJson(const CallSite& cs);
425
- cJSON* toJson(const LocationSet& ls);
425
+ cJSON* toJson(const AccessPath& ap);
426
426
  cJSON* toJson(const SVFLoop* loop);
427
427
  cJSON* toJson(const MemObj* memObj);
428
428
  cJSON* toJson(const ObjTypeInfo* objTypeInfo); // Only owned by MemObj
@@ -1104,7 +1104,7 @@ private:
1104
1104
  void readJson(const cJSON* obj, CHEdge*& edge); // CHGraph Edge
1105
1105
  void readJson(const cJSON* obj, CallSite& cs); // CHGraph's csToClassMap
1106
1106
 
1107
- void readJson(const cJSON* obj, LocationSet& ls);
1107
+ void readJson(const cJSON* obj, AccessPath& ap);
1108
1108
  void readJson(const cJSON* obj, SVFLoop*& loop);
1109
1109
  void readJson(const cJSON* obj, MemObj*& memObj);
1110
1110
  void readJson(const cJSON* obj,
@@ -64,12 +64,12 @@ public:
64
64
  typedef Map<const SVFFunction*,SVFStmtSet> FunToPAGEdgeSetMap;
65
65
  typedef Map<const ICFGNode*,SVFStmtList> ICFGNode2SVFStmtsMap;
66
66
  typedef Map<NodeID, NodeID> NodeToNodeMap;
67
- typedef std::pair<NodeID, s32_t> NodeOffset;
68
- typedef std::pair<NodeID, LocationSet> NodeLocationSet;
67
+ typedef std::pair<NodeID, APOffset> NodeOffset;
68
+ typedef std::pair<NodeID, AccessPath> NodeAccessPath;
69
69
  typedef Map<NodeOffset,NodeID> NodeOffsetMap;
70
- typedef Map<NodeLocationSet,NodeID> NodeLocationSetMap;
71
- typedef Map<const SVFValue*, NodeLocationSetMap> GepValueVarMap;
72
- typedef std::pair<const SVFType*, std::vector<LocationSet>> SVFTypeLocSetsPair;
70
+ typedef Map<NodeAccessPath,NodeID> NodeAccessPathMap;
71
+ typedef Map<const SVFValue*, NodeAccessPathMap> GepValueVarMap;
72
+ typedef std::pair<const SVFType*, std::vector<AccessPath>> SVFTypeLocSetsPair;
73
73
  typedef Map<NodeID, SVFTypeLocSetsPair> TypeLocSetsMap;
74
74
  typedef Map<NodePair,NodeID> NodePairSetMap;
75
75
 
@@ -80,7 +80,7 @@ private:
80
80
  ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap; ///< Map an ICFGNode to its PointerAnalysis related SVFStmts
81
81
  GepValueVarMap GepValObjMap; ///< Map a pair<base,off> to a gep value node id
82
82
  TypeLocSetsMap typeLocSetsMap; ///< Map an arg to its base SVFType* and all its field location sets
83
- NodeLocationSetMap GepObjVarMap; ///< Map a pair<base,off> to a gep obj node id
83
+ NodeOffsetMap GepObjVarMap; ///< Map a pair<base,off> to a gep obj node id
84
84
  MemObjToFieldsMap memToFieldsMap; ///< Map a mem object id to all its fields
85
85
  SVFStmtSet globSVFStmtSet; ///< Global PAGEdges without control flow information
86
86
  PHINodeMap phiNodeMap; ///< A set of phi copy edges
@@ -129,7 +129,7 @@ public:
129
129
  return memToFieldsMap;
130
130
  }
131
131
  /// Return GepObjVarMap
132
- inline NodeLocationSetMap& getGepObjNodeMap()
132
+ inline NodeOffsetMap& getGepObjNodeMap()
133
133
  {
134
134
  return GepObjVarMap;
135
135
  }
@@ -328,7 +328,8 @@ public:
328
328
  //@}
329
329
 
330
330
  /// Due to constaint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.
331
- NodeID getGepValVar(const SVFValue* curInst, NodeID base, const LocationSet& ls) const;
331
+ NodeID getGepValVar(const SVFValue* curInst, NodeID base,
332
+ const AccessPath& ap) const;
332
333
 
333
334
  /// Add/get indirect callsites
334
335
  //@{
@@ -392,9 +393,9 @@ public:
392
393
  //@}
393
394
 
394
395
  /// Get a field SVFIR Object node according to base mem obj and offset
395
- NodeID getGepObjVar(const MemObj* obj, const LocationSet& ls);
396
+ NodeID getGepObjVar(const MemObj* obj, const APOffset& ap);
396
397
  /// Get a field obj SVFIR node according to a mem obj and a given offset
397
- NodeID getGepObjVar(NodeID id, const LocationSet& ls) ;
398
+ NodeID getGepObjVar(NodeID id, const APOffset& ap) ;
398
399
  /// Get a field-insensitive obj SVFIR node according to a mem obj
399
400
  //@{
400
401
  inline NodeID getFIObjVar(const MemObj* obj) const
@@ -557,9 +558,9 @@ private:
557
558
  }
558
559
 
559
560
  /// Add a temp field value node, this method can only invoked by getGepValVar
560
- NodeID addGepValNode(const SVFValue* curInst,const SVFValue* val, const LocationSet& ls, NodeID i, const SVFType* type);
561
+ NodeID addGepValNode(const SVFValue* curInst,const SVFValue* val, const AccessPath& ap, NodeID i, const SVFType* type);
561
562
  /// Add a field obj node, this method can only invoked by getGepObjVar
562
- NodeID addGepObjNode(const MemObj* obj, const LocationSet& ls);
563
+ NodeID addGepObjNode(const MemObj* obj, const APOffset& apOffset);
563
564
  /// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
564
565
  NodeID addFIObjNode(const MemObj* obj);
565
566
  //@}
@@ -665,12 +666,12 @@ private:
665
666
  RetPE* addRetPE(NodeID src, NodeID dst, const CallICFGNode* cs,
666
667
  const FunExitICFGNode* exit);
667
668
  /// Add Gep edge
668
- GepStmt* addGepStmt(NodeID src, NodeID dst, const LocationSet& ls,
669
+ GepStmt* addGepStmt(NodeID src, NodeID dst, const AccessPath& ap,
669
670
  bool constGep);
670
671
  /// Add Offset(Gep) edge
671
- GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
672
+ GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const AccessPath& ap);
672
673
  /// Add Variant(Gep) edge
673
- GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
674
+ GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const AccessPath& ap);
674
675
  /// Add Thread fork edge for parameter passing
675
676
  TDForkPE* addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode* cs,
676
677
  const FunEntryICFGNode* entry);
@@ -32,7 +32,7 @@
32
32
  #define INCLUDE_SVFIR_SVFSTATEMENT_H_
33
33
 
34
34
  #include "Graphs/GenericGraph.h"
35
- #include "MemoryModel/LocationSet.h"
35
+ #include "MemoryModel/AccessPath.h"
36
36
 
37
37
  namespace SVF
38
38
  {
@@ -465,7 +465,7 @@ private:
465
465
  GepStmt(const GepStmt &); ///< place holder
466
466
  void operator=(const GepStmt &); ///< place holder
467
467
 
468
- LocationSet ls; ///< location set of the gep edge
468
+ AccessPath ap; ///< Access path of the GEP edge
469
469
  bool variantField; ///< Gep statement with a variant field index (pointer arithmetic) for struct field access (e.g., p = &(q + f), where f is a variable)
470
470
  public:
471
471
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -484,29 +484,29 @@ public:
484
484
  }
485
485
  //@}
486
486
 
487
- inline const LocationSet& getLocationSet() const
487
+ inline const AccessPath& getAccessPath() const
488
488
  {
489
- return ls;
489
+ return ap;
490
490
  }
491
- inline const LocationSet::OffsetVarAndGepTypePairs getOffsetVarAndGepTypePairVec() const
491
+ inline const AccessPath::OffsetVarAndGepTypePairs getOffsetVarAndGepTypePairVec() const
492
492
  {
493
- return getLocationSet().getOffsetVarAndGepTypePairVec();
493
+ return getAccessPath().getOffsetVarAndGepTypePairVec();
494
494
  }
495
495
  /// Return TRUE if this is a constant location set.
496
496
  inline bool isConstantOffset() const
497
497
  {
498
- return getLocationSet().isConstantOffset();
498
+ return getAccessPath().isConstantOffset();
499
499
  }
500
500
  /// Return accumulated constant offset (when accessing array or struct) if this offset is a constant.
501
- inline s32_t accumulateConstantOffset() const
501
+ inline APOffset accumulateConstantOffset() const
502
502
  {
503
- return getLocationSet().computeConstantOffset();
503
+ return getAccessPath().computeConstantOffset();
504
504
  }
505
505
  /// Field index of the gep statement if it access the field of a struct
506
- inline s32_t getConstantFieldIdx() const
506
+ inline APOffset getConstantFieldIdx() const
507
507
  {
508
- assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
509
- return getLocationSet().getConstantFieldIdx();
508
+ assert(isVariantFieldGep()==false && "Can't retrieve the AccessPath if using a variable field index (pointer arithmetic) for struct field access ");
509
+ return getAccessPath().getConstantFieldIdx();
510
510
  }
511
511
  /// Gep statement with a variant field index (pointer arithmetic) for struct field access
512
512
  inline bool isVariantFieldGep() const
@@ -515,8 +515,8 @@ public:
515
515
  }
516
516
 
517
517
  /// constructor
518
- GepStmt(SVFVar* s, SVFVar* d, const LocationSet& l, bool varfld = false)
519
- : AssignStmt(s, d, SVFStmt::Gep), ls(l), variantField(varfld)
518
+ GepStmt(SVFVar* s, SVFVar* d, const AccessPath& ap, bool varfld = false)
519
+ : AssignStmt(s, d, SVFStmt::Gep), ap(ap), variantField(varfld)
520
520
  {
521
521
  }
522
522
 
@@ -58,6 +58,7 @@ typedef u32_t EdgeID;
58
58
  typedef unsigned SymID;
59
59
  typedef unsigned CallSiteID;
60
60
  typedef unsigned ThreadID;
61
+ typedef s64_t APOffset;
61
62
 
62
63
  typedef SparseBitVector<> NodeBS;
63
64
  typedef unsigned PointsToID;
@@ -383,7 +383,7 @@ class GepValVar: public ValVar
383
383
  friend class SVFIRReader;
384
384
 
385
385
  private:
386
- LocationSet ls; // LocationSet
386
+ AccessPath ap; // AccessPath
387
387
  const SVFType* gepValType;
388
388
 
389
389
  /// Constructor to create empty GeValVar (for SVFIRReader/deserialization)
@@ -411,16 +411,16 @@ public:
411
411
  //@}
412
412
 
413
413
  /// Constructor
414
- GepValVar(const SVFValue* val, NodeID i, const LocationSet& l,
414
+ GepValVar(const SVFValue* val, NodeID i, const AccessPath& ap,
415
415
  const SVFType* ty)
416
- : ValVar(val, i, GepValNode), ls(l), gepValType(ty)
416
+ : ValVar(val, i, GepValNode), ap(ap), gepValType(ty)
417
417
  {
418
418
  }
419
419
 
420
420
  /// offset of the base value variable
421
- inline s32_t getConstantFieldIdx() const
421
+ inline APOffset getConstantFieldIdx() const
422
422
  {
423
- return ls.getConstantFieldIdx();
423
+ return ap.getConstantFieldIdx();
424
424
  }
425
425
 
426
426
  /// Return name of a LLVM value
@@ -451,7 +451,7 @@ class GepObjVar: public ObjVar
451
451
  friend class SVFIRReader;
452
452
 
453
453
  private:
454
- LocationSet ls;
454
+ APOffset apOffset = 0;
455
455
  NodeID base = 0;
456
456
 
457
457
  /// Constructor to create empty GepObjVar (for SVFIRReader/deserialization)
@@ -480,23 +480,17 @@ public:
480
480
  //@}
481
481
 
482
482
  /// Constructor
483
- GepObjVar(const MemObj* mem, NodeID i, const LocationSet& l,
483
+ GepObjVar(const MemObj* mem, NodeID i, const APOffset& apOffset,
484
484
  PNODEK ty = GepObjNode)
485
- : ObjVar(mem->getValue(), i, mem, ty), ls(l)
485
+ : ObjVar(mem->getValue(), i, mem, ty), apOffset(apOffset)
486
486
  {
487
487
  base = mem->getId();
488
488
  }
489
489
 
490
490
  /// offset of the mem object
491
- inline const LocationSet& getLocationSet() const
491
+ inline APOffset getConstantFieldIdx() const
492
492
  {
493
- return ls;
494
- }
495
-
496
- /// offset of the mem object
497
- inline s32_t getConstantFieldIdx() const
498
- {
499
- return ls.getConstantFieldIdx();
493
+ return apOffset;
500
494
  }
501
495
 
502
496
  /// Set the base object from which this GEP node came from.
@@ -514,15 +508,15 @@ public:
514
508
  /// Return the type of this gep object
515
509
  inline virtual const SVFType* getType() const
516
510
  {
517
- return SymbolTableInfo::SymbolInfo()->getFlatternedElemType(mem->getType(), ls.getConstantFieldIdx());
511
+ return SymbolTableInfo::SymbolInfo()->getFlatternedElemType(mem->getType(), apOffset);
518
512
  }
519
513
 
520
514
  /// Return name of a LLVM value
521
515
  inline const std::string getValueName() const
522
516
  {
523
517
  if (value)
524
- return value->getName() + "_" + std::to_string(ls.getConstantFieldIdx());
525
- return "offset_" + std::to_string(ls.getConstantFieldIdx());
518
+ return value->getName() + "_" + std::to_string(apOffset);
519
+ return "offset_" + std::to_string(apOffset);
526
520
  }
527
521
 
528
522
  virtual const std::string toString() const;
@@ -32,7 +32,7 @@
32
32
 
33
33
 
34
34
  #include "Util/SVFUtil.h"
35
- #include "MemoryModel/LocationSet.h"
35
+ #include "MemoryModel/AccessPath.h"
36
36
  #include "SVFIR/SVFModule.h"
37
37
  namespace SVF
38
38
  {
@@ -333,7 +333,8 @@ public:
333
333
  virtual void dump();
334
334
 
335
335
  /// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
336
- virtual LocationSet getModulusOffset(const MemObj* obj, const LocationSet& ls);
336
+ virtual APOffset getModulusOffset(const MemObj* obj,
337
+ const APOffset& apOffset);
337
338
 
338
339
  ///The struct type with the most fields
339
340
  const SVFType* maxStruct;
@@ -453,7 +454,7 @@ public:
453
454
  bool isConstDataOrConstGlobal() const;
454
455
  bool isConstDataOrAggData() const;
455
456
  bool hasPtrObj() const;
456
- bool isNonPtrFieldObj(const LocationSet& ls) const;
457
+ bool isNonPtrFieldObj(const APOffset& apOffset) const;
457
458
  //@}
458
459
 
459
460
  /// Operator overloading
@@ -621,7 +622,7 @@ public:
621
622
  {
622
623
  return hasFlag(HASPTR_OBJ);
623
624
  }
624
- virtual bool isNonPtrFieldObj(const LocationSet& ls);
625
+ virtual bool isNonPtrFieldObj(const APOffset& apOffset);
625
626
  //@}
626
627
  };
627
628
 
@@ -121,7 +121,7 @@ public:
121
121
  // Sparse value-flow graph (VFG.cpp)
122
122
  static const Option<bool> DumpVFG;
123
123
 
124
- // Location set for modeling abstract memory object (LocationSet.cpp)
124
+ // Location set for modeling abstract memory object (AccessPath.cpp)
125
125
  static const Option<bool> SingleStride;
126
126
 
127
127
  // Base class of pointer analyses (PointerAnalysis.cpp)
@@ -261,7 +261,7 @@ public:
261
261
 
262
262
  friend bool eq(const Z3Expr &lhs, const Z3Expr &rhs)
263
263
  {
264
- return eq(lhs.getExpr(), rhs.getExpr());
264
+ return eq(lhs.getExpr().simplify(), rhs.getExpr().simplify());
265
265
  }
266
266
 
267
267
  z3::sort get_sort() const
@@ -293,7 +293,7 @@ public:
293
293
  /// compute NEG
294
294
  static inline Z3Expr NEG(const Z3Expr &z3Expr)
295
295
  {
296
- return !z3Expr;
296
+ return (!z3Expr).simplify();
297
297
  }
298
298
 
299
299
  /// compute AND, used for branch condition
@@ -149,7 +149,7 @@ public:
149
149
  protected:
150
150
  void initialize();
151
151
  void PWCDetect();
152
- void fieldExpand(NodeSet& initials, s32_t offset, NodeBS& strides, PointsTo& expandPts);
152
+ void fieldExpand(NodeSet& initials, APOffset offset, NodeBS& strides, PointsTo& expandPts);
153
153
  bool processGepPts(const PointsTo& pts, const GepCGEdge* edge);
154
154
  bool mergeSrcToTgt(NodeID nodeId, NodeID newRepId);
155
155
 
@@ -579,7 +579,7 @@ void SVFIR2ConsExeState::translatePhi(const PhiStmt *phi)
579
579
  * @param offset
580
580
  * @return
581
581
  */
582
- SVFIR2ConsExeState::VAddrs SVFIR2ConsExeState::getGepObjAddress(u32_t base, u32_t offset)
582
+ SVFIR2ConsExeState::VAddrs SVFIR2ConsExeState::getGepObjAddress(u32_t base, s32_t offset)
583
583
  {
584
584
  const VAddrs &addrs = _es->getVAddrs(base);
585
585
  VAddrs ret;
@@ -655,7 +655,7 @@ std::pair<s32_t, s32_t> SVFIR2ConsExeState::getGepOffset(const SVF::GepStmt *gep
655
655
 
656
656
  if (const SVFPointerType *pty = SVFUtil::dyn_cast<SVFPointerType>(type))
657
657
  {
658
- offset = offset * gep->getLocationSet().getElementNum(pty->getPtrElementType());
658
+ offset = offset * gep->getAccessPath().getElementNum(pty->getPtrElementType());
659
659
  }
660
660
  else
661
661
  {
@@ -152,7 +152,7 @@ void SVFIR2ItvExeState::narrowVAddrs(IntervalExeState &lhs, const IntervalExeSta
152
152
  }
153
153
  }
154
154
 
155
- SVFIR2ItvExeState::VAddrs SVFIR2ItvExeState::getGepObjAddress(u32_t pointer, u32_t offset)
155
+ SVFIR2ItvExeState::VAddrs SVFIR2ItvExeState::getGepObjAddress(u32_t pointer, s32_t offset)
156
156
  {
157
157
  assert(!getVAddrs(pointer).empty());
158
158
  VAddrs &addrs = getVAddrs(pointer);
@@ -242,8 +242,8 @@ std::pair<s32_t, s32_t> SVFIR2ItvExeState::getGepOffset(const GepStmt *gep)
242
242
 
243
243
  if (const SVFPointerType *pty = SVFUtil::dyn_cast<SVFPointerType>(type))
244
244
  {
245
- offsetLb = offsetLb * gep->getLocationSet().getElementNum(pty->getPtrElementType());
246
- offsetUb = offsetUb * gep->getLocationSet().getElementNum(pty->getPtrElementType());
245
+ offsetLb = offsetLb * gep->getAccessPath().getElementNum(pty->getPtrElementType());
246
+ offsetUb = offsetUb * gep->getAccessPath().getElementNum(pty->getPtrElementType());
247
247
 
248
248
  }
249
249
  else