svf-tools 1.0.1035 → 1.0.1036
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 +1 -1
- package/svf/include/Graphs/IRGraph.h +238 -29
- package/svf/include/MemoryModel/AccessPath.h +0 -1
- package/svf/include/SVFIR/ObjTypeInfo.h +225 -0
- package/svf/include/SVFIR/SVFIR.h +9 -19
- package/svf/include/SVFIR/SVFVariables.h +4 -9
- package/svf/lib/AE/Core/AbstractState.cpp +3 -3
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +1 -1
- package/svf/lib/Graphs/IRGraph.cpp +281 -2
- package/svf/lib/MemoryModel/AccessPath.cpp +4 -4
- package/svf/lib/MemoryModel/PointerAnalysis.cpp +1 -1
- package/svf/lib/SVFIR/PAGBuilderFromFile.cpp +1 -1
- package/svf/lib/SVFIR/SVFIR.cpp +1 -1
- package/svf/lib/SVFIR/SVFModule.cpp +1 -1
- package/svf/lib/SVFIR/SVFStatements.cpp +2 -2
- package/svf/lib/SVFIR/SVFVariables.cpp +11 -0
- package/svf/lib/Util/SVFStat.cpp +1 -1
- package/svf-llvm/include/SVF-LLVM/LLVMModule.h +1 -1
- package/svf-llvm/include/SVF-LLVM/SymbolTableBuilder.h +3 -3
- package/svf-llvm/lib/CHGBuilder.cpp +2 -2
- package/svf-llvm/lib/DCHG.cpp +1 -1
- package/svf-llvm/lib/LLVMModule.cpp +7 -7
- package/svf-llvm/lib/LLVMUtil.cpp +1 -1
- package/svf-llvm/lib/SVFIRBuilder.cpp +38 -39
- package/svf-llvm/lib/SVFIRExtAPI.cpp +8 -8
- package/svf-llvm/lib/SymbolTableBuilder.cpp +36 -38
- package/svf/include/SVFIR/SymbolTableInfo.h +0 -545
- 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.
|
|
3
|
+
"version": "1.0.1036",
|
|
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,58 @@ 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
|
+
/// llvm value to sym id map
|
|
75
|
+
/// local (%) and global (@) identifiers are pointer types which have a value node id.
|
|
76
|
+
typedef OrderedMap<const SVFValue*, NodeID> ValueToIDMapTy;
|
|
77
|
+
/// sym id to obj type info map
|
|
78
|
+
typedef OrderedMap<NodeID, ObjTypeInfo*> IDToTypeInfoMapTy;
|
|
79
|
+
|
|
80
|
+
/// function to sym id map
|
|
81
|
+
typedef OrderedMap<const SVFFunction*, NodeID> FunToIDMapTy;
|
|
82
|
+
/// struct type to struct info map
|
|
83
|
+
typedef Set<const SVFType*> SVFTypeSet;
|
|
84
|
+
//@}
|
|
85
|
+
|
|
86
|
+
private:
|
|
87
|
+
ValueToIDMapTy valSymMap; ///< map a value to its sym id
|
|
88
|
+
ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
|
|
89
|
+
FunToIDMapTy returnSymMap; ///< return map
|
|
90
|
+
FunToIDMapTy varargSymMap; ///< vararg map
|
|
91
|
+
IDToTypeInfoMapTy objTypeInfoMap; ///< map a memory sym id to its obj
|
|
92
|
+
|
|
93
|
+
/// (owned) All SVF Types
|
|
94
|
+
/// Every type T is mapped to StInfo
|
|
95
|
+
/// which contains size (fsize) , offset(foffset)
|
|
96
|
+
/// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
|
|
97
|
+
/// fsize[0] is always the size of the expanded struct.
|
|
98
|
+
SVFTypeSet svfTypes;
|
|
99
|
+
|
|
100
|
+
/// @brief (owned) All StInfo
|
|
101
|
+
Set<const StInfo*> stInfos;
|
|
102
|
+
|
|
103
|
+
/// total number of symbols
|
|
104
|
+
NodeID totalSymNum;
|
|
105
|
+
|
|
106
|
+
void destorySymTable();
|
|
53
107
|
|
|
54
108
|
public:
|
|
55
109
|
typedef Set<const SVFStmt*> SVFStmtSet;
|
|
@@ -60,7 +114,6 @@ protected:
|
|
|
60
114
|
bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
|
|
61
115
|
NodeID nodeNumAfterPAGBuild; ///< initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
|
|
62
116
|
u32_t totalPTAPAGEdge;
|
|
63
|
-
SymbolTableInfo* symInfo;
|
|
64
117
|
|
|
65
118
|
/// Add a node into the graph
|
|
66
119
|
inline NodeID addNode(SVFVar* node)
|
|
@@ -86,74 +139,203 @@ protected:
|
|
|
86
139
|
|
|
87
140
|
public:
|
|
88
141
|
IRGraph(bool buildFromFile)
|
|
89
|
-
: fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
|
|
142
|
+
: totalSymNum(0), fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0),
|
|
143
|
+
maxStruct(nullptr), maxStSize(0)
|
|
90
144
|
{
|
|
91
|
-
symInfo = SymbolTableInfo::SymbolInfo();
|
|
92
145
|
}
|
|
93
146
|
|
|
94
147
|
virtual ~IRGraph();
|
|
95
148
|
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
return symInfo;
|
|
99
|
-
}
|
|
149
|
+
|
|
100
150
|
/// Whether this SVFIR built from a txt file
|
|
101
151
|
inline bool isBuiltFromFile()
|
|
102
152
|
{
|
|
103
153
|
return fromFile;
|
|
104
154
|
}
|
|
105
155
|
|
|
106
|
-
///
|
|
107
|
-
|
|
108
|
-
inline
|
|
156
|
+
/// special value
|
|
157
|
+
// @{
|
|
158
|
+
static inline bool isBlkPtr(NodeID id)
|
|
109
159
|
{
|
|
110
|
-
return
|
|
160
|
+
return (id == BlkPtr);
|
|
111
161
|
}
|
|
112
|
-
inline bool
|
|
162
|
+
static inline bool isNullPtr(NodeID id)
|
|
113
163
|
{
|
|
114
|
-
return
|
|
164
|
+
return (id == NullPtr);
|
|
115
165
|
}
|
|
116
|
-
|
|
117
|
-
/// specified global, heap or alloca instruction according to llvm value.
|
|
118
|
-
inline NodeID getObjectNode(const SVFValue* V)
|
|
166
|
+
static inline bool isBlkObj(NodeID id)
|
|
119
167
|
{
|
|
120
|
-
return
|
|
168
|
+
return (id == BlackHole);
|
|
121
169
|
}
|
|
122
|
-
|
|
123
|
-
inline NodeID getReturnNode(const SVFFunction* func) const
|
|
170
|
+
static inline bool isConstantSym(NodeID id)
|
|
124
171
|
{
|
|
125
|
-
return
|
|
172
|
+
return (id == ConstantObj);
|
|
126
173
|
}
|
|
127
|
-
|
|
128
|
-
|
|
174
|
+
static inline bool isBlkObjOrConstantObj(NodeID id)
|
|
175
|
+
{
|
|
176
|
+
return (isBlkObj(id) || isConstantSym(id));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
inline NodeID blkPtrSymID() const
|
|
180
|
+
{
|
|
181
|
+
return BlkPtr;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
inline NodeID nullPtrSymID() const
|
|
185
|
+
{
|
|
186
|
+
return NullPtr;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
inline NodeID constantSymID() const
|
|
190
|
+
{
|
|
191
|
+
return ConstantObj;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
inline NodeID blackholeSymID() const
|
|
195
|
+
{
|
|
196
|
+
return BlackHole;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/// Statistics
|
|
200
|
+
//@{
|
|
201
|
+
inline u32_t getTotalSymNum() const
|
|
202
|
+
{
|
|
203
|
+
return totalSymNum;
|
|
204
|
+
}
|
|
205
|
+
inline u32_t getMaxStructSize() const
|
|
206
|
+
{
|
|
207
|
+
return maxStSize;
|
|
208
|
+
}
|
|
209
|
+
//@}
|
|
210
|
+
|
|
211
|
+
/// Get different kinds of syms maps
|
|
212
|
+
//@{
|
|
213
|
+
inline ValueToIDMapTy& valSyms()
|
|
214
|
+
{
|
|
215
|
+
return valSymMap;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
inline ValueToIDMapTy& objSyms()
|
|
219
|
+
{
|
|
220
|
+
return objSymMap;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
inline IDToTypeInfoMapTy& idToObjTypeInfoMap()
|
|
224
|
+
{
|
|
225
|
+
return objTypeInfoMap;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
inline const IDToTypeInfoMapTy& idToObjTypeInfoMap() const
|
|
129
229
|
{
|
|
130
|
-
return
|
|
230
|
+
return objTypeInfoMap;
|
|
131
231
|
}
|
|
232
|
+
|
|
233
|
+
inline FunToIDMapTy& retSyms()
|
|
234
|
+
{
|
|
235
|
+
return returnSymMap;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
inline FunToIDMapTy& varargSyms()
|
|
239
|
+
{
|
|
240
|
+
return varargSymMap;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
//@}
|
|
244
|
+
|
|
245
|
+
/// Get SVFIR Node according to LLVM value
|
|
246
|
+
///getNode - Return the node corresponding to the specified pointer.
|
|
247
|
+
NodeID getValueNode(const SVFValue* V);
|
|
248
|
+
|
|
249
|
+
bool hasValueNode(const SVFValue* V);
|
|
250
|
+
|
|
251
|
+
/// getObject - Return the obj node id refer to the memory object for the
|
|
252
|
+
/// specified global, heap or alloca instruction according to llvm value.
|
|
253
|
+
NodeID getObjectNode(const SVFValue* V);
|
|
254
|
+
|
|
255
|
+
inline ObjTypeInfo* getObjTypeInfo(NodeID id) const
|
|
256
|
+
{
|
|
257
|
+
IDToTypeInfoMapTy::const_iterator iter = objTypeInfoMap.find(id);
|
|
258
|
+
assert(iter!=objTypeInfoMap.end() && "obj type info not found");
|
|
259
|
+
return iter->second;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/// GetReturnNode - Return the unique node representing the return value of a function
|
|
263
|
+
NodeID getReturnNode(const SVFFunction* func) const;
|
|
264
|
+
|
|
265
|
+
/// getVarargNode - Return the unique node representing the variadic argument of a variadic function.
|
|
266
|
+
NodeID getVarargNode(const SVFFunction* func) const;
|
|
267
|
+
|
|
132
268
|
inline NodeID getBlackHoleNode() const
|
|
133
269
|
{
|
|
134
|
-
return
|
|
270
|
+
return blackholeSymID();
|
|
135
271
|
}
|
|
136
272
|
inline NodeID getConstantNode() const
|
|
137
273
|
{
|
|
138
|
-
return
|
|
274
|
+
return constantSymID();
|
|
139
275
|
}
|
|
140
276
|
inline NodeID getBlkPtr() const
|
|
141
277
|
{
|
|
142
|
-
return
|
|
278
|
+
return blkPtrSymID();
|
|
143
279
|
}
|
|
144
280
|
inline NodeID getNullPtr() const
|
|
145
281
|
{
|
|
146
|
-
return
|
|
282
|
+
return nullPtrSymID();
|
|
147
283
|
}
|
|
148
284
|
|
|
149
285
|
inline u32_t getValueNodeNum() const
|
|
150
286
|
{
|
|
151
|
-
return
|
|
287
|
+
return valSymMap.size();
|
|
152
288
|
}
|
|
153
289
|
inline u32_t getObjectNodeNum() const
|
|
154
290
|
{
|
|
155
|
-
return
|
|
291
|
+
return objTypeInfoMap.size();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/// Constant reader that won't change the state of the symbol table
|
|
295
|
+
//@{
|
|
296
|
+
inline const SVFTypeSet& getSVFTypes() const
|
|
297
|
+
{
|
|
298
|
+
return svfTypes;
|
|
156
299
|
}
|
|
300
|
+
|
|
301
|
+
inline const Set<const StInfo*>& getStInfos() const
|
|
302
|
+
{
|
|
303
|
+
return stInfos;
|
|
304
|
+
}
|
|
305
|
+
//@}
|
|
306
|
+
/// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
|
|
307
|
+
virtual APOffset getModulusOffset(const BaseObjVar* baseObj, const APOffset& apOffset);
|
|
308
|
+
/// Get struct info
|
|
309
|
+
//@{
|
|
310
|
+
///Get a reference to StructInfo.
|
|
311
|
+
const StInfo* getTypeInfo(const SVFType* T) const;
|
|
312
|
+
inline bool hasSVFTypeInfo(const SVFType* T)
|
|
313
|
+
{
|
|
314
|
+
return svfTypes.find(T) != svfTypes.end();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
|
|
318
|
+
ObjTypeInfo* createObjTypeInfo(const SVFType* type);
|
|
319
|
+
|
|
320
|
+
const ObjTypeInfo* createDummyObjTypeInfo(NodeID symId, const SVFType* type);
|
|
321
|
+
|
|
322
|
+
///Get a reference to the components of struct_info.
|
|
323
|
+
/// Number of flattened elements of an array or struct
|
|
324
|
+
u32_t getNumOfFlattenElements(const SVFType* T);
|
|
325
|
+
/// Flattened element idx of an array or struct by considering stride
|
|
326
|
+
u32_t getFlattenedElemIdx(const SVFType* T, u32_t origId);
|
|
327
|
+
/// Return the type of a flattened element given a flattened index
|
|
328
|
+
const SVFType* getFlatternedElemType(const SVFType* baseType, u32_t flatten_idx);
|
|
329
|
+
/// struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b;
|
|
330
|
+
/// OriginalElemType of b with field_idx 1 : Struct A
|
|
331
|
+
/// FlatternedElemType of b with field_idx 1 : int
|
|
332
|
+
const SVFType* getOriginalElemType(const SVFType* baseType, u32_t origId) const;
|
|
333
|
+
//@}
|
|
334
|
+
|
|
335
|
+
/// Debug method
|
|
336
|
+
void printFlattenFields(const SVFType* type);
|
|
337
|
+
|
|
338
|
+
|
|
157
339
|
inline u32_t getNodeNumAfterPAGBuild() const
|
|
158
340
|
{
|
|
159
341
|
return nodeNumAfterPAGBuild;
|
|
@@ -181,11 +363,38 @@ public:
|
|
|
181
363
|
return "SVFIR";
|
|
182
364
|
}
|
|
183
365
|
|
|
366
|
+
void dumpSymTable();
|
|
367
|
+
|
|
184
368
|
/// Dump SVFIR
|
|
185
369
|
void dump(std::string name);
|
|
186
370
|
|
|
187
371
|
/// View graph from the debugger
|
|
188
372
|
void view();
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
///The struct type with the most fields
|
|
377
|
+
const SVFType* maxStruct;
|
|
378
|
+
|
|
379
|
+
///The number of fields in max_struct
|
|
380
|
+
u32_t maxStSize;
|
|
381
|
+
|
|
382
|
+
inline void addTypeInfo(const SVFType* ty)
|
|
383
|
+
{
|
|
384
|
+
bool inserted = svfTypes.insert(ty).second;
|
|
385
|
+
if(!inserted)
|
|
386
|
+
assert(false && "this type info has been added before");
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
inline void addStInfo(StInfo* stInfo)
|
|
390
|
+
{
|
|
391
|
+
stInfos.insert(stInfo);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
protected:
|
|
395
|
+
|
|
396
|
+
/// Return the flattened field type for struct type only
|
|
397
|
+
const std::vector<const SVFType*>& getFlattenFieldTypes(const SVFStructType *T);
|
|
189
398
|
};
|
|
190
399
|
|
|
191
400
|
}
|
|
@@ -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_ */
|
|
@@ -431,27 +431,17 @@ public:
|
|
|
431
431
|
|
|
432
432
|
/// Get black hole and constant id
|
|
433
433
|
//@{
|
|
434
|
-
|
|
435
|
-
{
|
|
436
|
-
return (SymbolTableInfo::isBlkPtr(id));
|
|
437
|
-
}
|
|
438
|
-
inline bool isNullPtr(NodeID id) const
|
|
439
|
-
{
|
|
440
|
-
return (SymbolTableInfo::isNullPtr(id));
|
|
441
|
-
}
|
|
434
|
+
|
|
442
435
|
inline bool isBlkObjOrConstantObj(NodeID id) const
|
|
443
436
|
{
|
|
444
437
|
return (isBlkObj(id) || isConstantObj(id));
|
|
445
438
|
}
|
|
446
|
-
|
|
447
|
-
{
|
|
448
|
-
return SymbolTableInfo::isBlkObj(id);
|
|
449
|
-
}
|
|
439
|
+
|
|
450
440
|
inline bool isConstantObj(NodeID id) const
|
|
451
441
|
{
|
|
452
442
|
const BaseObjVar* obj = getBaseObject(id);
|
|
453
443
|
assert(obj && "not an object node?");
|
|
454
|
-
return
|
|
444
|
+
return isConstantSym(id) ||
|
|
455
445
|
obj->isConstDataOrConstGlobal();
|
|
456
446
|
}
|
|
457
447
|
//@}
|
|
@@ -715,25 +705,25 @@ private:
|
|
|
715
705
|
}
|
|
716
706
|
inline NodeID addDummyObjNode(NodeID i, const SVFType* type)
|
|
717
707
|
{
|
|
718
|
-
if (
|
|
708
|
+
if (idToObjTypeInfoMap().find(i) == idToObjTypeInfoMap().end())
|
|
719
709
|
{
|
|
720
|
-
ObjTypeInfo* ti =
|
|
721
|
-
|
|
710
|
+
ObjTypeInfo* ti = createObjTypeInfo(type);
|
|
711
|
+
idToObjTypeInfoMap()[i] = ti;
|
|
722
712
|
return addObjNode(new DummyObjVar(i, ti, nullptr, type));
|
|
723
713
|
}
|
|
724
714
|
else
|
|
725
715
|
{
|
|
726
|
-
return addObjNode(new DummyObjVar(i,
|
|
716
|
+
return addObjNode(new DummyObjVar(i, getObjTypeInfo(i), nullptr, type));
|
|
727
717
|
}
|
|
728
718
|
}
|
|
729
719
|
|
|
730
720
|
inline NodeID addBlackholeObjNode()
|
|
731
721
|
{
|
|
732
|
-
return addObjNode(new DummyObjVar(getBlackHoleNode(),
|
|
722
|
+
return addObjNode(new DummyObjVar(getBlackHoleNode(), getObjTypeInfo(getBlackHoleNode()), nullptr));
|
|
733
723
|
}
|
|
734
724
|
inline NodeID addConstantObjNode()
|
|
735
725
|
{
|
|
736
|
-
return addObjNode(new DummyObjVar(getConstantNode(),
|
|
726
|
+
return addObjNode(new DummyObjVar(getConstantNode(), getObjTypeInfo(getConstantNode()), nullptr));
|
|
737
727
|
}
|
|
738
728
|
inline NodeID addBlackholePtrNode()
|
|
739
729
|
{
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
#define INCLUDE_SVFIR_SVFVARIABLE_H_
|
|
32
32
|
|
|
33
33
|
#include "Graphs/GenericGraph.h"
|
|
34
|
-
#include "SVFIR/
|
|
34
|
+
#include "SVFIR/ObjTypeInfo.h"
|
|
35
35
|
#include "SVFIR/SVFStatements.h"
|
|
36
36
|
|
|
37
37
|
namespace SVF
|
|
@@ -648,10 +648,7 @@ public:
|
|
|
648
648
|
}
|
|
649
649
|
|
|
650
650
|
/// Whether it is a black hole object
|
|
651
|
-
bool isBlackHoleObj() const
|
|
652
|
-
{
|
|
653
|
-
return SymbolTableInfo::isBlkObj(getId());
|
|
654
|
-
}
|
|
651
|
+
bool isBlackHoleObj() const;
|
|
655
652
|
|
|
656
653
|
/// Get the byte size of this object
|
|
657
654
|
u32_t getByteSizeOfObj() const
|
|
@@ -802,10 +799,8 @@ public:
|
|
|
802
799
|
}
|
|
803
800
|
|
|
804
801
|
/// Return the type of this gep object
|
|
805
|
-
inline virtual const SVFType* getType() const
|
|
806
|
-
|
|
807
|
-
return SymbolTableInfo::SymbolInfo()->getFlatternedElemType(type, apOffset);
|
|
808
|
-
}
|
|
802
|
+
inline virtual const SVFType* getType() const;
|
|
803
|
+
|
|
809
804
|
|
|
810
805
|
/// Return name of a LLVM value
|
|
811
806
|
inline const std::string getValueName() const
|