svf-lib 1.0.726 → 1.0.727

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
@@ -0,0 +1,102 @@
1
+ //===- LocMemModel.h -- Memory model builder-----------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * MemModelBuilder.h
25
+ *
26
+ * Created on: Apr 28, 2014
27
+ * Author: Yulei
28
+ */
29
+
30
+ #ifndef MEMMODELBUILDER_H_
31
+ #define MEMMODELBUILDER_H_
32
+
33
+ #include "MemoryModel/MemModel.h"
34
+ #include "SVF-FE/LLVMModule.h"
35
+ #include "SVF-FE/SymbolTableInfo.h"
36
+
37
+ /*
38
+ * This class is to build SymbolTableInfo, MemObjs and ObjTypeInfo
39
+ */
40
+ namespace SVF
41
+ {
42
+
43
+ class MemModelBuilder
44
+ {
45
+
46
+ private:
47
+ SymbolTableInfo* symInfo;
48
+
49
+ public:
50
+ /// Constructor
51
+ MemModelBuilder(SymbolTableInfo* si): symInfo(si){
52
+
53
+ }
54
+
55
+ /// Start building memory model
56
+ void buildMemModel(SVFModule* svfModule);
57
+
58
+ /// collect the syms
59
+ //@{
60
+ void collectSym(const Value *val);
61
+
62
+ void collectVal(const Value *val);
63
+
64
+ void collectObj(const Value *val);
65
+
66
+ void collectRet(const Function *val);
67
+
68
+ void collectVararg(const Function *val);
69
+ //@}
70
+
71
+ /// Handle constant expression
72
+ // @{
73
+ void handleGlobalCE(const GlobalVariable *G);
74
+ void handleGlobalInitializerCE(const Constant *C, u32_t offset);
75
+ void handleCE(const Value *val);
76
+ // @}
77
+
78
+
79
+ // /// Collect the struct info
80
+ // virtual void collectStructInfo(const StructType *T);
81
+ // /// Collect the array info
82
+ // virtual void collectArrayInfo(const ArrayType* T);
83
+ // /// Collect simple type (non-aggregate) info
84
+ // virtual void collectSimpleTypeInfo(const Type* T);
85
+
86
+ /// Create an objectInfo based on LLVM value
87
+ ObjTypeInfo* createObjTypeInfo(const Value *val);
88
+ /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
89
+ // ObjTypeInfo* createObjTypeInfo(const Type *type = nullptr);
90
+
91
+ /// Initialize TypeInfo based on LLVM Value
92
+ void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value);
93
+ /// Analyse types of all flattened fields of this object
94
+ void analyzeGlobalStackObjType(ObjTypeInfo* typeinfo, const Value* val);
95
+ /// Return size of this object based on LLVM value
96
+ u32_t getObjSize(const Value* val);
97
+
98
+ };
99
+
100
+ }
101
+
102
+ #endif /* MEMMODELBUILDER_H_ */
@@ -42,6 +42,8 @@ namespace SVF
42
42
  class SymbolTableInfo
43
43
  {
44
44
 
45
+ friend class MemModelBuilder;
46
+
45
47
  public:
46
48
  /// various maps defined
47
49
  //{@
@@ -142,6 +144,11 @@ public:
142
144
  {
143
145
  return mod;
144
146
  }
147
+ /// Module
148
+ inline void setModule(SVFModule* m)
149
+ {
150
+ mod = m;
151
+ }
145
152
 
146
153
  /// Get target machine data layout
147
154
  inline static DataLayout* getDataLayout(Module* mod)
@@ -157,22 +164,6 @@ public:
157
164
  u32_t getTypeSizeInBytes(const StructType *sty, u32_t field_index);
158
165
  //@}
159
166
 
160
- /// Start building memory model
161
- void buildMemModel(SVFModule* svfModule);
162
-
163
- /// collect the syms
164
- //@{
165
- void collectSym(const Value *val);
166
-
167
- void collectVal(const Value *val);
168
-
169
- void collectObj(const Value *val);
170
-
171
- void collectRet(const Function *val);
172
-
173
- void collectVararg(const Function *val);
174
- //@}
175
-
176
167
  /// special value
177
168
  // @{
178
169
  static bool isNullPtrSym(const Value *val);
@@ -248,13 +239,6 @@ public:
248
239
  }
249
240
  // @}
250
241
 
251
- /// Handle constant expression
252
- // @{
253
- void handleGlobalCE(const GlobalVariable *G);
254
- void handleGlobalInitializerCE(const Constant *C, u32_t offset);
255
- void handleCE(const Value *val);
256
- // @}
257
-
258
242
  /// Get different kinds of syms
259
243
  //@{
260
244
  SymID getValSym(const Value *val)
@@ -433,18 +417,9 @@ protected:
433
417
  /// Collect simple type (non-aggregate) info
434
418
  virtual void collectSimpleTypeInfo(const Type* T);
435
419
 
436
- /// Create an objectInfo based on LLVM value
437
- ObjTypeInfo* createObjTypeInfo(const Value *val);
438
420
  /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
439
421
  ObjTypeInfo* createObjTypeInfo(const Type *type = nullptr);
440
422
 
441
- /// Initialize TypeInfo based on LLVM Value
442
- void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value);
443
- /// Analyse types of all flattened fields of this object
444
- void analyzeGlobalStackObjType(ObjTypeInfo* typeinfo, const Value* val);
445
- /// Return size of this object based on LLVM value
446
- u32_t getObjSize(const Value* val);
447
-
448
423
  /// Every type T is mapped to StInfo
449
424
  /// which contains size (fsize) , offset(foffset)
450
425
  /// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
@@ -68,7 +68,7 @@ public:
68
68
  NodeID allocateValueId(void);
69
69
 
70
70
  /// Notify the allocator that all symbols have had IDs allocated.
71
- void endSymbolAllocation(void);
71
+ NodeID endSymbolAllocation(void);
72
72
 
73
73
  /// Returns the total number of memory objects.
74
74
  NodeID getNumObjects(void) const { return numObjects; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.726",
3
+ "version": "1.0.727",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {