svf-lib 1.0.1490 → 1.0.1492

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.
@@ -92,44 +92,43 @@ template <class T> struct Hash
92
92
 
93
93
  template <typename Key, typename Hash = Hash<Key>,
94
94
  typename KeyEqual = std::equal_to<Key>,
95
- typename Allocator = std::allocator<Key>>
95
+ typename Allocator = std::allocator<Key> >
96
96
  using Set = std::unordered_set<Key, Hash, KeyEqual, Allocator>;
97
97
 
98
98
  template <typename Key, typename Value, typename Hash = Hash<Key>,
99
99
  typename KeyEqual = std::equal_to<Key>,
100
- typename Allocator = std::allocator<std::pair<const Key, Value>>>
101
- using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
102
-
103
- template <typename Key, typename Compare = std::less<Key>,
104
- typename Allocator = std::allocator<Key>>
105
- using OrderedSet = std::set<Key, Compare, Allocator>;
106
-
107
- template <typename Key, typename Value, typename Compare = std::less<Key>,
108
- typename Allocator = std::allocator<std::pair<const Key, Value>>>
109
- using OrderedMap = std::map<Key, Value, Compare, Allocator>;
110
-
111
- typedef std::pair<NodeID, NodeID> NodePair;
112
- typedef OrderedSet<NodeID> OrderedNodeSet;
113
- typedef Set<NodeID> NodeSet;
114
- typedef Set<NodePair> NodePairSet;
115
- typedef Map<NodePair, NodeID> NodePairMap;
116
- typedef std::vector<NodeID> NodeVector;
117
- typedef std::vector<EdgeID> EdgeVector;
118
- typedef std::stack<NodeID> NodeStack;
119
- typedef std::list<NodeID> NodeList;
120
- typedef std::deque<NodeID> NodeDeque;
121
- typedef NodeSet EdgeSet;
122
- typedef std::vector<u32_t> CallStrCxt;
123
- typedef unsigned Version;
124
- typedef Set<Version> VersionSet;
125
- typedef std::pair<NodeID, Version> VersionedVar;
126
- typedef Set<VersionedVar> VersionedVarSet;
127
-
128
- /*!
129
- * Flatterned type information of StructType, ArrayType and
130
- * SingleValueType
131
- */
132
- class StInfo
100
+ typename Allocator = std::allocator<std::pair<const Key, Value> > >
101
+ using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
102
+
103
+ template <typename Key, typename Compare = std::less<Key>,
104
+ typename Allocator = std::allocator<Key> >
105
+ using OrderedSet = std::set<Key, Compare, Allocator>;
106
+
107
+ template <typename Key, typename Value, typename Compare = std::less<Key>,
108
+ typename Allocator = std::allocator<std::pair<const Key, Value> > >
109
+ using OrderedMap = std::map<Key, Value, Compare, Allocator>;
110
+
111
+ typedef std::pair<NodeID, NodeID> NodePair;
112
+ typedef OrderedSet<NodeID> OrderedNodeSet;
113
+ typedef Set<NodeID> NodeSet;
114
+ typedef Set<NodePair> NodePairSet;
115
+ typedef Map<NodePair, NodeID> NodePairMap;
116
+ typedef std::vector<NodeID> NodeVector;
117
+ typedef std::vector<EdgeID> EdgeVector;
118
+ typedef std::stack<NodeID> NodeStack;
119
+ typedef std::list<NodeID> NodeList;
120
+ typedef std::deque<NodeID> NodeDeque;
121
+ typedef NodeSet EdgeSet;
122
+ typedef std::vector<u32_t> CallStrCxt;
123
+ typedef unsigned Version;
124
+ typedef Set<Version> VersionSet;
125
+ typedef std::pair<NodeID, Version> VersionedVar;
126
+ typedef Set<VersionedVar> VersionedVarSet;
127
+
128
+ /*!
129
+ * Flattened type information of StructType, ArrayType and SingleValueType
130
+ */
131
+ class StInfo
133
132
  {
134
133
  friend class SVFModuleWrite;
135
134
  friend class SVFModuleRead;
@@ -329,8 +329,13 @@ public:
329
329
 
330
330
  inline void addTypeInfo(const SVFType* ty)
331
331
  {
332
- assert(!hasSVFTypeInfo(ty) && "this type info has been added before");
333
- svfTypes.insert(ty);
332
+ bool inserted = svfTypes.insert(ty).second;
333
+ assert(inserted && "this type info has been added before");
334
+ }
335
+
336
+ inline void addStInfo(StInfo* stInfo)
337
+ {
338
+ stInfos.insert(stInfo);
334
339
  }
335
340
 
336
341
  protected:
@@ -341,11 +346,15 @@ protected:
341
346
  /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
342
347
  ObjTypeInfo* createObjTypeInfo(const SVFType* type);
343
348
 
349
+ /// (owned) All SVF Types
344
350
  /// Every type T is mapped to StInfo
345
351
  /// which contains size (fsize) , offset(foffset)
346
352
  /// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
347
353
  /// fsize[0] is always the size of the expanded struct.
348
354
  SVFTypeSet svfTypes;
355
+
356
+ /// @brief (owned) All StInfo
357
+ Set<StInfo*> stInfos;
349
358
  };
