svf-lib 1.0.992 → 1.0.995
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/lib/libSvf.a +0 -0
- package/SVF-linux/include/CFL/CFGNormalizer.h +6 -3
- package/SVF-linux/include/CFL/CFLAlias.h +26 -15
- package/SVF-linux/include/CFL/CFLGrammar.h +30 -16
- package/SVF-linux/include/CFL/CFLSolver.h +9 -5
- package/SVF-linux/include/CFL/GrammarBuilder.h +10 -7
- package/SVF-linux/include/CUDD/cudd.h +20 -11
- package/SVF-linux/include/CUDD/cuddInt.h +48 -31
- package/SVF-linux/include/CUDD/epd.h +35 -29
- package/SVF-linux/include/CUDD/mtr.h +4 -3
- package/SVF-linux/include/CUDD/st.h +7 -4
- package/SVF-linux/include/CUDD/util.h +6 -6
- package/SVF-linux/include/FastCluster/fastcluster.h +13 -12
- package/SVF-linux/include/Graphs/CFLGraph.h +16 -10
- package/SVF-linux/include/Graphs/CHG.h +2 -2
- package/SVF-linux/include/Graphs/ConsG.h +2 -1
- package/SVF-linux/include/Graphs/GenericGraph.h +3 -3
- package/SVF-linux/include/Graphs/ICFG.h +2 -2
- package/SVF-linux/include/Graphs/ICFGEdge.h +16 -9
- package/SVF-linux/include/Graphs/ICFGNode.h +2 -2
- package/SVF-linux/include/Graphs/IRGraph.h +10 -6
- package/SVF-linux/include/Graphs/PTACallGraph.h +1 -1
- package/SVF-linux/include/Graphs/SVFG.h +4 -3
- package/SVF-linux/include/Graphs/SVFGNode.h +14 -8
- package/SVF-linux/include/Graphs/ThreadCallGraph.h +4 -2
- package/SVF-linux/include/Graphs/VFG.h +45 -39
- package/SVF-linux/include/Graphs/VFGNode.h +8 -4
- package/SVF-linux/include/MSSA/MemSSA.h +1 -1
- package/SVF-linux/include/MTA/FSMPTA.h +55 -44
- package/SVF-linux/include/MTA/LockAnalysis.h +11 -9
- package/SVF-linux/include/MTA/LockResultValidator.h +64 -54
- package/SVF-linux/include/MTA/MHP.h +17 -13
- package/SVF-linux/include/MTA/MTAResultValidator.h +24 -20
- package/SVF-linux/include/MTA/PCG.h +9 -7
- package/SVF-linux/include/MTA/TCT.h +27 -22
- package/SVF-linux/include/MemoryModel/LocationSet.h +5 -3
- package/SVF-linux/include/MemoryModel/PersistentPointsToCache.h +28 -13
- package/SVF-linux/include/MemoryModel/PersistentPointsToDS.h +2 -2
- package/SVF-linux/include/MemoryModel/PointerAnalysis.h +5 -4
- package/SVF-linux/include/MemoryModel/PointsTo.h +8 -2
- package/SVF-linux/include/MemoryModel/SVFIR.h +6 -5
- package/SVF-linux/include/MemoryModel/SVFStatements.h +65 -45
- package/SVF-linux/include/MemoryModel/SVFVariables.h +6 -5
- package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +18 -15
- package/SVF-linux/include/SABER/PathCondAllocator.h +14 -7
- package/SVF-linux/include/SABER/ProgSlice.h +2 -1
- package/SVF-linux/include/SABER/SaberSVFGBuilder.h +1 -1
- package/SVF-linux/include/SABER/SrcSnkDDA.h +8 -4
- package/SVF-linux/include/SVF-FE/CHGBuilder.h +4 -2
- package/SVF-linux/include/SVF-FE/DataFlowUtil.h +10 -9
- package/SVF-linux/include/SVF-FE/IRAnnotator.h +8 -8
- package/SVF-linux/include/SVF-FE/LLVMModule.h +13 -12
- package/SVF-linux/include/SVF-FE/LLVMUtil.h +4 -4
- package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +13 -9
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +3 -2
- package/SVF-linux/include/Util/BDDExpr.h +32 -16
- package/SVF-linux/include/Util/BasicTypes.h +77 -25
- package/SVF-linux/include/Util/CoreBitVector.h +2 -1
- package/SVF-linux/include/Util/CxtStmt.h +37 -27
- package/SVF-linux/include/Util/ExeState.h +42 -22
- package/SVF-linux/include/Util/ExtAPI.h +1 -1
- package/SVF-linux/include/Util/NodeIDAllocator.h +7 -4
- package/SVF-linux/include/Util/Options.h +3 -3
- package/SVF-linux/include/Util/SVFBasicTypes.h +49 -40
- package/SVF-linux/include/Util/SVFModule.h +5 -5
- package/SVF-linux/include/Util/SVFUtil.h +12 -9
- package/SVF-linux/include/Util/Z3Expr.h +191 -144
- package/SVF-linux/include/WPA/Andersen.h +11 -11
- package/SVF-linux/include/WPA/VersionedFlowSensitive.h +4 -1
- package/SVF-osx/Release-build/lib/CUDD/libCudd.a +0 -0
- package/SVF-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/CFL/CFGNormalizer.h +6 -3
- package/SVF-osx/include/CFL/CFLAlias.h +26 -15
- package/SVF-osx/include/CFL/CFLGrammar.h +30 -16
- package/SVF-osx/include/CFL/CFLSolver.h +9 -5
- package/SVF-osx/include/CFL/GrammarBuilder.h +10 -7
- package/SVF-osx/include/CUDD/cudd.h +20 -11
- package/SVF-osx/include/CUDD/cuddInt.h +48 -31
- package/SVF-osx/include/CUDD/epd.h +35 -29
- package/SVF-osx/include/CUDD/mtr.h +4 -3
- package/SVF-osx/include/CUDD/st.h +7 -4
- package/SVF-osx/include/CUDD/util.h +6 -6
- package/SVF-osx/include/FastCluster/fastcluster.h +13 -12
- package/SVF-osx/include/Graphs/CFLGraph.h +16 -10
- package/SVF-osx/include/Graphs/CHG.h +2 -2
- package/SVF-osx/include/Graphs/ConsG.h +2 -1
- package/SVF-osx/include/Graphs/GenericGraph.h +3 -3
- package/SVF-osx/include/Graphs/ICFG.h +2 -2
- package/SVF-osx/include/Graphs/ICFGEdge.h +16 -9
- package/SVF-osx/include/Graphs/ICFGNode.h +2 -2
- package/SVF-osx/include/Graphs/IRGraph.h +10 -6
- package/SVF-osx/include/Graphs/PTACallGraph.h +1 -1
- package/SVF-osx/include/Graphs/SVFG.h +4 -3
- package/SVF-osx/include/Graphs/SVFGNode.h +14 -8
- package/SVF-osx/include/Graphs/ThreadCallGraph.h +4 -2
- package/SVF-osx/include/Graphs/VFG.h +45 -39
- package/SVF-osx/include/Graphs/VFGNode.h +8 -4
- package/SVF-osx/include/MSSA/MemSSA.h +1 -1
- package/SVF-osx/include/MTA/FSMPTA.h +55 -44
- package/SVF-osx/include/MTA/LockAnalysis.h +11 -9
- package/SVF-osx/include/MTA/LockResultValidator.h +64 -54
- package/SVF-osx/include/MTA/MHP.h +17 -13
- package/SVF-osx/include/MTA/MTAResultValidator.h +24 -20
- package/SVF-osx/include/MTA/PCG.h +9 -7
- package/SVF-osx/include/MTA/TCT.h +27 -22
- package/SVF-osx/include/MemoryModel/LocationSet.h +5 -3
- package/SVF-osx/include/MemoryModel/PersistentPointsToCache.h +28 -13
- package/SVF-osx/include/MemoryModel/PersistentPointsToDS.h +2 -2
- package/SVF-osx/include/MemoryModel/PointerAnalysis.h +5 -4
- package/SVF-osx/include/MemoryModel/PointsTo.h +8 -2
- package/SVF-osx/include/MemoryModel/SVFIR.h +6 -5
- package/SVF-osx/include/MemoryModel/SVFStatements.h +65 -45
- package/SVF-osx/include/MemoryModel/SVFVariables.h +6 -5
- package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +18 -15
- package/SVF-osx/include/SABER/PathCondAllocator.h +14 -7
- package/SVF-osx/include/SABER/ProgSlice.h +2 -1
- package/SVF-osx/include/SABER/SaberSVFGBuilder.h +1 -1
- package/SVF-osx/include/SABER/SrcSnkDDA.h +8 -4
- package/SVF-osx/include/SVF-FE/CHGBuilder.h +4 -2
- package/SVF-osx/include/SVF-FE/DataFlowUtil.h +10 -9
- package/SVF-osx/include/SVF-FE/IRAnnotator.h +8 -8
- package/SVF-osx/include/SVF-FE/LLVMModule.h +13 -12
- package/SVF-osx/include/SVF-FE/LLVMUtil.h +4 -4
- package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +13 -9
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +3 -2
- package/SVF-osx/include/Util/BDDExpr.h +32 -16
- package/SVF-osx/include/Util/BasicTypes.h +77 -25
- package/SVF-osx/include/Util/CoreBitVector.h +2 -1
- package/SVF-osx/include/Util/CxtStmt.h +37 -27
- package/SVF-osx/include/Util/ExeState.h +42 -22
- package/SVF-osx/include/Util/ExtAPI.h +1 -1
- package/SVF-osx/include/Util/NodeIDAllocator.h +7 -4
- package/SVF-osx/include/Util/Options.h +3 -3
- package/SVF-osx/include/Util/SVFBasicTypes.h +49 -40
- package/SVF-osx/include/Util/SVFModule.h +5 -5
- package/SVF-osx/include/Util/SVFUtil.h +12 -9
- package/SVF-osx/include/Util/Z3Expr.h +191 -144
- package/SVF-osx/include/WPA/Andersen.h +11 -11
- package/SVF-osx/include/WPA/VersionedFlowSensitive.h +4 -1
- package/package.json +1 -1
|
@@ -74,7 +74,10 @@ public:
|
|
|
74
74
|
NodeID endSymbolAllocation(void);
|
|
75
75
|
|
|
76
76
|
/// Returns the total number of memory objects.
|
|
77
|
-
NodeID getNumObjects(void) const
|
|
77
|
+
NodeID getNumObjects(void) const
|
|
78
|
+
{
|
|
79
|
+
return numObjects;
|
|
80
|
+
}
|
|
78
81
|
|
|
79
82
|
private:
|
|
80
83
|
/// Builds a node ID allocator with the strategy specified on the command line.
|
|
@@ -135,7 +138,7 @@ public:
|
|
|
135
138
|
/// based on the points-to sets in pta accessed through keys.
|
|
136
139
|
/// The second part of the keys pairs are the number of (potential) occurrences of that points-to set
|
|
137
140
|
/// or a subset, depending on the client's wish.
|
|
138
|
-
/// TODO: interfaces are getting unwieldy, an initialised object may be better.
|
|
141
|
+
/// TODO: interfaces are getting unwieldy, an initialised object may be better.
|
|
139
142
|
/// TODO: kind of sucks pta can't be const here because getPts isn't.
|
|
140
143
|
static std::vector<NodeID> cluster(BVDataPTAImpl *pta, const std::vector<std::pair<NodeID, unsigned>> keys, std::vector<std::pair<hclust_fast_methods, std::vector<NodeID>>> &candidates, std::string evalSubtitle="");
|
|
141
144
|
|
|
@@ -180,8 +183,8 @@ public:
|
|
|
180
183
|
|
|
181
184
|
// From all the candidates, returns the best mapping for pointsToSets (points-to set -> # occurences).
|
|
182
185
|
static inline std::pair<hclust_fast_methods, std::vector<NodeID>> determineBestMapping(
|
|
183
|
-
|
|
184
|
-
|
|
186
|
+
const std::vector<std::pair<hclust_fast_methods, std::vector<NodeID>>> &candidates,
|
|
187
|
+
Map<PointsTo, unsigned> pointsToSets, const std::string &evalSubtitle, double &evalTime);
|
|
185
188
|
|
|
186
189
|
};
|
|
187
190
|
};
|
|
@@ -120,7 +120,7 @@ public:
|
|
|
120
120
|
// Sparse value-flow graph (VFG.cpp)
|
|
121
121
|
static const llvm::cl::opt<bool> DumpVFG;
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
// Location set for modeling abstract memory object (LocationSet.cpp)
|
|
124
124
|
static const llvm::cl::opt<bool> SingleStride;
|
|
125
125
|
|
|
126
126
|
// Base class of pointer analyses (PointerAnalysis.cpp)
|
|
@@ -180,8 +180,8 @@ public:
|
|
|
180
180
|
|
|
181
181
|
// MTAResultValidator.cpp
|
|
182
182
|
static const llvm::cl::opt<bool> PrintValidRes;
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
|
|
184
|
+
static const llvm::cl::opt<bool> LockValid;
|
|
185
185
|
//MTAStat.cpp
|
|
186
186
|
static const llvm::cl::opt<bool> AllPairMHP;
|
|
187
187
|
|
|
@@ -55,22 +55,26 @@ namespace SVF
|
|
|
55
55
|
/// provide extra hash function for std::pair handling
|
|
56
56
|
template <class T> struct Hash;
|
|
57
57
|
|
|
58
|
-
template <class S, class T> struct Hash<std::pair<S, T>>
|
|
58
|
+
template <class S, class T> struct Hash<std::pair<S, T>>
|
|
59
|
+
{
|
|
59
60
|
// Pairing function from: http://szudzik.com/ElegantPairing.pdf
|
|
60
61
|
static size_t szudzik(size_t a, size_t b)
|
|
61
62
|
{
|
|
62
63
|
return a > b ? b * b + a : a * a + a + b;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
size_t operator()(const std::pair<S, T> &t) const
|
|
66
|
+
size_t operator()(const std::pair<S, T> &t) const
|
|
67
|
+
{
|
|
66
68
|
Hash<decltype(t.first)> first;
|
|
67
69
|
Hash<decltype(t.second)> second;
|
|
68
70
|
return szudzik(first(t.first), second(t.second));
|
|
69
71
|
}
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
template <class T> struct Hash
|
|
73
|
-
|
|
74
|
+
template <class T> struct Hash
|
|
75
|
+
{
|
|
76
|
+
size_t operator()(const T &t) const
|
|
77
|
+
{
|
|
74
78
|
std::hash<T> h;
|
|
75
79
|
return h(t);
|
|
76
80
|
}
|
|
@@ -97,45 +101,46 @@ typedef PointsTo AliasSet;
|
|
|
97
101
|
typedef unsigned PointsToID;
|
|
98
102
|
|
|
99
103
|
template <typename Key, typename Hash = Hash<Key>, typename KeyEqual = std::equal_to<Key>,
|
|
100
|
-
typename Allocator = std::allocator<Key>>
|
|
104
|
+
typename Allocator = std::allocator<Key>>
|
|
101
105
|
using Set = std::unordered_set<Key, Hash, KeyEqual, Allocator>;
|
|
102
106
|
|
|
103
107
|
template<typename Key, typename Value, typename Hash = Hash<Key>,
|
|
104
|
-
|
|
105
|
-
typename Allocator = std::allocator<std::pair<const Key, Value>>>
|
|
106
|
-
using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
|
|
107
|
-
|
|
108
|
-
template<typename Key, typename Compare = std::less<Key>, typename Allocator = std::allocator<Key>>
|
|
109
|
-
using OrderedSet = std::set<Key, Compare, Allocator>;
|
|
110
|
-
|
|
111
|
-
template<typename Key, typename Value, typename Compare = std::less<Key>,
|
|
108
|
+
typename KeyEqual = std::equal_to<Key>,
|
|
112
109
|
typename Allocator = std::allocator<std::pair<const Key, Value>>>
|
|
113
|
-
using
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
typedef
|
|
123
|
-
typedef std::
|
|
124
|
-
typedef
|
|
125
|
-
typedef
|
|
126
|
-
typedef
|
|
127
|
-
typedef
|
|
128
|
-
typedef
|
|
129
|
-
|
|
130
|
-
typedef
|
|
131
|
-
typedef
|
|
132
|
-
typedef std::
|
|
133
|
-
typedef
|
|
110
|
+
using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
|
|
111
|
+
|
|
112
|
+
template<typename Key, typename Compare = std::less<Key>, typename Allocator = std::allocator<Key>>
|
|
113
|
+
using OrderedSet = std::set<Key, Compare, Allocator>;
|
|
114
|
+
|
|
115
|
+
template<typename Key, typename Value, typename Compare = std::less<Key>,
|
|
116
|
+
typename Allocator = std::allocator<std::pair<const Key, Value>>>
|
|
117
|
+
using OrderedMap = std::map<Key, Value, Compare, Allocator>;
|
|
118
|
+
|
|
119
|
+
typedef llvm::SmallVector<llvm::BasicBlock*, 8> SmallBBVector;
|
|
120
|
+
typedef std::pair<NodeID, NodeID> NodePair;
|
|
121
|
+
typedef OrderedSet<NodeID> OrderedNodeSet;
|
|
122
|
+
typedef Set<NodeID> NodeSet;
|
|
123
|
+
typedef Set<NodePair> NodePairSet;
|
|
124
|
+
typedef Map<NodePair,NodeID> NodePairMap;
|
|
125
|
+
typedef std::vector<NodeID> NodeVector;
|
|
126
|
+
typedef std::vector<EdgeID> EdgeVector;
|
|
127
|
+
typedef std::stack<NodeID> NodeStack;
|
|
128
|
+
typedef std::list<NodeID> NodeList;
|
|
129
|
+
typedef std::deque<NodeID> NodeDeque;
|
|
130
|
+
typedef NodeSet EdgeSet;
|
|
131
|
+
typedef std::vector<u32_t> CallStrCxt;
|
|
132
|
+
typedef llvm::StringMap<u32_t> StringMap;
|
|
133
|
+
|
|
134
|
+
typedef unsigned Version;
|
|
135
|
+
typedef Set<Version> VersionSet;
|
|
136
|
+
typedef std::pair<NodeID, Version> VersionedVar;
|
|
137
|
+
typedef Set<VersionedVar> VersionedVarSet;
|
|
134
138
|
|
|
135
139
|
// TODO: be explicit that this is a pair of 32-bit unsigneds?
|
|
136
|
-
template <> struct Hash<NodePair>
|
|
140
|
+
template <> struct Hash<NodePair>
|
|
137
141
|
{
|
|
138
|
-
size_t operator()(const NodePair &p) const
|
|
142
|
+
size_t operator()(const NodePair &p) const
|
|
143
|
+
{
|
|
139
144
|
// Make sure our assumptions are sound: use u32_t
|
|
140
145
|
// and u64_t. If NodeID is not actually u32_t or size_t
|
|
141
146
|
// is not u64_t we should be fine since we get a
|
|
@@ -278,8 +283,10 @@ public:
|
|
|
278
283
|
} // End namespace SVF
|
|
279
284
|
|
|
280
285
|
|
|
281
|
-
template <> struct std::hash<SVF::NodePair>
|
|
282
|
-
|
|
286
|
+
template <> struct std::hash<SVF::NodePair>
|
|
287
|
+
{
|
|
288
|
+
size_t operator()(const SVF::NodePair &p) const
|
|
289
|
+
{
|
|
283
290
|
// Make sure our assumptions are sound: use u32_t
|
|
284
291
|
// and u64_t. If NodeID is not actually u32_t or size_t
|
|
285
292
|
// is not u64_t we should be fine since we get a
|
|
@@ -294,7 +301,8 @@ template <> struct std::hash<SVF::NodePair> {
|
|
|
294
301
|
template <unsigned N>
|
|
295
302
|
struct std::hash<llvm::SparseBitVector<N>>
|
|
296
303
|
{
|
|
297
|
-
size_t operator()(const llvm::SparseBitVector<N> &sbv) const
|
|
304
|
+
size_t operator()(const llvm::SparseBitVector<N> &sbv) const
|
|
305
|
+
{
|
|
298
306
|
SVF::Hash<std::pair<std::pair<size_t, size_t>, size_t>> h;
|
|
299
307
|
return h(std::make_pair(std::make_pair(sbv.count(), sbv.find_first()), sbv.find_last()));
|
|
300
308
|
}
|
|
@@ -303,7 +311,8 @@ struct std::hash<llvm::SparseBitVector<N>>
|
|
|
303
311
|
template <typename T>
|
|
304
312
|
struct std::hash<std::vector<T>>
|
|
305
313
|
{
|
|
306
|
-
size_t operator()(const std::vector<T> &v) const
|
|
314
|
+
size_t operator()(const std::vector<T> &v) const
|
|
315
|
+
{
|
|
307
316
|
// TODO: repetition with CBV.
|
|
308
317
|
size_t h = v.size();
|
|
309
318
|
|
|
@@ -73,11 +73,11 @@ public:
|
|
|
73
73
|
|
|
74
74
|
~SVFModule()
|
|
75
75
|
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
for (auto * f : FunctionSet)
|
|
77
|
+
delete f;
|
|
78
|
+
NodeIDAllocator::unset();
|
|
79
|
+
ThreadAPI::destroy();
|
|
80
|
+
ExtAPI::destory();
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
static inline void setPagFromTXT(std::string txt)
|
|
@@ -170,8 +170,9 @@ inline bool isIntrinsicFun(const Function* func)
|
|
|
170
170
|
func->getIntrinsicID() == llvm::Intrinsic::dbg_addr ||
|
|
171
171
|
func->getIntrinsicID() == llvm::Intrinsic::dbg_declare ||
|
|
172
172
|
func->getIntrinsicID() == llvm::Intrinsic::dbg_label ||
|
|
173
|
-
func->getIntrinsicID() == llvm::Intrinsic::dbg_value))
|
|
174
|
-
|
|
173
|
+
func->getIntrinsicID() == llvm::Intrinsic::dbg_value))
|
|
174
|
+
{
|
|
175
|
+
return true;
|
|
175
176
|
}
|
|
176
177
|
return false;
|
|
177
178
|
}
|
|
@@ -179,9 +180,11 @@ inline bool isIntrinsicFun(const Function* func)
|
|
|
179
180
|
/// Return true if it is an intrinsic instruction
|
|
180
181
|
inline bool isIntrinsicInst(const Instruction* inst)
|
|
181
182
|
{
|
|
182
|
-
if (const llvm::CallBase* call = llvm::dyn_cast<llvm::CallBase>(inst))
|
|
183
|
+
if (const llvm::CallBase* call = llvm::dyn_cast<llvm::CallBase>(inst))
|
|
184
|
+
{
|
|
183
185
|
const Function* func = call->getCalledFunction();
|
|
184
|
-
if (isIntrinsicFun(func))
|
|
186
|
+
if (isIntrinsicFun(func))
|
|
187
|
+
{
|
|
185
188
|
return true;
|
|
186
189
|
}
|
|
187
190
|
}
|
|
@@ -197,10 +200,10 @@ inline bool isCallSite(const Instruction* inst)
|
|
|
197
200
|
/// Whether an instruction is a call or invoke instruction
|
|
198
201
|
inline bool isCallSite(const Value* val)
|
|
199
202
|
{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(val))
|
|
204
|
+
return SVFUtil::isCallSite(inst);
|
|
205
|
+
else
|
|
206
|
+
return false;
|
|
204
207
|
}
|
|
205
208
|
/// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
|
|
206
209
|
inline bool isNonInstricCallSite(const Instruction* inst)
|
|
@@ -237,7 +240,7 @@ inline const SVFFunction* getFunction(StringRef name)
|
|
|
237
240
|
}
|
|
238
241
|
|
|
239
242
|
/// find the unique defined global across multiple modules
|
|
240
|
-
inline const Value* getGlobalRep(const Value* val)
|
|
243
|
+
inline const Value* getGlobalRep(const Value* val)
|
|
241
244
|
{
|
|
242
245
|
if(const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
|
|
243
246
|
{
|
|
@@ -32,202 +32,249 @@
|
|
|
32
32
|
#include "z3++.h"
|
|
33
33
|
#include "Util/SVFBasicTypes.h"
|
|
34
34
|
|
|
35
|
-
namespace SVF
|
|
35
|
+
namespace SVF
|
|
36
|
+
{
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
class Z3Expr
|
|
39
|
+
{
|
|
40
|
+
public:
|
|
41
|
+
static z3::context *ctx;
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
private:
|
|
44
|
+
z3::expr e;
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
Z3Expr(float f); // placeholder don't support floating point expression
|
|
47
|
+
Z3Expr(double f); // placeholder don't support floating point expression
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
public:
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
Z3Expr() : e(nullExpr())
|
|
52
|
+
{
|
|
53
|
+
}
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
Z3Expr(const z3::expr &_e) : e(_e)
|
|
56
|
+
{
|
|
57
|
+
}
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
Z3Expr(int i) : e(getContext().int_val(i))
|
|
60
|
+
{
|
|
61
|
+
}
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
Z3Expr(const Z3Expr &z3Expr) : e(z3Expr.getExpr())
|
|
64
|
+
{
|
|
65
|
+
}
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
virtual ~Z3Expr() = default;
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
inline Z3Expr &operator=(const Z3Expr &rhs)
|
|
70
|
+
{
|
|
71
|
+
if (this->id() != rhs.id())
|
|
72
|
+
{
|
|
73
|
+
e = rhs.getExpr();
|
|
68
74
|
}
|
|
75
|
+
return *this;
|
|
76
|
+
}
|
|
69
77
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
const z3::expr &getExpr() const
|
|
79
|
+
{
|
|
80
|
+
return e;
|
|
81
|
+
}
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
/// Get z3 context, singleton design here to make sure we only have one context
|
|
84
|
+
static z3::context &getContext()
|
|
85
|
+
{
|
|
86
|
+
if (ctx == nullptr)
|
|
87
|
+
{
|
|
88
|
+
ctx = new z3::context();
|
|
80
89
|
}
|
|
90
|
+
return *ctx;
|
|
91
|
+
}
|
|
81
92
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
/// release z3 context
|
|
94
|
+
static void releaseContext()
|
|
95
|
+
{
|
|
96
|
+
delete ctx;
|
|
97
|
+
ctx = nullptr;
|
|
98
|
+
}
|
|
87
99
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
100
|
+
/// null expression
|
|
101
|
+
static z3::expr nullExpr()
|
|
102
|
+
{
|
|
103
|
+
return getContext().int_const("null");
|
|
104
|
+
}
|
|
92
105
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
/// get id
|
|
107
|
+
inline u32_t id() const
|
|
108
|
+
{
|
|
109
|
+
return e.id();
|
|
110
|
+
}
|
|
97
111
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
inline const std::string to_string() const
|
|
113
|
+
{
|
|
114
|
+
return e.to_string();
|
|
115
|
+
}
|
|
101
116
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
inline bool is_numeral() const
|
|
118
|
+
{
|
|
119
|
+
return e.is_numeral();
|
|
120
|
+
}
|
|
105
121
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
inline bool is_bool() const
|
|
123
|
+
{
|
|
124
|
+
return e.is_bool();
|
|
125
|
+
}
|
|
109
126
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
127
|
+
inline Z3Expr simplify() const
|
|
128
|
+
{
|
|
129
|
+
return e.simplify();
|
|
130
|
+
}
|
|
113
131
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
132
|
+
inline int64_t get_numeral_int64() const
|
|
133
|
+
{
|
|
134
|
+
return e.get_numeral_int64();
|
|
135
|
+
}
|
|
117
136
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
137
|
+
inline int get_numeral_int() const
|
|
138
|
+
{
|
|
139
|
+
return e.get_numeral_int();
|
|
140
|
+
}
|
|
121
141
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
//{% reload operator
|
|
143
|
+
friend Z3Expr operator==(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
144
|
+
{
|
|
145
|
+
return lhs.getExpr() == rhs.getExpr();
|
|
146
|
+
}
|
|
126
147
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
148
|
+
friend Z3Expr operator!=(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
149
|
+
{
|
|
150
|
+
return lhs.getExpr() != rhs.getExpr();
|
|
151
|
+
}
|
|
130
152
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
153
|
+
friend Z3Expr operator>(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
154
|
+
{
|
|
155
|
+
return lhs.getExpr() > rhs.getExpr();
|
|
156
|
+
}
|
|
134
157
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
158
|
+
friend Z3Expr operator<(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
159
|
+
{
|
|
160
|
+
return lhs.getExpr() < rhs.getExpr();
|
|
161
|
+
}
|
|
138
162
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
163
|
+
friend Z3Expr operator<=(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
164
|
+
{
|
|
165
|
+
return lhs.getExpr() <= rhs.getExpr();
|
|
166
|
+
}
|
|
142
167
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
168
|
+
friend Z3Expr operator>=(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
169
|
+
{
|
|
170
|
+
return lhs.getExpr() >= rhs.getExpr();
|
|
171
|
+
}
|
|
146
172
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
173
|
+
friend Z3Expr operator+(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
174
|
+
{
|
|
175
|
+
return lhs.getExpr() + rhs.getExpr();
|
|
176
|
+
}
|
|
150
177
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
178
|
+
friend Z3Expr operator-(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
179
|
+
{
|
|
180
|
+
return lhs.getExpr() - rhs.getExpr();
|
|
181
|
+
}
|
|
154
182
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
183
|
+
friend Z3Expr operator*(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
184
|
+
{
|
|
185
|
+
return lhs.getExpr() * rhs.getExpr();
|
|
186
|
+
}
|
|
158
187
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
188
|
+
friend Z3Expr operator/(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
189
|
+
{
|
|
190
|
+
return lhs.getExpr() / rhs.getExpr();
|
|
191
|
+
}
|
|
162
192
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
193
|
+
friend Z3Expr operator%(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
194
|
+
{
|
|
195
|
+
return lhs.getExpr() % rhs.getExpr();
|
|
196
|
+
}
|
|
166
197
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
198
|
+
friend Z3Expr operator^(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
199
|
+
{
|
|
200
|
+
return lhs.getExpr() ^ rhs.getExpr();
|
|
201
|
+
}
|
|
170
202
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
203
|
+
friend Z3Expr operator&(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
204
|
+
{
|
|
205
|
+
return lhs.getExpr() & rhs.getExpr();
|
|
206
|
+
}
|
|
174
207
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
208
|
+
friend Z3Expr operator|(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
209
|
+
{
|
|
210
|
+
return lhs.getExpr() | rhs.getExpr();
|
|
211
|
+
}
|
|
178
212
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
213
|
+
friend Z3Expr ashr(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
214
|
+
{
|
|
215
|
+
return ashr(lhs.getExpr(), rhs.getExpr());
|
|
216
|
+
}
|
|
182
217
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
218
|
+
friend Z3Expr shl(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
219
|
+
{
|
|
220
|
+
return shl(lhs.getExpr(), rhs.getExpr());
|
|
221
|
+
}
|
|
186
222
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
223
|
+
friend Z3Expr int2bv(u32_t n, const Z3Expr &e)
|
|
224
|
+
{
|
|
225
|
+
return int2bv(n, e.getExpr());
|
|
226
|
+
}
|
|
190
227
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
228
|
+
friend Z3Expr bv2int(const Z3Expr &e, bool isSigned)
|
|
229
|
+
{
|
|
230
|
+
return z3::bv2int(e.getExpr(), isSigned);
|
|
231
|
+
}
|
|
194
232
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
233
|
+
friend Z3Expr operator&&(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
234
|
+
{
|
|
235
|
+
return lhs.getExpr() && rhs.getExpr();
|
|
236
|
+
}
|
|
198
237
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
238
|
+
friend Z3Expr operator||(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
239
|
+
{
|
|
240
|
+
return lhs.getExpr() || rhs.getExpr();
|
|
241
|
+
}
|
|
202
242
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
243
|
+
friend Z3Expr operator!(const Z3Expr &lhs)
|
|
244
|
+
{
|
|
245
|
+
return !lhs.getExpr();
|
|
246
|
+
}
|
|
206
247
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
248
|
+
friend Z3Expr ite(const Z3Expr& cond, const Z3Expr& lhs, const Z3Expr& rhs)
|
|
249
|
+
{
|
|
250
|
+
return ite(cond.getExpr(), lhs.getExpr(), rhs.getExpr());
|
|
251
|
+
}
|
|
210
252
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
253
|
+
friend std::ostream &operator<<(std::ostream &out, const Z3Expr &expr)
|
|
254
|
+
{
|
|
255
|
+
out << expr.getExpr();
|
|
256
|
+
return out;
|
|
257
|
+
}
|
|
215
258
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
259
|
+
friend bool eq(const Z3Expr &lhs, const Z3Expr &rhs)
|
|
260
|
+
{
|
|
261
|
+
return eq(lhs.getExpr(), rhs.getExpr());
|
|
262
|
+
}
|
|
219
263
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
264
|
+
z3::sort get_sort() const
|
|
265
|
+
{
|
|
266
|
+
return getExpr().get_sort();
|
|
267
|
+
}
|
|
268
|
+
//%}
|
|
269
|
+
};
|
|
225
270
|
}
|
|
226
271
|
|
|
227
272
|
/// Specialise hash for AbsCxtDPItem.
|
|
228
273
|
template<>
|
|
229
|
-
struct std::hash<SVF::Z3Expr>
|
|
230
|
-
|
|
274
|
+
struct std::hash<SVF::Z3Expr>
|
|
275
|
+
{
|
|
276
|
+
size_t operator()(const SVF::Z3Expr &z3Expr) const
|
|
277
|
+
{
|
|
231
278
|
return z3Expr.id();
|
|
232
279
|
}
|
|
233
280
|
};
|