svf-tools 1.0.1035 → 1.0.1037

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 (36) hide show
  1. package/package.json +1 -1
  2. package/svf/include/Graphs/IRGraph.h +212 -31
  3. package/svf/include/MemoryModel/AccessPath.h +0 -1
  4. package/svf/include/SVFIR/ObjTypeInfo.h +225 -0
  5. package/svf/include/SVFIR/SVFIR.h +18 -20
  6. package/svf/include/SVFIR/SVFVariables.h +5 -10
  7. package/svf/include/Util/GeneralType.h +0 -1
  8. package/svf/include/Util/SVFUtil.h +0 -1
  9. package/svf/lib/AE/Core/AbstractState.cpp +3 -3
  10. package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +1 -1
  11. package/svf/lib/DDA/ContextDDA.cpp +1 -1
  12. package/svf/lib/Graphs/IRGraph.cpp +237 -2
  13. package/svf/lib/MemoryModel/AccessPath.cpp +4 -4
  14. package/svf/lib/MemoryModel/PointerAnalysis.cpp +1 -1
  15. package/svf/lib/SVFIR/PAGBuilderFromFile.cpp +1 -1
  16. package/svf/lib/SVFIR/SVFIR.cpp +1 -1
  17. package/svf/lib/SVFIR/SVFModule.cpp +1 -1
  18. package/svf/lib/SVFIR/SVFStatements.cpp +2 -2
  19. package/svf/lib/SVFIR/SVFVariables.cpp +11 -0
  20. package/svf/lib/Util/SVFStat.cpp +3 -3
  21. package/svf/lib/Util/SVFUtil.cpp +1 -15
  22. package/svf/lib/WPA/AndersenStat.cpp +2 -2
  23. package/svf/lib/WPA/FlowSensitiveStat.cpp +4 -4
  24. package/svf/lib/WPA/VersionedFlowSensitiveStat.cpp +4 -4
  25. package/svf-llvm/include/SVF-LLVM/LLVMModule.h +44 -2
  26. package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +2 -2
  27. package/svf-llvm/include/SVF-LLVM/SymbolTableBuilder.h +9 -5
  28. package/svf-llvm/lib/CHGBuilder.cpp +2 -2
  29. package/svf-llvm/lib/DCHG.cpp +1 -1
  30. package/svf-llvm/lib/LLVMModule.cpp +78 -7
  31. package/svf-llvm/lib/LLVMUtil.cpp +1 -1
  32. package/svf-llvm/lib/SVFIRBuilder.cpp +59 -60
  33. package/svf-llvm/lib/SVFIRExtAPI.cpp +15 -15
  34. package/svf-llvm/lib/SymbolTableBuilder.cpp +65 -68
  35. package/svf/include/SVFIR/SymbolTableInfo.h +0 -545
  36. package/svf/lib/SVFIR/SymbolTableInfo.cpp +0 -392
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1035",
3
+ "version": "1.0.1037",
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": {
@@ -42,6 +42,8 @@ namespace SVF
42
42
  typedef SVFVar PAGNode;
43
43
  typedef SVFStmt PAGEdge;
44
44
 