350
359
 
351
360
 
@@ -84,11 +84,10 @@ private:
84
84
  SVFValue2LLVMValueMap SVFValue2LLVMValue;
85
85
  LLVMType2SVFTypeMap LLVMType2SVFType;
86
86
  Type2TypeInfoMap Type2TypeInfo;
87
- Set<const StInfo*> StInfos;
88
87
 
89
88
  /// Constructor
90
89
  LLVMModuleSet();
91
- ~LLVMModuleSet();
90
+ ~LLVMModuleSet() = default;
92
91
 
93
92
  void build();
94
93
 
@@ -330,8 +329,8 @@ private:
330
329
  SVFType* addSVFTypeInfo(const Type* t);
331
330
  /// Collect a type info
332
331
  StInfo* collectTypeInfo(const Type* ty);
333
- /// Collect the struct info; nf contains the number of fields after flattening
334
- StInfo* collectStructInfo(const StructType *T, u32_t& nf);
332
+ /// Collect the struct info and set the number of fields after flattening
333
+ StInfo* collectStructInfo(const StructType* structTy, u32_t& numFields);
335
334
  /// Collect the array info
336
335
  StInfo* collectArrayInfo(const ArrayType* T);
337
336
  /// Collect simple type (non-aggregate) info
@@ -92,44 +92,43 @@ template <class T> struct Hash
92
92
 
93
93
  template <typename Key, typename Hash = Hash<Key>,
94
94
  typename KeyEqual = std::equal_to<Key>,
95
- typename Allocator = std::allocator<Key>>
95
+ typename Allocator = std::allocator<Key> >
96
96
  using Set = std::unordered_set<Key, Hash, KeyEqual, Allocator>;
97
97
 
98
98
  template <typename Key, typename Value, typename Hash = Hash<Key>,
99
99
  typename KeyEqual = std::equal_to<Key>,
