svf-lib 1.0.1571 → 1.0.1573
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/SVF-linux/Release-build/svf/libSvfCore.a +0 -0
- package/SVF-linux/Release-build/svf-llvm/libSvfLLVM.a +0 -0
- package/SVF-linux/svf/include/Util/ExtAPI.h +1 -1
- package/SVF-linux/svf/include/Util/ExtAPI.json +8 -8
- package/SVF-osx/Release-build/svf/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
- package/SVF-osx/svf/include/AbstractExecution/SVFIR2ConsExeState.h +1 -1
- package/SVF-osx/svf/include/AbstractExecution/SVFIR2ItvExeState.h +1 -1
- package/SVF-osx/svf/include/Graphs/ConsG.h +2 -2
- package/SVF-osx/svf/include/Graphs/ConsGEdge.h +4 -4
- package/SVF-osx/svf/include/MemoryModel/AccessPath.h +157 -0
- package/SVF-osx/svf/include/MemoryModel/PointerAnalysis.h +1 -1
- package/SVF-osx/svf/include/SVFIR/PAGBuilderFromFile.h +1 -1
- package/SVF-osx/svf/include/SVFIR/SVFFileSystem.h +3 -3
- package/SVF-osx/svf/include/SVFIR/SVFIR.h +15 -15
- package/SVF-osx/svf/include/SVFIR/SVFStatements.h +12 -12
- package/SVF-osx/svf/include/SVFIR/SVFType.h +1 -0
- package/SVF-osx/svf/include/SVFIR/SVFVariables.h +9 -15
- package/SVF-osx/svf/include/SVFIR/SymbolTableInfo.h +4 -4
- package/SVF-osx/svf/include/Util/Options.h +1 -1
- package/SVF-osx/svf/include/WPA/AndersenPWC.h +1 -1
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +8 -8
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
@@ -481,7 +481,7 @@ public:
|
|
|
481
481
|
|
|
482
482
|
// Get all operations of an extern function
|
|
483
483
|
Operand getBasicOperation(cJSON* obj);
|
|
484
|
-
ExtFunctionOps getExtFunctionOps(
|
|
484
|
+
ExtFunctionOps getExtFunctionOps(const SVFFunction* extFunction);
|
|
485
485
|
|
|
486
486
|
// Get property of the operation, e.g. "EFT_A1R_A0R"
|
|
487
487
|
extType get_type(const SVF::SVFFunction *callee);
|
|
@@ -1401,7 +1401,7 @@
|
|
|
1401
1401
|
},
|
|
1402
1402
|
"llvm.va_start": {
|
|
1403
1403
|
"return": "void",
|
|
1404
|
-
"arguments": "(
|
|
1404
|
+
"arguments": "(i8*)",
|
|
1405
1405
|
"type": "EFT_NOOP",
|
|
1406
1406
|
"overwrite_app_function": 1
|
|
1407
1407
|
},
|
|
@@ -3346,8 +3346,8 @@
|
|
|
3346
3346
|
}
|
|
3347
3347
|
},
|
|
3348
3348
|
"__sysv_signal": {
|
|
3349
|
-
"return": "
|
|
3350
|
-
"arguments": "(
|
|
3349
|
+
"return": "void (i32)*",
|
|
3350
|
+
"arguments": "(i32, void (i32)*)",
|
|
3351
3351
|
"type": "EFT_ALLOC",
|
|
3352
3352
|
"overwrite_app_function": 1,
|
|
3353
3353
|
"AddrStmt": {
|
|
@@ -3356,8 +3356,8 @@
|
|
|
3356
3356
|
}
|
|
3357
3357
|
},
|
|
3358
3358
|
"signal": {
|
|
3359
|
-
"return": "
|
|
3360
|
-
"arguments": "(
|
|
3359
|
+
"return": "void (i32)*",
|
|
3360
|
+
"arguments": "(i32, void (i32)*)",
|
|
3361
3361
|
"type": "EFT_ALLOC",
|
|
3362
3362
|
"overwrite_app_function": 1,
|
|
3363
3363
|
"AddrStmt": {
|
|
@@ -5009,7 +5009,7 @@
|
|
|
5009
5009
|
},
|
|
5010
5010
|
"llvm.memset.p0i8.i64": {
|
|
5011
5011
|
"return": "void",
|
|
5012
|
-
"arguments": "(i8*, i8, i64,
|
|
5012
|
+
"arguments": "(i8*, i8, i64, i1)",
|
|
5013
5013
|
"type": "EFT_L_A0__A0R_A1",
|
|
5014
5014
|
"overwrite_app_function": 0,
|
|
5015
5015
|
"memset_like": {
|
|
@@ -5061,7 +5061,7 @@
|
|
|
5061
5061
|
},
|
|
5062
5062
|
"llvm.memcpy.p0i8.p0i8.i64": {
|
|
5063
5063
|
"return": "void",
|
|
5064
|
-
"arguments": "(i8*,
|
|
5064
|
+
"arguments": "(i8*, i8*, i64, i1)",
|
|
5065
5065
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5066
5066
|
"overwrite_app_function": 0,
|
|
5067
5067
|
"memcpy_like": {
|
|
@@ -5585,7 +5585,7 @@
|
|
|
5585
5585
|
},
|
|
5586
5586
|
"_ZNSt8__detail15_List_node_base7_M_hookEPS0_":{
|
|
5587
5587
|
"return": "void",
|
|
5588
|
-
"arguments": "(std::__detail::_List_node_base*)",
|
|
5588
|
+
"arguments": "(struct.std::__detail::_List_node_base*, struct.std::__detail::_List_node_base*)",
|
|
5589
5589
|
"type": "EFT_STD_LIST_HOOK",
|
|
5590
5590
|
"overwrite_app_function": 0,
|
|
5591
5591
|
"StoreStmt": {
|
|
Binary file
|
|
Binary file
|
|
@@ -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,
|
|
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,
|
|
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);
|
|
@@ -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
|
|
183
|
+
NormalGepCGEdge* addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath& ls);
|
|
184
184
|
VariantGepCGEdge* addVariantGepCGEdge(NodeID src, NodeID dst);
|
|
185
185
|
/// Add Load edge
|
|
186
186
|
LoadCGEdge* addLoadCGEdge(NodeID src, NodeID dst);
|
|
@@ -325,7 +325,7 @@ 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
|
|
328
|
+
inline NodeID getGepObjVar(NodeID id, const APOffset& ls)
|
|
329
329
|
{
|
|
330
330
|
NodeID gep = pag->getGepObjVar(id,ls);
|
|
331
331
|
/// Create a node when it is (1) not exist on graph and (2) not merged
|
|
@@ -269,7 +269,7 @@ private:
|
|
|
269
269
|
NormalGepCGEdge(const NormalGepCGEdge &); ///< place holder
|
|
270
270
|
void operator=(const NormalGepCGEdge &); ///< place holder
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
AccessPath ls; ///< location set of the gep edge
|
|
273
273
|
|
|
274
274
|
public:
|
|
275
275
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
@@ -293,18 +293,18 @@ public:
|
|
|
293
293
|
//@}
|
|
294
294
|
|
|
295
295
|
/// Constructor
|
|
296
|
-
NormalGepCGEdge(ConstraintNode* s, ConstraintNode* d, const
|
|
296
|
+
NormalGepCGEdge(ConstraintNode* s, ConstraintNode* d, const AccessPath& l, EdgeID id)
|
|
297
297
|
: GepCGEdge(s,d,NormalGep,id), ls(l)
|
|
298
298
|
{}
|
|
299
299
|
|
|
300
300
|
/// Get location set of the gep edge
|
|
301
|
-
inline const
|
|
301
|
+
inline const AccessPath& getAccessPath() const
|
|
302
302
|
{
|
|
303
303
|
return ls;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
/// Get location set of the gep edge
|
|
307
|
-
inline
|
|
307
|
+
inline APOffset getConstantFieldIdx() const
|
|
308
308
|
{
|
|
309
309
|
return ls.getConstantFieldIdx();
|
|
310
310
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
//===- AccessPath.h -- Location set of abstract object-----------------------//
|
|
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
|
+
* @file: AccessPath.h
|
|
25
|
+
* @author: yesen
|
|
26
|
+
* @date: 26 Sep 2014
|
|
27
|
+
*
|
|
28
|
+
* LICENSE
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#ifndef AccessPath_H_
|
|
34
|
+
#define AccessPath_H_
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#include "SVFIR/SVFValue.h"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
namespace SVF
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
class SVFVar;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
* Location set represents a set of locations in a memory block with following offsets:
|
|
48
|
+
* { offset + \sum_{i=0}^N (stride_i * j_i) | 0 \leq j_i < M_i }
|
|
49
|
+
* where N is the size of number-stride pair vector, M_i (stride_i) is i-th number (stride)
|
|
50
|
+
* in the number-stride pair vector.
|
|
51
|
+
*/
|
|
52
|
+
class AccessPath
|
|
53
|
+
{
|
|
54
|
+
friend class SymbolTableInfo;
|
|
55
|
+
friend class SVFIRWriter;
|
|
56
|
+
friend class SVFIRReader;
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
enum LSRelation
|
|
60
|
+
{
|
|
61
|
+
NonOverlap, Overlap, Subset, Superset, Same
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
typedef std::pair<const SVFVar*, const SVFType*> VarAndGepTypePair;
|
|
65
|
+
typedef std::vector<VarAndGepTypePair> OffsetVarAndGepTypePairs;
|
|
66
|
+
|
|
67
|
+
/// Constructor
|
|
68
|
+
AccessPath(APOffset o = 0) : fldIdx(o) {}
|
|
69
|
+
|
|
70
|
+
/// Copy Constructor
|
|
71
|
+
AccessPath(const AccessPath& ls)
|
|
72
|
+
: fldIdx(ls.fldIdx),
|
|
73
|
+
offsetVarAndGepTypePairs(ls.getOffsetVarAndGepTypePairVec())
|
|
74
|
+
{
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
~AccessPath() {}
|
|
78
|
+
|
|
79
|
+
/// Overload operators
|
|
80
|
+
//@{
|
|
81
|
+
AccessPath operator+(const AccessPath& rhs) const;
|
|
82
|
+
bool operator<(const AccessPath& rhs) const;
|
|
83
|
+
inline const AccessPath& operator=(const AccessPath& rhs)
|
|
84
|
+
{
|
|
85
|
+
fldIdx = rhs.fldIdx;
|
|
86
|
+
offsetVarAndGepTypePairs = rhs.getOffsetVarAndGepTypePairVec();
|
|
87
|
+
return *this;
|
|
88
|
+
}
|
|
89
|
+
inline bool operator==(const AccessPath& rhs) const
|
|
90
|
+
{
|
|
91
|
+
return this->fldIdx == rhs.fldIdx &&
|
|
92
|
+
this->offsetVarAndGepTypePairs == rhs.offsetVarAndGepTypePairs;
|
|
93
|
+
}
|
|
94
|
+
//@}
|
|
95
|
+
|
|
96
|
+
/// Get methods
|
|
97
|
+
//@{
|
|
98
|
+
inline APOffset getConstantFieldIdx() const
|
|
99
|
+
{
|
|
100
|
+
return fldIdx;
|
|
101
|
+
}
|
|
102
|
+
inline void setFldIdx(APOffset idx)
|
|
103
|
+
{
|
|
104
|
+
fldIdx = idx;
|
|
105
|
+
}
|
|
106
|
+
inline const OffsetVarAndGepTypePairs& getOffsetVarAndGepTypePairVec() const
|
|
107
|
+
{
|
|
108
|
+
return offsetVarAndGepTypePairs;
|
|
109
|
+
}
|
|
110
|
+
//@}
|
|
111
|
+
|
|
112
|
+
/// Return accumulated constant offset given OffsetVarVec
|
|
113
|
+
APOffset computeConstantOffset() const;
|
|
114
|
+
|
|
115
|
+
/// Return element number of a type.
|
|
116
|
+
u32_t getElementNum(const SVFType* type) const;
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
bool addOffsetVarAndGepTypePair(const SVFVar* var, const SVFType* gepIterType);
|
|
120
|
+
|
|
121
|
+
/// Return TRUE if this is a constant location set.
|
|
122
|
+
bool isConstantOffset() const;
|
|
123
|
+
|
|
124
|
+
/// Return TRUE if we share any location in common with RHS
|
|
125
|
+
inline bool intersects(const AccessPath& RHS) const
|
|
126
|
+
{
|
|
127
|
+
return computeAllLocations().intersects(RHS.computeAllLocations());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// Dump location set
|
|
131
|
+
std::string dump() const;
|
|
132
|
+
|
|
133
|
+
private:
|
|
134
|
+
|
|
135
|
+
/// Check relations of two location sets
|
|
136
|
+
LSRelation checkRelation(const AccessPath& LHS, const AccessPath& RHS);
|
|
137
|
+
|
|
138
|
+
/// Compute all possible locations according to offset and number-stride pairs.
|
|
139
|
+
NodeBS computeAllLocations() const;
|
|
140
|
+
|
|
141
|
+
APOffset fldIdx; ///< Accumulated Constant Offsets
|
|
142
|
+
OffsetVarAndGepTypePairs offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
} // End namespace SVF
|
|
146
|
+
|
|
147
|
+
template <> struct std::hash<SVF::AccessPath>
|
|
148
|
+
{
|
|
149
|
+
size_t operator()(const SVF::AccessPath &ls) const
|
|
150
|
+
{
|
|
151
|
+
SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
|
|
152
|
+
std::hash<SVF::AccessPath::OffsetVarAndGepTypePairs> v;
|
|
153
|
+
return h(std::make_pair(ls.getConstantFieldIdx(), v(ls.getOffsetVarAndGepTypePairVec())));
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
#endif /* AccessPath_H_ */
|
|
@@ -159,7 +159,7 @@ class SymbolTableInfo;
|
|
|
159
159
|
|
|
160
160
|
class SVFModule;
|
|
161
161
|
|
|
162
|
-
class
|
|
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
|
|
425
|
+
cJSON* toJson(const AccessPath& ls);
|
|
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,
|
|
1107
|
+
void readJson(const cJSON* obj, AccessPath& ls);
|
|
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,
|
|
68
|
-
typedef std::pair<NodeID,
|
|
67
|
+
typedef std::pair<NodeID, APOffset> NodeOffset;
|
|
68
|
+
typedef std::pair<NodeID, AccessPath> NodeAccessPath;
|
|
69
69
|
typedef Map<NodeOffset,NodeID> NodeOffsetMap;
|
|
70
|
-
typedef Map<
|
|
71
|
-
typedef Map<const SVFValue*,
|
|
72
|
-
typedef std::pair<const SVFType*, std::vector<
|
|
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
|
-
|
|
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
|
|
132
|
+
inline NodeOffsetMap& getGepObjNodeMap()
|
|
133
133
|
{
|
|
134
134
|
return GepObjVarMap;
|
|
135
135
|
}
|
|
@@ -328,7 +328,7 @@ 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
|
|
331
|
+
NodeID getGepValVar(const SVFValue* curInst, NodeID base, const AccessPath& ls) const;
|
|
332
332
|
|
|
333
333
|
/// Add/get indirect callsites
|
|
334
334
|
//@{
|
|
@@ -392,9 +392,9 @@ public:
|
|
|
392
392
|
//@}
|
|
393
393
|
|
|
394
394
|
/// Get a field SVFIR Object node according to base mem obj and offset
|
|
395
|
-
NodeID getGepObjVar(const MemObj* obj, const
|
|
395
|
+
NodeID getGepObjVar(const MemObj* obj, const APOffset& ls);
|
|
396
396
|
/// Get a field obj SVFIR node according to a mem obj and a given offset
|
|
397
|
-
NodeID getGepObjVar(NodeID id, const
|
|
397
|
+
NodeID getGepObjVar(NodeID id, const APOffset& ls) ;
|
|
398
398
|
/// Get a field-insensitive obj SVFIR node according to a mem obj
|
|
399
399
|
//@{
|
|
400
400
|
inline NodeID getFIObjVar(const MemObj* obj) const
|
|
@@ -557,9 +557,9 @@ private:
|
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
/// Add a temp field value node, this method can only invoked by getGepValVar
|
|
560
|
-
NodeID addGepValNode(const SVFValue* curInst,const SVFValue* val, const
|
|
560
|
+
NodeID addGepValNode(const SVFValue* curInst,const SVFValue* val, const AccessPath& ls, NodeID i, const SVFType* type);
|
|
561
561
|
/// Add a field obj node, this method can only invoked by getGepObjVar
|
|
562
|
-
NodeID addGepObjNode(const MemObj* obj, const
|
|
562
|
+
NodeID addGepObjNode(const MemObj* obj, const APOffset& ls);
|
|
563
563
|
/// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
|
|
564
564
|
NodeID addFIObjNode(const MemObj* obj);
|
|
565
565
|
//@}
|
|
@@ -665,12 +665,12 @@ private:
|
|
|
665
665
|
RetPE* addRetPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
666
666
|
const FunExitICFGNode* exit);
|
|
667
667
|
/// Add Gep edge
|
|
668
|
-
GepStmt* addGepStmt(NodeID src, NodeID dst, const
|
|
668
|
+
GepStmt* addGepStmt(NodeID src, NodeID dst, const AccessPath& ls,
|
|
669
669
|
bool constGep);
|
|
670
670
|
/// Add Offset(Gep) edge
|
|
671
|
-
GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const
|
|
671
|
+
GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const AccessPath& ls);
|
|
672
672
|
/// Add Variant(Gep) edge
|
|
673
|
-
GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const
|
|
673
|
+
GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const AccessPath& ls);
|
|
674
674
|
/// Add Thread fork edge for parameter passing
|
|
675
675
|
TDForkPE* addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
676
676
|
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/
|
|
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
|
-
|
|
468
|
+
AccessPath ls; ///< location set 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
|
|
487
|
+
inline const AccessPath& getAccessPath() const
|
|
488
488
|
{
|
|
489
489
|
return ls;
|
|
490
490
|
}
|
|
491
|
-
inline const
|
|
491
|
+
inline const AccessPath::OffsetVarAndGepTypePairs getOffsetVarAndGepTypePairVec() const
|
|
492
492
|
{
|
|
493
|
-
return
|
|
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
|
|
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
|
|
501
|
+
inline APOffset accumulateConstantOffset() const
|
|
502
502
|
{
|
|
503
|
-
return
|
|
503
|
+
return getAccessPath().computeConstantOffset();
|
|
504
504
|
}
|
|
505
505
|
/// Field index of the gep statement if it access the field of a struct
|
|
506
|
-
inline
|
|
506
|
+
inline APOffset getConstantFieldIdx() const
|
|
507
507
|
{
|
|
508
|
-
assert(isVariantFieldGep()==false && "Can't retrieve the
|
|
509
|
-
return
|
|
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,7 +515,7 @@ public:
|
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
/// constructor
|
|
518
|
-
GepStmt(SVFVar* s, SVFVar* d, const
|
|
518
|
+
GepStmt(SVFVar* s, SVFVar* d, const AccessPath& l, bool varfld = false)
|
|
519
519
|
: AssignStmt(s, d, SVFStmt::Gep), ls(l), variantField(varfld)
|
|
520
520
|
{
|
|
521
521
|
}
|
|
@@ -383,7 +383,7 @@ class GepValVar: public ValVar
|
|
|
383
383
|
friend class SVFIRReader;
|
|
384
384
|
|
|
385
385
|
private:
|
|
386
|
-
|
|
386
|
+
AccessPath ls; // AccessPath
|
|
387
387
|
const SVFType* gepValType;
|
|
388
388
|
|
|
389
389
|
/// Constructor to create empty GeValVar (for SVFIRReader/deserialization)
|
|
@@ -411,14 +411,14 @@ public:
|
|
|
411
411
|
//@}
|
|
412
412
|
|
|
413
413
|
/// Constructor
|
|
414
|
-
GepValVar(const SVFValue* val, NodeID i, const
|
|
414
|
+
GepValVar(const SVFValue* val, NodeID i, const AccessPath& l,
|
|
415
415
|
const SVFType* ty)
|
|
416
416
|
: ValVar(val, i, GepValNode), ls(l), gepValType(ty)
|
|
417
417
|
{
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
/// offset of the base value variable
|
|
421
|
-
inline
|
|
421
|
+
inline APOffset getConstantFieldIdx() const
|
|
422
422
|
{
|
|
423
423
|
return ls.getConstantFieldIdx();
|
|
424
424
|
}
|
|
@@ -451,7 +451,7 @@ class GepObjVar: public ObjVar
|
|
|
451
451
|
friend class SVFIRReader;
|
|
452
452
|
|
|
453
453
|
private:
|
|
454
|
-
|
|
454
|
+
APOffset ls = 0;
|
|
455
455
|
NodeID base = 0;
|
|
456
456
|
|
|
457
457
|
/// Constructor to create empty GepObjVar (for SVFIRReader/deserialization)
|
|
@@ -480,7 +480,7 @@ public:
|
|
|
480
480
|
//@}
|
|
481
481
|
|
|
482
482
|
/// Constructor
|
|
483
|
-
GepObjVar(const MemObj* mem, NodeID i, const
|
|
483
|
+
GepObjVar(const MemObj* mem, NodeID i, const APOffset& l,
|
|
484
484
|
PNODEK ty = GepObjNode)
|
|
485
485
|
: ObjVar(mem->getValue(), i, mem, ty), ls(l)
|
|
486
486
|
{
|
|
@@ -488,17 +488,11 @@ public:
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
/// offset of the mem object
|
|
491
|
-
inline
|
|
491
|
+
inline APOffset getConstantFieldIdx() const
|
|
492
492
|
{
|
|
493
493
|
return ls;
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
/// offset of the mem object
|
|
497
|
-
inline s32_t getConstantFieldIdx() const
|
|
498
|
-
{
|
|
499
|
-
return ls.getConstantFieldIdx();
|
|
500
|
-
}
|
|
501
|
-
|
|
502
496
|
/// Set the base object from which this GEP node came from.
|
|
503
497
|
inline void setBaseNode(NodeID base)
|
|
504
498
|
{
|
|
@@ -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
|
|
511
|
+
return SymbolTableInfo::SymbolInfo()->getFlatternedElemType(mem->getType(), ls);
|
|
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
|
|
525
|
-
return "offset_" + std::to_string(ls
|
|
518
|
+
return value->getName() + "_" + std::to_string(ls);
|
|
519
|
+
return "offset_" + std::to_string(ls);
|
|
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/
|
|
35
|
+
#include "MemoryModel/AccessPath.h"
|
|
36
36
|
#include "SVFIR/SVFModule.h"
|
|
37
37
|
namespace SVF
|
|
38
38
|
{
|
|
@@ -333,7 +333,7 @@ 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
|
|
336
|
+
virtual APOffset getModulusOffset(const MemObj* obj, const APOffset& ls);
|
|
337
337
|
|
|
338
338
|
///The struct type with the most fields
|
|
339
339
|
const SVFType* maxStruct;
|
|
@@ -453,7 +453,7 @@ public:
|
|
|
453
453
|
bool isConstDataOrConstGlobal() const;
|
|
454
454
|
bool isConstDataOrAggData() const;
|
|
455
455
|
bool hasPtrObj() const;
|
|
456
|
-
bool isNonPtrFieldObj(const
|
|
456
|
+
bool isNonPtrFieldObj(const APOffset& ls) const;
|
|
457
457
|
//@}
|
|
458
458
|
|
|
459
459
|
/// Operator overloading
|
|
@@ -621,7 +621,7 @@ public:
|
|
|
621
621
|
{
|
|
622
622
|
return hasFlag(HASPTR_OBJ);
|
|
623
623
|
}
|
|
624
|
-
virtual bool isNonPtrFieldObj(const
|
|
624
|
+
virtual bool isNonPtrFieldObj(const APOffset& ls);
|
|
625
625
|
//@}
|
|
626
626
|
};
|
|
627
627
|
|
|
@@ -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 (
|
|
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)
|
|
@@ -149,7 +149,7 @@ public:
|
|
|
149
149
|
protected:
|
|
150
150
|
void initialize();
|
|
151
151
|
void PWCDetect();
|
|
152
|
-
void fieldExpand(NodeSet& initials,
|
|
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
|
|
|
@@ -75,7 +75,7 @@ public:
|
|
|
75
75
|
//@{
|
|
76
76
|
void initialiseNodes();
|
|
77
77
|
void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
|
|
78
|
-
|
|
78
|
+
APOffset offset = 0, Instruction* cs = nullptr);
|
|
79
79
|
// @}
|
|
80
80
|
|
|
81
81
|
/// Sanity check for SVFIR
|
|
@@ -216,10 +216,10 @@ protected:
|
|
|
216
216
|
void processCE(const Value* val);
|
|
217
217
|
|
|
218
218
|
/// Infer field index from byteoffset.
|
|
219
|
-
u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl,
|
|
219
|
+
u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, AccessPath& ls, APOffset idx);
|
|
220
220
|
|
|
221
221
|
/// Compute offset of a gep instruction or gep constant expression
|
|
222
|
-
bool computeGepOffset(const User *V,
|
|
222
|
+
bool computeGepOffset(const User *V, AccessPath& ls);
|
|
223
223
|
|
|
224
224
|
/// Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst, i8* src, int size))
|
|
225
225
|
const Value* getBaseValueForExtArg(const Value* V);
|
|
@@ -287,7 +287,7 @@ protected:
|
|
|
287
287
|
return nullPtr;
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
NodeID getGepValVar(const SVFValue* val, const
|
|
290
|
+
NodeID getGepValVar(const SVFValue* val, const AccessPath& ls, const SVFType* baseType);
|
|
291
291
|
|
|
292
292
|
void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
|
|
293
293
|
|
|
@@ -384,19 +384,19 @@ protected:
|
|
|
384
384
|
setCurrentBBAndValueForPAGEdge(edge);
|
|
385
385
|
}
|
|
386
386
|
/// Add Gep edge
|
|
387
|
-
inline void addGepEdge(NodeID src, NodeID dst, const
|
|
387
|
+
inline void addGepEdge(NodeID src, NodeID dst, const AccessPath& ls, bool constGep)
|
|
388
388
|
{
|
|
389
389
|
if(GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep))
|
|
390
390
|
setCurrentBBAndValueForPAGEdge(edge);
|
|
391
391
|
}
|
|
392
392
|
/// Add Offset(Gep) edge
|
|
393
|
-
inline void addNormalGepEdge(NodeID src, NodeID dst, const
|
|
393
|
+
inline void addNormalGepEdge(NodeID src, NodeID dst, const AccessPath& ls)
|
|
394
394
|
{
|
|
395
395
|
if(GepStmt *edge = pag->addNormalGepStmt(src, dst, ls))
|
|
396
396
|
setCurrentBBAndValueForPAGEdge(edge);
|
|
397
397
|
}
|
|
398
398
|
/// Add Variant(Gep) edge
|
|
399
|
-
inline void addVariantGepEdge(NodeID src, NodeID dst, const
|
|
399
|
+
inline void addVariantGepEdge(NodeID src, NodeID dst, const AccessPath& ls)
|
|
400
400
|
{
|
|
401
401
|
if(GepStmt *edge = pag->addVariantGepStmt(src, dst, ls))
|
|
402
402
|
setCurrentBBAndValueForPAGEdge(edge);
|
|
@@ -415,7 +415,7 @@ protected:
|
|
|
415
415
|
}
|
|
416
416
|
//@}
|
|
417
417
|
|
|
418
|
-
|
|
418
|
+
AccessPath getAccessPathFromBaseNode(NodeID nodeId);
|
|
419
419
|
};
|
|
420
420
|
|
|
421
421
|
} // End namespace SVF
|