45
+ class ObjTypeInfo;
46
+
45
47
  /*
46
48
  * Graph representation of SVF IR.
47
49
  * It can be seen as a program assignment graph (PAG).
@@ -50,6 +52,53 @@ class IRGraph : public GenericGraph<SVFVar, SVFStmt>
50
52
  {
51
53
  friend class SVFIRWriter;
52
54
  friend class SVFIRReader;
55
+ friend class SymbolTableBuilder;
56
+
57
+ public:
58
+
59
+ /// Symbol types
60
+ enum SYMTYPE
61
+ {
62
+ NullPtr,
63
+ BlkPtr,
64
+ BlackHole,
65
+ ConstantObj,
66
+ ValSymbol,
67
+ ObjSymbol,
68
+ RetSymbol,
69
+ VarargSymbol
70
+ };
71
+
72
+ /// various maps defined
73
+ //{@
74
+ /// sym id to obj type info map
75
+ typedef OrderedMap<NodeID, ObjTypeInfo*> IDToTypeInfoMapTy;
76
+
77
+ /// function to sym id map
78
+ typedef OrderedMap<const SVFFunction*, NodeID> FunToIDMapTy;
79
+ /// struct type to struct info map
80
+ typedef Set<const SVFType*> SVFTypeSet;
81
+ //@}
82
+
83
+ private:
84
+ FunToIDMapTy returnSymMap; ///< return map
85
+ FunToIDMapTy varargSymMap; ///< vararg map
86
+ IDToTypeInfoMapTy objTypeInfoMap; ///< map a memory sym id to its obj
87
+
88
+ /// (owned) All SVF Types
89
+ /// Every type T is mapped to StInfo
90
+ /// which contains size (fsize) , offset(foffset)
91
+ /// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
92
+ /// fsize[0] is always the size of the expanded struct.
93
+ SVFTypeSet svfTypes;
94
+
95
+ /// @brief (owned) All StInfo
96
+ Set<const StInfo*> stInfos;
97
+
98
+ /// total number of symbols
99
+ NodeID totalSymNum;
100
+
101
+ void destorySymTable();
53
102
 
54
103
  public:
55
104
  typedef Set<const SVFStmt*> SVFStmtSet;
@@ -60,7 +109,8 @@ protected:
60
109
  bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
61
110
  NodeID nodeNumAfterPAGBuild; ///< initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
62
111
  u32_t totalPTAPAGEdge;
63
- SymbolTableInfo* symInfo;
112
+ u32_t valVarNum;
113
+ u32_t objVarNum;
64
114
 
65
115
  /// Add a node into the graph
66
116
  inline NodeID addNode(SVFVar* node)
@@ -86,74 +136,178 @@ protected:
86
136
 
87
137
  public:
88
138
  IRGraph(bool buildFromFile)
89
- : fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
139
+ : totalSymNum(0), fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0), valVarNum(0), objVarNum(0),
140
+ maxStruct(nullptr), maxStSize(0)
90
141
  {
91
- symInfo = SymbolTableInfo::SymbolInfo();
92
142
  }
93
143
 
94
144
  virtual ~IRGraph();
95
145
 
96
- inline SymbolTableInfo* getSymbolInfo() const
97
- {
98
- return symInfo;
99
- }
146
+
100
147
  /// Whether this SVFIR built from a txt file
101
148
  inline bool isBuiltFromFile()
102
149
  {
103
150
  return fromFile;
104
151
  }
105
152
 
106
- /// Get SVFIR Node according to LLVM value
107
- ///getNode - Return the node corresponding to the specified pointer.
108
- inline NodeID getValueNode(const SVFValue* V)
153
+ /// special value
154
+ // @{
155
+ static inline bool isBlkPtr(NodeID id)
109
156
  {
110
- return symInfo->getValSym(V);
157
+ return (id == BlkPtr);
111
158
  }
112
- inline bool hasValueNode(const SVFValue* V)
159
+ static inline bool isNullPtr(NodeID id)
113
160
  {
114
- return symInfo->hasValSym(V);
161
+ return (id == NullPtr);
115
162
  }
116
- /// getObject - Return the obj node id refer to the memory object for the
117
- /// specified global, heap or alloca instruction according to llvm value.
118
- inline NodeID getObjectNode(const SVFValue* V)
163
+ static inline bool isBlkObj(NodeID id)
119
164
  {
120
- return symInfo->getObjSym(V);
165
+ return (id == BlackHole);
121
166
  }
122
- /// GetReturnNode - Return the unique node representing the return value of a function
123
- inline NodeID getReturnNode(const SVFFunction* func) const
167
+ static inline bool isConstantSym(NodeID id)
124
168
  {
125
- return symInfo->getRetSym(func);
169
+ return (id == ConstantObj);
126
170
  }
127
- /// getVarargNode - Return the unique node representing the variadic argument of a variadic function.
128
- inline NodeID getVarargNode(const SVFFunction* func) const
171
+ static inline bool isBlkObjOrConstantObj(NodeID id)
172
+ {
173
+ return (isBlkObj(id) || isConstantSym(id));
174
+ }
175
+
176
+ inline NodeID blkPtrSymID() const
177
+ {
178
+ return BlkPtr;
179
+ }
180
+
181
+ inline NodeID nullPtrSymID() const
182
+ {
183
+ return NullPtr;
184
+ }
185
+
186
+ inline NodeID constantSymID() const
187
+ {
188
+ return ConstantObj;
189
+ }
190
+
191
+ inline NodeID blackholeSymID() const
192
+ {
193
+ return BlackHole;
194
+ }
195
+
196
+ /// Statistics
197
+ //@{
198
+ inline u32_t getTotalSymNum() const
199
+ {
200
+ return totalSymNum;
201
+ }
202
+ inline u32_t getMaxStructSize() const
203
+ {
204
+ return maxStSize;
205
+ }
206
+ //@}
207
+
208
+ /// Get different kinds of syms maps
209
+ //@{
210
+ inline IDToTypeInfoMapTy& idToObjTypeInfoMap()
211
+ {
212
+ return objTypeInfoMap;
213
+ }
214
+
215
+ inline const IDToTypeInfoMapTy& idToObjTypeInfoMap() const
129
216
  {
130
- return symInfo->getVarargSym(func);
217
+ return objTypeInfoMap;
131
218
  }
219
+
220
+ inline FunToIDMapTy& retSyms()
221
+ {
222
+ return returnSymMap;
223
+ }
224
+
225
+ inline FunToIDMapTy& varargSyms()
226
+ {
227
+ return varargSymMap;
228
+ }
229
+
230
+ //@}
231
+
232
+ inline ObjTypeInfo* getObjTypeInfo(NodeID id) const
233
+ {
234
+ IDToTypeInfoMapTy::const_iterator iter = objTypeInfoMap.find(id);
235
+ assert(iter!=objTypeInfoMap.end() && "obj type info not found");
236
+ return iter->second;
237
+ }
238
+
239
+ /// GetReturnNode - Return the unique node representing the return value of a function
240
+ NodeID getReturnNode(const SVFFunction* func) const;
241
+
242
+ /// getVarargNode - Return the unique node representing the variadic argument of a variadic function.
243
+ NodeID getVarargNode(const SVFFunction* func) const;
244
+
132
245
  inline NodeID getBlackHoleNode() const
133
246
  {
134
- return symInfo->blackholeSymID();
247
+ return blackholeSymID();
135
248
  }
136
249
  inline NodeID getConstantNode() const
137
250
  {
138
- return symInfo->constantSymID();
251
+ return constantSymID();
139
252
  }
140
253
  inline NodeID getBlkPtr() const
141
254
  {
142
- return symInfo->blkPtrSymID();
255
+ return blkPtrSymID();
143
256
  }
144
257
  inline NodeID getNullPtr() const
145
258
  {
146
- return symInfo->nullPtrSymID();
259
+ return nullPtrSymID();
260
+ }
261
+
262
+ u32_t getValueNodeNum();
263
+
264
+ u32_t getObjectNodeNum();
265
+
266
+ /// Constant reader that won't change the state of the symbol table
267
+ //@{
268
+ inline const SVFTypeSet& getSVFTypes() const
269
+ {
270
+ return svfTypes;
147
271
  }
148
272
 
149
- inline u32_t getValueNodeNum() const
273
+ inline const Set<const StInfo*>& getStInfos() const
150
274
  {
151
- return symInfo->valSyms().size();
275
+ return stInfos;
152
276
  }
153
- inline u32_t getObjectNodeNum() const
277
+ //@}
278
+ /// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
279
+ virtual APOffset getModulusOffset(const BaseObjVar* baseObj, const APOffset& apOffset);
280
+ /// Get struct info
281
+ //@{
282
+ ///Get a reference to StructInfo.
283
+ const StInfo* getTypeInfo(const SVFType* T) const;
284
+ inline bool hasSVFTypeInfo(const SVFType* T)
154
285
  {
155
- return symInfo->idToObjTypeInfoMap().size();
286
+ return svfTypes.find(T) != svfTypes.end();
156
287
  }
288
+
289
+ /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
290
+ ObjTypeInfo* createObjTypeInfo(const SVFType* type);
291
+
292
+ const ObjTypeInfo* createDummyObjTypeInfo(NodeID symId, const SVFType* type);
293
+
294
+ ///Get a reference to the components of struct_info.
295
+ /// Number of flattened elements of an array or struct
296
+ u32_t getNumOfFlattenElements(const SVFType* T);
297
+ /// Flattened element idx of an array or struct by considering stride
298
+ u32_t getFlattenedElemIdx(const SVFType* T, u32_t origId);
299
+ /// Return the type of a flattened element given a flattened index
300
+ const SVFType* getFlatternedElemType(const SVFType* baseType, u32_t flatten_idx);
301
+ /// struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b;
302
+ /// OriginalElemType of b with field_idx 1 : Struct A
303
+ /// FlatternedElemType of b with field_idx 1 : int
304
+ const SVFType* getOriginalElemType(const SVFType* baseType, u32_t origId) const;
305
+ //@}
306
+
307
+ /// Debug method
308
+ void printFlattenFields(const SVFType* type);
309
+
310
+
157
311
  inline u32_t getNodeNumAfterPAGBuild() const
158
312
  {
159
313
  return nodeNumAfterPAGBuild;
@@ -181,11 +335,38 @@ public:
181
335
  return "SVFIR";
182
336
  }
183
337
 
338
+ void dumpSymTable();
339
+
184
340
  /// Dump SVFIR
185
341
  void dump(std::string name);
186
342
 
187
343
  /// View graph from the debugger
188
344
  void view();
345
+
346
+
347
+
348
+ ///The struct type with the most fields
349
+ const SVFType* maxStruct;
350
+
351
+ ///The number of fields in max_struct
352
+ u32_t maxStSize;
353
+
354
+ inline void addTypeInfo(const SVFType* ty)
355
+ {
356
+ bool inserted = svfTypes.insert(ty).second;
357
+ if(!inserted)
358
+ assert(false && "this type info has been added before");
359
+ }
360
+
361
+ inline void addStInfo(StInfo* stInfo)
362
+ {
363
+ stInfos.insert(stInfo);
364
+ }
365
+
366
+ protected:
367
+
368
+ /// Return the flattened field type for struct type only
369
+ const std::vector<const SVFType*>& getFlattenFieldTypes(const SVFStructType *T);
189
370
  };
190
371
 
191
372
  }
@@ -51,7 +51,6 @@ class SVFVar;
51
51
  */
52
52
  class AccessPath
53
53
  {
54
- friend class SymbolTableInfo;
55
54
  friend class SVFIRWriter;
56
55
  friend class SVFIRReader;
57
56
 
@@ -0,0 +1,225 @@
1
+ //===- ObjTypeInfo.h -- Object type information------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <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 Affero 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 Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * ObjTypeInfo.h
25
+ *
26
+ * Created on: Nov 11, 2013
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef INCLUDE_SVFIR_OBJTYPEINFO_H_
31
+ #define INCLUDE_SVFIR_OBJTYPEINFO_H_
32
+
33
+
34
+ #include "Util/SVFUtil.h"
35
+ #include "MemoryModel/AccessPath.h"
36
+ #include "SVFIR/SVFModule.h"
37
+ namespace SVF
38
+ {
39
+
40
+ /*!
41
+ * Type Info of an abstract memory object
42
+ */
43
+ class ObjTypeInfo
44
+ {
45
+ friend class SVFIRWriter;
46
+ friend class SVFIRReader;
47
+ friend class SymbolTableBuilder;
48
+
49
+ public:
50
+ typedef enum
51
+ {
52
+ FUNCTION_OBJ = 0x1, // object is a function
53
+ GLOBVAR_OBJ = 0x2, // object is a global variable
54
+ STATIC_OBJ = 0x4, // object is a static variable allocated before main
55
+ STACK_OBJ = 0x8, // object is a stack variable
56
+ HEAP_OBJ = 0x10, // object is a heap variable
57
+ VAR_STRUCT_OBJ = 0x20, // object contains struct
58
+ VAR_ARRAY_OBJ = 0x40, // object contains array
59
+ CONST_STRUCT_OBJ = 0x80, // constant struct
60
+ CONST_ARRAY_OBJ = 0x100, // constant array
61
+ CONST_GLOBAL_OBJ = 0x200, // global constant object
62
+ CONST_DATA = 0x400, // constant object str e.g. 5, 10, 1.0
63
+ } MEMTYPE;
64
+
65
+ private:
66
+ /// SVF type
67
+ const SVFType* type;
68
+ /// Type flags
69
+ u32_t flags;
70
+ /// Max offset for flexible field sensitive analysis
71
+ /// maximum number of field object can be created
72
+ /// minimum number is 0 (field insensitive analysis)
73
+ u32_t maxOffsetLimit;
74
+ /// Size of the object or number of elements
75
+ u32_t elemNum;
76
+
77
+ /// Byte size of object
78
+ u32_t byteSize;
79
+
80
+ inline void resetTypeForHeapStaticObj(const SVFType* t)
81
+ {
82
+ assert((isStaticObj() || isHeap()) && "can only reset the inferred type for heap and static objects!");
83
+ type = t;
84
+ }
85
+ public:
86
+
87
+ /// Constructors
88
+ ObjTypeInfo(const SVFType* t, u32_t max) : type(t), flags(0), maxOffsetLimit(max), elemNum(max)
89
+ {
90
+ assert(t && "no type information for this object?");
91
+ }
92
+
93
+ /// Destructor
94
+ virtual ~ObjTypeInfo()
95
+ {
96
+ }
97
+
98
+ /// Get LLVM type
99
+ inline const SVFType* getType() const
100
+ {
101
+ return type;
102
+ }
103
+
104
+ /// Get max field offset limit
105
+ inline u32_t getMaxFieldOffsetLimit()
106
+ {
107
+ return maxOffsetLimit;
108
+ }
109
+
110
+ /// Get max field offset limit
111
+ inline void setMaxFieldOffsetLimit(u32_t limit)
112
+ {
113
+ maxOffsetLimit = limit;
114
+ }
115
+
116
+ /// Set the number of elements of this object
117
+ inline void setNumOfElements(u32_t num)
118
+ {
119
+ elemNum = num;
120
+ setMaxFieldOffsetLimit(num);
121
+ }
122
+
123
+ /// Get the number of elements of this object
124
+ inline u32_t getNumOfElements() const
125
+ {
126
+ return elemNum;
127
+ }
128
+
129
+ /// Get the byte size of this object
130
+ inline u32_t getByteSizeOfObj() const
131
+ {
132
+ assert(isConstantByteSize() && "This Obj's byte size is not constant.");
133
+ return byteSize;
134
+ }
135
+
136
+ /// Set the byte size of this object
137
+ inline void setByteSizeOfObj(u32_t size)
138
+ {
139
+ byteSize = size;
140
+ }
141
+
142
+ /// Check if byte size is a const value
143
+ inline bool isConstantByteSize() const
144
+ {
145
+ return byteSize != 0;
146
+ }
147
+
148
+ /// Flag for this object type
149
+ //@{
150
+ inline void setFlag(MEMTYPE mask)
151
+ {
152
+ flags |= mask;
153
+ }
154
+ inline bool hasFlag(MEMTYPE mask)
155
+ {
156
+ return (flags & mask) == mask;
157
+ }
158
+ //@}
159
+
160
+ /// Object attributes
161
+ //@{
162
+ inline bool isFunction()
163
+ {
164
+ return hasFlag(FUNCTION_OBJ);
165
+ }
166
+ inline bool isGlobalObj()
167
+ {
168
+ return hasFlag(GLOBVAR_OBJ);
169
+ }
170
+ inline bool isStaticObj()
171
+ {
172
+ return hasFlag(STATIC_OBJ);
173
+ }
174
+ inline bool isStack()
175
+ {
176
+ return hasFlag(STACK_OBJ);
177
+ }
178
+ inline bool isHeap()
179
+ {
180
+ return hasFlag(HEAP_OBJ);
181
+ }
182
+ //@}
183
+
184
+ /// Object attributes (noted that an object can be a nested compound types)
185
+ /// e.g. both isStruct and isArray can return true
186
+ //@{
187
+ inline bool isVarStruct()
188
+ {
189
+ return hasFlag(VAR_STRUCT_OBJ);
190
+ }
191
+ inline bool isConstantStruct()
192
+ {
193
+ return hasFlag(CONST_STRUCT_OBJ);
194
+ }
195
+ inline bool isStruct()
196
+ {
197
+ return hasFlag(VAR_STRUCT_OBJ) || hasFlag(CONST_STRUCT_OBJ);
198
+ }
199
+ inline bool isVarArray()
200
+ {
201
+ return hasFlag(VAR_ARRAY_OBJ);
202
+ }
203
+ inline bool isConstantArray()
204
+ {
205
+ return hasFlag(CONST_ARRAY_OBJ);
206
+ }
207
+ inline bool isArray()
208
+ {
209
+ return hasFlag(VAR_ARRAY_OBJ) || hasFlag(CONST_ARRAY_OBJ);
210
+ }
211
+ inline bool isConstDataOrConstGlobal()
212
+ {
213
+ return hasFlag(CONST_GLOBAL_OBJ) || hasFlag(CONST_DATA);
214
+ }
215
+ inline bool isConstDataOrAggData()
216
+ {
217
+ return hasFlag(CONST_DATA);
218
+ }
219
+ //@}
220
+ };
221
+
222
+
223
+ } // End namespace SVF
224
+
225
+ #endif /* INCLUDE_SVFIR_OBJTYPEINFO_H_ */
@@ -39,7 +39,6 @@ class CallGraph;
39
39
  /*!
40
40
  * SVF Intermediate representation, representing variables and statements as a Program Assignment Graph (PAG)
41
41
  * Variables as nodes and statements as edges.
42
- * SymID and NodeID are equal here (same numbering).
43
42
  */
44
43
  class SVFIR : public IRGraph
45
44
  {
@@ -63,6 +62,7 @@ public:
63
62
  typedef Map<const CallICFGNode*,SVFVarList> CSToArgsListMap;
64
63
  typedef Map<const RetICFGNode*,const SVFVar*> CSToRetMap;
65
64
  typedef Map<const SVFFunction*,const SVFVar*> FunToRetMap;
65
+ typedef Map<const CallGraphNode*,const FunObjVar *> FunToFunObjVarMap;
66
66
  typedef Map<const SVFFunction*,SVFStmtSet> FunToPAGEdgeSetMap;
67
67
  typedef Map<const ICFGNode*,SVFStmtList> ICFGNode2SVFStmtsMap;
68
68
  typedef Map<NodeID, NodeID> NodeToNodeMap;
@@ -90,6 +90,7 @@ private:
90
90
  CSToArgsListMap callSiteArgsListMap; ///< Map a callsite to a list of all its actual parameters
91
91
  CSToRetMap callSiteRetMap; ///< Map a callsite to its callsite returns PAGNodes
92
92
  FunToRetMap funRetMap; ///< Map a function to its unique function return PAGNodes
93
+ FunToFunObjVarMap funToFunObjvarMap; ///< Map a function to its unique function object PAGNodes
93
94
  CallSiteToFunPtrMap indCallSiteToFunPtrMap; ///< Map an indirect callsite to its function pointer
94
95
  FunPtrToCallSitesMap funPtrToCallSitesMap; ///< Map a function pointer to the callsites where it is used
95
96
  /// Valid pointers for pointer analysis resolution connected by SVFIR edges (constraints)
@@ -330,6 +331,12 @@ public:
330
331
  }
331
332
  //@}
332
333
 
334
+ inline const FunObjVar* getFunObjVar(const CallGraphNode* node) const
335
+ {
336
+ FunToFunObjVarMap::const_iterator it = funToFunObjvarMap.find(node);
337
+ assert(it != funToFunObjvarMap.end() && "this function doesn't have funobjvar");
338
+ return it->second;
339
+ }
333
340
  /// Node and edge statistics
334
341
  //@{
335
342
  inline u32_t getFieldValNodeNum() const
@@ -431,27 +438,17 @@ public:
431
438
 
432
439
  /// Get black hole and constant id
433
440
  //@{
434
- inline bool isBlkPtr(NodeID id) const
435
- {
436
- return (SymbolTableInfo::isBlkPtr(id));
437
- }
438
- inline bool isNullPtr(NodeID id) const
439
- {
440
- return (SymbolTableInfo::isNullPtr(id));
441
- }
441
+
442
442
  inline bool isBlkObjOrConstantObj(NodeID id) const
443
443
  {
444
444
  return (isBlkObj(id) || isConstantObj(id));
445
445
  }
446
- inline bool isBlkObj(NodeID id) const
447
- {
448
- return SymbolTableInfo::isBlkObj(id);
449
- }
446
+
450
447
  inline bool isConstantObj(NodeID id) const
451
448
  {
452
449
  const BaseObjVar* obj = getBaseObject(id);
453
450
  assert(obj && "not an object node?");
454
- return SymbolTableInfo::isConstantObj(id) ||
451
+ return isConstantSym(id) ||
455
452
  obj->isConstDataOrConstGlobal();
456
453
  }
457
454
  //@}
@@ -632,6 +629,7 @@ private:
632
629
  {
633
630
  memToFieldsMap[id].set(id);
634
631
  FunObjVar* funObj = new FunObjVar(id, ti, callGraphNode, type, node);
632
+ funToFunObjvarMap[callGraphNode] = funObj;
635
633
  return addObjNode(funObj);
636
634
  }
637
635
 
@@ -715,25 +713,25 @@ private:
715
713
  }
716
714
  inline NodeID addDummyObjNode(NodeID i, const SVFType* type)
717
715
  {
718
- if (symInfo->idToObjTypeInfoMap().find(i) == symInfo->idToObjTypeInfoMap().end())
716
+ if (idToObjTypeInfoMap().find(i) == idToObjTypeInfoMap().end())
719
717
  {
720
- ObjTypeInfo* ti = symInfo->createObjTypeInfo(type);
721
- symInfo->idToObjTypeInfoMap()[i] = ti;
718
+ ObjTypeInfo* ti = createObjTypeInfo(type);
719
+ idToObjTypeInfoMap()[i] = ti;
722
720
  return addObjNode(new DummyObjVar(i, ti, nullptr, type));
723
721
  }
724
722
  else
725
723
  {
726
- return addObjNode(new DummyObjVar(i, symInfo->getObjTypeInfo(i), nullptr, type));
724
+ return addObjNode(new DummyObjVar(i, getObjTypeInfo(i), nullptr, type));
727
725
  }
728
726
  }
729
727
 
730
728
  inline NodeID addBlackholeObjNode()
731
729
  {
732
- return addObjNode(new DummyObjVar(getBlackHoleNode(), symInfo->getObjTypeInfo(getBlackHoleNode()), nullptr));
730
+ return addObjNode(new DummyObjVar(getBlackHoleNode(), getObjTypeInfo(getBlackHoleNode()), nullptr));
733
731
  }
734
732
  inline NodeID addConstantObjNode()
735
733
  {
736
- return addObjNode(new DummyObjVar(getConstantNode(), symInfo->getObjTypeInfo(getConstantNode()), nullptr));
734
+ return addObjNode(new DummyObjVar(getConstantNode(), getObjTypeInfo(getConstantNode()), nullptr));
737
735
  }
738
736
  inline NodeID addBlackholePtrNode()
739
737
  {