100
- typename Allocator = std::allocator<std::pair<const Key, Value>>>
101
- using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
102
-
103
- template <typename Key, typename Compare = std::less<Key>,
104
- typename Allocator = std::allocator<Key>>
105
- using OrderedSet = std::set<Key, Compare, Allocator>;
106
-
107
- template <typename Key, typename Value, typename Compare = std::less<Key>,
108
- typename Allocator = std::allocator<std::pair<const Key, Value>>>
109
- using OrderedMap = std::map<Key, Value, Compare, Allocator>;
110
-
111
- typedef std::pair<NodeID, NodeID> NodePair;
112
- typedef OrderedSet<NodeID> OrderedNodeSet;
113
- typedef Set<NodeID> NodeSet;
114
- typedef Set<NodePair> NodePairSet;
115
- typedef Map<NodePair, NodeID> NodePairMap;
116
- typedef std::vector<NodeID> NodeVector;
117
- typedef std::vector<EdgeID> EdgeVector;
118
- typedef std::stack<NodeID> NodeStack;
119
- typedef std::list<NodeID> NodeList;
120
- typedef std::deque<NodeID> NodeDeque;
121
- typedef NodeSet EdgeSet;
122
- typedef std::vector<u32_t> CallStrCxt;
123
- typedef unsigned Version;
124
- typedef Set<Version> VersionSet;
125
- typedef std::pair<NodeID, Version> VersionedVar;
126
- typedef Set<VersionedVar> VersionedVarSet;
127
-
128
- /*!
129
- * Flatterned type information of StructType, ArrayType and
130
- * SingleValueType
131
- */
132
- class StInfo
100
+ typename Allocator = std::allocator<std::pair<const Key, Value> > >
101
+ using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
102
+
103
+ template <typename Key, typename Compare = std::less<Key>,
104
+ typename Allocator = std::allocator<Key> >
105
+ using OrderedSet = std::set<Key, Compare, Allocator>;
106
+
107
+ template <typename Key, typename Value, typename Compare = std::less<Key>,
108
+ typename Allocator = std::allocator<std::pair<const Key, Value> > >
109
+ using OrderedMap = std::map<Key, Value, Compare, Allocator>;
110
+
111
+ typedef std::pair<NodeID, NodeID> NodePair;
112
+ typedef OrderedSet<NodeID> OrderedNodeSet;
113
+ typedef Set<NodeID> NodeSet;
114
+ typedef Set<NodePair> NodePairSet;
115
+ typedef Map<NodePair, NodeID> NodePairMap;
116
+ typedef std::vector<NodeID> NodeVector;
117
+ typedef std::vector<EdgeID> EdgeVector;
118
+ typedef std::stack<NodeID> NodeStack;
119
+ typedef std::list<NodeID> NodeList;
120
+ typedef std::deque<NodeID> NodeDeque;
121
+ typedef NodeSet EdgeSet;
122
+ typedef std::vector<u32_t> CallStrCxt;
123
+ typedef unsigned Version;
124
+ typedef Set<Version> VersionSet;
125
+ typedef std::pair<NodeID, Version> VersionedVar;
126
+ typedef Set<VersionedVar> VersionedVarSet;
127
+
128
+ /*!
129
+ * Flattened type information of StructType, ArrayType and SingleValueType
130
+ */
131
+ class StInfo
133
132
  {
134
133
  friend class SVFModuleWrite;
135
134
  friend class SVFModuleRead;
@@ -329,8 +329,13 @@ public:
329
329
 
330
330
  inline void addTypeInfo(const SVFType* ty)
331
331
  {
332
- assert(!hasSVFTypeInfo(ty) && "this type info has been added before");
333
- svfTypes.insert(ty);
332
+ bool inserted = svfTypes.insert(ty).second;
333
+ assert(inserted && "this type info has been added before");
334
+ }
335
+
336
+ inline void addStInfo(StInfo* stInfo)
337
+ {
338
+ stInfos.insert(stInfo);
334
339
  }
335
340
 
336
341
  protected:
@@ -341,11 +346,15 @@ protected:
341
346
  /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
342
347
  ObjTypeInfo* createObjTypeInfo(const SVFType* type);
343
348
 
349
+ /// (owned) All SVF Types
344
350
  /// Every type T is mapped to StInfo
345
351
  /// which contains size (fsize) , offset(foffset)
346
352
  /// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
347
353
  /// fsize[0] is always the size of the expanded struct.
348
354
  SVFTypeSet svfTypes;
355
+
356
+ /// @brief (owned) All StInfo
357
+ Set<StInfo*> stInfos;
349
358
  };
350
359
 
351
360
 
@@ -84,11 +84,10 @@ private:
84
84
  SVFValue2LLVMValueMap SVFValue2LLVMValue;
85
85
  LLVMType2SVFTypeMap LLVMType2SVFType;
86
86
  Type2TypeInfoMap Type2TypeInfo;
87
- Set<const StInfo*> StInfos;
88
87
 
89
88
  /// Constructor
90
89
  LLVMModuleSet();
91
- ~LLVMModuleSet();
90
+ ~LLVMModuleSet() = default;
92
91
 
93
92
  void build();
94
93
 
@@ -330,8 +329,8 @@ private:
330
329
  SVFType* addSVFTypeInfo(const Type* t);
331
330
  /// Collect a type info
332
331
  StInfo* collectTypeInfo(const Type* ty);
333
- /// Collect the struct info; nf contains the number of fields after flattening
334
- StInfo* collectStructInfo(const StructType *T, u32_t& nf);
332
+ /// Collect the struct info and set the number of fields after flattening
333
+ StInfo* collectStructInfo(const StructType* structTy, u32_t& numFields);
335
334
  /// Collect the array info
336
335
  StInfo* collectArrayInfo(const ArrayType* T);
337
336
  /// Collect simple type (non-aggregate) info
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1490",
3
+ "version": "1.0.1492",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {