svf-tools 1.0.733 → 1.0.734
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/AbstractExecution/SVFIR2ConsExeState.h +1 -1
- package/svf/include/AbstractExecution/SVFIR2ItvExeState.h +1 -1
- package/svf/include/Graphs/ConsG.h +2 -2
- package/svf/include/Graphs/ConsGEdge.h +4 -4
- package/svf/include/MemoryModel/{LocationSet.h → AccessPath.h} +22 -22
- package/svf/include/MemoryModel/PointerAnalysis.h +1 -1
- package/svf/include/SVFIR/PAGBuilderFromFile.h +1 -1
- package/svf/include/SVFIR/SVFFileSystem.h +3 -3
- package/svf/include/SVFIR/SVFIR.h +15 -15
- package/svf/include/SVFIR/SVFStatements.h +12 -12
- package/svf/include/SVFIR/SVFType.h +1 -0
- package/svf/include/SVFIR/SVFVariables.h +9 -15
- package/svf/include/SVFIR/SymbolTableInfo.h +4 -4
- package/svf/include/Util/Options.h +1 -1
- package/svf/include/WPA/AndersenPWC.h +1 -1
- package/svf/lib/AbstractExecution/SVFIR2ConsExeState.cpp +2 -2
- package/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp +3 -3
- package/svf/lib/DDA/ContextDDA.cpp +1 -1
- package/svf/lib/DDA/FlowDDA.cpp +1 -1
- package/svf/lib/Graphs/ConsG.cpp +4 -4
- package/svf/lib/MemoryModel/{LocationSet.cpp → AccessPath.cpp} +16 -16
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +3 -3
- package/svf/lib/SVFIR/PAGBuilderFromFile.cpp +4 -4
- package/svf/lib/SVFIR/SVFFileSystem.cpp +4 -4
- package/svf/lib/SVFIR/SVFIR.cpp +15 -15
- package/svf/lib/SVFIR/SVFVariables.cpp +1 -1
- package/svf/lib/SVFIR/SymbolTableInfo.cpp +7 -7
- package/svf/lib/Util/Options.cpp +1 -1
- package/svf/lib/WPA/Andersen.cpp +3 -3
- package/svf/lib/WPA/AndersenSFR.cpp +7 -7
- package/svf/lib/WPA/FlowSensitive.cpp +1 -1
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +8 -8
- package/svf-llvm/lib/SVFIRBuilder.cpp +16 -16
- package/svf-llvm/lib/SVFIRExtAPI.cpp +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.734",
|
|
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": {
|
|
@@ -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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//===-
|
|
1
|
+
//===- AccessPath.h -- Location set of abstract object-----------------------//
|
|
2
2
|
//
|
|
3
3
|
// SVF: Static Value-Flow Analysis
|
|
4
4
|
//
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
//===----------------------------------------------------------------------===//
|
|
22
22
|
|
|
23
23
|
/*
|
|
24
|
-
* @file:
|
|
24
|
+
* @file: AccessPath.h
|
|
25
25
|
* @author: yesen
|
|
26
26
|
* @date: 26 Sep 2014
|
|
27
27
|
*
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
#ifndef
|
|
34
|
-
#define
|
|
33
|
+
#ifndef AccessPath_H_
|
|
34
|
+
#define AccessPath_H_
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
#include "SVFIR/SVFValue.h"
|
|
@@ -49,7 +49,7 @@ class SVFVar;
|
|
|
49
49
|
* where N is the size of number-stride pair vector, M_i (stride_i) is i-th number (stride)
|
|
50
50
|
* in the number-stride pair vector.
|
|
51
51
|
*/
|
|
52
|
-
class
|
|
52
|
+
class AccessPath
|
|
53
53
|
{
|
|
54
54
|
friend class SymbolTableInfo;
|
|
55
55
|
friend class SVFIRWriter;
|
|
@@ -65,28 +65,28 @@ public:
|
|
|
65
65
|
typedef std::vector<VarAndGepTypePair> OffsetVarAndGepTypePairs;
|
|
66
66
|
|
|
67
67
|
/// Constructor
|
|
68
|
-
|
|
68
|
+
AccessPath(APOffset o = 0) : fldIdx(o) {}
|
|
69
69
|
|
|
70
70
|
/// Copy Constructor
|
|
71
|
-
|
|
71
|
+
AccessPath(const AccessPath& ls)
|
|
72
72
|
: fldIdx(ls.fldIdx),
|
|
73
73
|
offsetVarAndGepTypePairs(ls.getOffsetVarAndGepTypePairVec())
|
|
74
74
|
{
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
~
|
|
77
|
+
~AccessPath() {}
|
|
78
78
|
|
|
79
79
|
/// Overload operators
|
|
80
80
|
//@{
|
|
81
|
-
|
|
82
|
-
bool operator<(const
|
|
83
|
-
inline const
|
|
81
|
+
AccessPath operator+(const AccessPath& rhs) const;
|
|
82
|
+
bool operator<(const AccessPath& rhs) const;
|
|
83
|
+
inline const AccessPath& operator=(const AccessPath& rhs)
|
|
84
84
|
{
|
|
85
85
|
fldIdx = rhs.fldIdx;
|
|
86
86
|
offsetVarAndGepTypePairs = rhs.getOffsetVarAndGepTypePairVec();
|
|
87
87
|
return *this;
|
|
88
88
|
}
|
|
89
|
-
inline bool operator==(const
|
|
89
|
+
inline bool operator==(const AccessPath& rhs) const
|
|
90
90
|
{
|
|
91
91
|
return this->fldIdx == rhs.fldIdx &&
|
|
92
92
|
this->offsetVarAndGepTypePairs == rhs.offsetVarAndGepTypePairs;
|
|
@@ -95,11 +95,11 @@ public:
|
|
|
95
95
|
|
|
96
96
|
/// Get methods
|
|
97
97
|
//@{
|
|
98
|
-
inline
|
|
98
|
+
inline APOffset getConstantFieldIdx() const
|
|
99
99
|
{
|
|
100
100
|
return fldIdx;
|
|
101
101
|
}
|
|
102
|
-
inline void setFldIdx(
|
|
102
|
+
inline void setFldIdx(APOffset idx)
|
|
103
103
|
{
|
|
104
104
|
fldIdx = idx;
|
|
105
105
|
}
|
|
@@ -110,7 +110,7 @@ public:
|
|
|
110
110
|
//@}
|
|
111
111
|
|
|
112
112
|
/// Return accumulated constant offset given OffsetVarVec
|
|
113
|
-
|
|
113
|
+
APOffset computeConstantOffset() const;
|
|
114
114
|
|
|
115
115
|
/// Return element number of a type.
|
|
116
116
|
u32_t getElementNum(const SVFType* type) const;
|
|
@@ -122,7 +122,7 @@ public:
|
|
|
122
122
|
bool isConstantOffset() const;
|
|
123
123
|
|
|
124
124
|
/// Return TRUE if we share any location in common with RHS
|
|
125
|
-
inline bool intersects(const
|
|
125
|
+
inline bool intersects(const AccessPath& RHS) const
|
|
126
126
|
{
|
|
127
127
|
return computeAllLocations().intersects(RHS.computeAllLocations());
|
|
128
128
|
}
|
|
@@ -133,25 +133,25 @@ public:
|
|
|
133
133
|
private:
|
|
134
134
|
|
|
135
135
|
/// Check relations of two location sets
|
|
136
|
-
LSRelation checkRelation(const
|
|
136
|
+
LSRelation checkRelation(const AccessPath& LHS, const AccessPath& RHS);
|
|
137
137
|
|
|
138
138
|
/// Compute all possible locations according to offset and number-stride pairs.
|
|
139
139
|
NodeBS computeAllLocations() const;
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
APOffset fldIdx; ///< Accumulated Constant Offsets
|
|
142
142
|
OffsetVarAndGepTypePairs offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
} // End namespace SVF
|
|
146
146
|
|
|
147
|
-
template <> struct std::hash<SVF::
|
|
147
|
+
template <> struct std::hash<SVF::AccessPath>
|
|
148
148
|
{
|
|
149
|
-
size_t operator()(const SVF::
|
|
149
|
+
size_t operator()(const SVF::AccessPath &ls) const
|
|
150
150
|
{
|
|
151
151
|
SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
|
|
152
|
-
std::hash<SVF::
|
|
152
|
+
std::hash<SVF::AccessPath::OffsetVarAndGepTypePairs> v;
|
|
153
153
|
return h(std::make_pair(ls.getConstantFieldIdx(), v(ls.getOffsetVarAndGepTypePairVec())));
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
#endif /*
|
|
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
|
|
|
@@ -579,7 +579,7 @@ void SVFIR2ConsExeState::translatePhi(const PhiStmt *phi)
|
|
|
579
579
|
* @param offset
|
|
580
580
|
* @return
|
|
581
581
|
*/
|
|
582
|
-
SVFIR2ConsExeState::VAddrs SVFIR2ConsExeState::getGepObjAddress(u32_t base,
|
|
582
|
+
SVFIR2ConsExeState::VAddrs SVFIR2ConsExeState::getGepObjAddress(u32_t base, s32_t offset)
|
|
583
583
|
{
|
|
584
584
|
const VAddrs &addrs = _es->getVAddrs(base);
|
|
585
585
|
VAddrs ret;
|
|
@@ -655,7 +655,7 @@ std::pair<s32_t, s32_t> SVFIR2ConsExeState::getGepOffset(const SVF::GepStmt *gep
|
|
|
655
655
|
|
|
656
656
|
if (const SVFPointerType *pty = SVFUtil::dyn_cast<SVFPointerType>(type))
|
|
657
657
|
{
|
|
658
|
-
offset = offset * gep->
|
|
658
|
+
offset = offset * gep->getAccessPath().getElementNum(pty->getPtrElementType());
|
|
659
659
|
}
|
|
660
660
|
else
|
|
661
661
|
{
|
|
@@ -152,7 +152,7 @@ void SVFIR2ItvExeState::narrowVAddrs(IntervalExeState &lhs, const IntervalExeSta
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
SVFIR2ItvExeState::VAddrs SVFIR2ItvExeState::getGepObjAddress(u32_t pointer,
|
|
155
|
+
SVFIR2ItvExeState::VAddrs SVFIR2ItvExeState::getGepObjAddress(u32_t pointer, s32_t offset)
|
|
156
156
|
{
|
|
157
157
|
assert(!getVAddrs(pointer).empty());
|
|
158
158
|
VAddrs &addrs = getVAddrs(pointer);
|
|
@@ -242,8 +242,8 @@ std::pair<s32_t, s32_t> SVFIR2ItvExeState::getGepOffset(const GepStmt *gep)
|
|
|
242
242
|
|
|
243
243
|
if (const SVFPointerType *pty = SVFUtil::dyn_cast<SVFPointerType>(type))
|
|
244
244
|
{
|
|
245
|
-
offsetLb = offsetLb * gep->
|
|
246
|
-
offsetUb = offsetUb * gep->
|
|
245
|
+
offsetLb = offsetLb * gep->getAccessPath().getElementNum(pty->getPtrElementType());
|
|
246
|
+
offsetUb = offsetUb * gep->getAccessPath().getElementNum(pty->getPtrElementType());
|
|
247
247
|
|
|
248
248
|
}
|
|
249
249
|
else
|
|
@@ -171,7 +171,7 @@ CxtPtSet ContextDDA::processGepPts(const GepSVFGNode* gep, const CxtPtSet& srcPt
|
|
|
171
171
|
}
|
|
172
172
|
else
|
|
173
173
|
{
|
|
174
|
-
CxtVar var(ptd.get_cond(),getGepObjVar(ptd.get_id(),gepStmt->
|
|
174
|
+
CxtVar var(ptd.get_cond(),getGepObjVar(ptd.get_id(),gepStmt->getAccessPath().getConstantFieldIdx()));
|
|
175
175
|
tmpDstPts.set(var);
|
|
176
176
|
}
|
|
177
177
|
}
|
package/svf/lib/DDA/FlowDDA.cpp
CHANGED
|
@@ -156,7 +156,7 @@ PointsTo FlowDDA::processGepPts(const GepSVFGNode* gep, const PointsTo& srcPts)
|
|
|
156
156
|
}
|
|
157
157
|
else
|
|
158
158
|
{
|
|
159
|
-
NodeID fieldSrcPtdNode = getGepObjVar(ptd, gepStmt->
|
|
159
|
+
NodeID fieldSrcPtdNode = getGepObjVar(ptd, gepStmt->getAccessPath().getConstantFieldIdx());
|
|
160
160
|
tmpDstPts.set(fieldSrcPtdNode);
|
|
161
161
|
}
|
|
162
162
|
}
|
package/svf/lib/Graphs/ConsG.cpp
CHANGED
|
@@ -121,7 +121,7 @@ void ConstraintGraph::buildCG()
|
|
|
121
121
|
if(edge->isVariantFieldGep())
|
|
122
122
|
addVariantGepCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
|
|
123
123
|
else
|
|
124
|
-
addNormalGepCGEdge(edge->getRHSVarID(),edge->getLHSVarID(),edge->
|
|
124
|
+
addNormalGepCGEdge(edge->getRHSVarID(),edge->getLHSVarID(),edge->getAccessPath());
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
SVFStmt::SVFStmtSetTy& loads = getPAGEdgeSet(SVFStmt::Load);
|
|
@@ -210,7 +210,7 @@ CopyCGEdge* ConstraintGraph::addCopyCGEdge(NodeID src, NodeID dst)
|
|
|
210
210
|
/*!
|
|
211
211
|
* Add Gep edge
|
|
212
212
|
*/
|
|
213
|
-
NormalGepCGEdge* ConstraintGraph::addNormalGepCGEdge(NodeID src, NodeID dst, const
|
|
213
|
+
NormalGepCGEdge* ConstraintGraph::addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath& ls)
|
|
214
214
|
{
|
|
215
215
|
ConstraintNode* srcNode = getConstraintNode(src);
|
|
216
216
|
ConstraintNode* dstNode = getConstraintNode(dst);
|
|
@@ -320,7 +320,7 @@ void ConstraintGraph::reTargetDstOfEdge(ConstraintEdge* edge, ConstraintNode* ne
|
|
|
320
320
|
}
|
|
321
321
|
else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
|
|
322
322
|
{
|
|
323
|
-
const
|
|
323
|
+
const AccessPath ls = gep->getAccessPath();
|
|
324
324
|
removeDirectEdge(gep);
|
|
325
325
|
addNormalGepCGEdge(srcId,newDstNodeID,ls);
|
|
326
326
|
}
|
|
@@ -364,7 +364,7 @@ void ConstraintGraph::reTargetSrcOfEdge(ConstraintEdge* edge, ConstraintNode* ne
|
|
|
364
364
|
}
|
|
365
365
|
else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
|
|
366
366
|
{
|
|
367
|
-
const
|
|
367
|
+
const AccessPath ls = gep->getAccessPath();
|
|
368
368
|
removeDirectEdge(gep);
|
|
369
369
|
addNormalGepCGEdge(newSrcNodeID,dstId,ls);
|
|
370
370
|
}
|