svf-lib 1.0.1925 → 1.0.1927
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/bin/ae +0 -0
- package/SVF-linux/Release-build/bin/svf-ex +0 -0
- package/SVF-linux/Release-build/include/AE/Core/AbstractState.h +750 -0
- package/SVF-linux/Release-build/include/AE/Core/AbstractValue.h +514 -39
- package/SVF-linux/Release-build/include/AE/Core/AddressValue.h +32 -25
- package/SVF-linux/Release-build/include/AE/Core/ExeState.h +2 -2
- package/SVF-linux/Release-build/include/AE/Core/IntervalValue.h +9 -24
- package/SVF-linux/Release-build/include/AE/Core/RelationSolver.h +9 -9
- package/SVF-linux/Release-build/include/AE/Svfexe/{AbstractExecution.h → AbstractInterpretation.h} +24 -22
- package/SVF-linux/Release-build/include/AE/Svfexe/BufOverflowChecker.h +5 -5
- package/SVF-linux/Release-build/include/AE/Svfexe/SVFIR2ItvExeState.h +23 -25
- package/SVF-linux/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/bin/ae +0 -0
- package/SVF-osx/Release-build/bin/svf-ex +0 -0
- package/SVF-osx/Release-build/include/AE/Core/AbstractState.h +2 -3
- package/SVF-osx/Release-build/include/AE/Core/IntervalValue.h +1 -0
- package/SVF-osx/Release-build/include/AE/Core/RelExeState.h +1 -1
- package/SVF-osx/Release-build/include/AE/Svfexe/AbstractInterpretation.h +3 -4
- package/SVF-osx/Release-build/include/AE/Svfexe/ICFGSimplification.h +1 -2
- package/SVF-osx/Release-build/include/AE/Svfexe/{SVFIR2ItvExeState.h → SVFIR2AbsState.h} +8 -9
- package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
- package/package.json +1 -1
- package/SVF-linux/Release-build/include/AE/Core/IntervalExeState.h +0 -650
- package/SVF-osx/Release-build/include/AE/Core/ConsExeState.h +0 -453
- package/SVF-osx/Release-build/include/AE/Core/ExeState.h +0 -304
- package/SVF-osx/Release-build/include/AE/Core/SingleAbsValue.h +0 -477
- package/SVF-osx/Release-build/include/AE/Core/SymState.h +0 -221
- package/SVF-osx/Release-build/include/AE/Svfexe/SVFIR2ConsExeState.h +0 -148
|
@@ -1,477 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Created by Xiao and Jiawei on 2023/5/29.
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
#ifndef SVF_SINGLEABSVALUE_H
|
|
6
|
-
#define SVF_SINGLEABSVALUE_H
|
|
7
|
-
|
|
8
|
-
#include "AE/Core/BoundedZ3Expr.h"
|
|
9
|
-
|
|
10
|
-
namespace SVF
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
/*!
|
|
14
|
-
* Atom Z3 expr for constant execution state
|
|
15
|
-
*/
|
|
16
|
-
class SingleAbsValue : public BoundedZ3Expr
|
|
17
|
-
{
|
|
18
|
-
public:
|
|
19
|
-
|
|
20
|
-
SingleAbsValue() = default;
|
|
21
|
-
|
|
22
|
-
SingleAbsValue(const Z3Expr &z3Expr) : BoundedZ3Expr(z3Expr.getExpr()) {}
|
|
23
|
-
|
|
24
|
-
SingleAbsValue(const BoundedZ3Expr &z3Bound) : BoundedZ3Expr(z3Bound) {}
|
|
25
|
-
|
|
26
|
-
SingleAbsValue(const z3::expr &e) : BoundedZ3Expr(e) {}
|
|
27
|
-
|
|
28
|
-
SingleAbsValue(s32_t i) : BoundedZ3Expr(i) {}
|
|
29
|
-
|
|
30
|
-
SingleAbsValue(const SingleAbsValue &_z3Expr) : BoundedZ3Expr(_z3Expr) {}
|
|
31
|
-
|
|
32
|
-
inline SingleAbsValue &operator=(const SingleAbsValue &rhs)
|
|
33
|
-
{
|
|
34
|
-
BoundedZ3Expr::operator=(rhs);
|
|
35
|
-
return *this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
SingleAbsValue(SingleAbsValue &&_z3Expr) : BoundedZ3Expr(_z3Expr)
|
|
39
|
-
{
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
inline SingleAbsValue &operator=(SingleAbsValue &&rhs)
|
|
43
|
-
{
|
|
44
|
-
BoundedZ3Expr::operator=(rhs);
|
|
45
|
-
return *this;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static z3::context &getContext()
|
|
49
|
-
{
|
|
50
|
-
return BoundedZ3Expr::getContext();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static SingleAbsValue topConstant()
|
|
54
|
-
{
|
|
55
|
-
return getContext().int_const("⊤");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static SingleAbsValue bottomConstant()
|
|
59
|
-
{
|
|
60
|
-
return getContext().int_const("⊥");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
void join_with(const SingleAbsValue& other)
|
|
64
|
-
{
|
|
65
|
-
if (this->isBottom())
|
|
66
|
-
{
|
|
67
|
-
if (other.isBottom())
|
|
68
|
-
{
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
else
|
|
72
|
-
{
|
|
73
|
-
*this = other;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else if (other.isBottom())
|
|
77
|
-
{
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
else
|
|
81
|
-
{
|
|
82
|
-
if (!eq(*this, other))
|
|
83
|
-
{
|
|
84
|
-
set_to_top();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
void set_to_top()
|
|
90
|
-
{
|
|
91
|
-
*this = topConstant();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static bool isTopAbsValue(const SingleAbsValue &expr)
|
|
95
|
-
{
|
|
96
|
-
return eq(expr, topConstant());
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static bool isBottomAbsValue(const SingleAbsValue &expr)
|
|
100
|
-
{
|
|
101
|
-
return eq(expr, bottomConstant());
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
inline bool isBottom() const
|
|
105
|
-
{
|
|
106
|
-
return isBottomAbsValue(*this);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
inline bool isTop() const
|
|
110
|
-
{
|
|
111
|
-
return isTopAbsValue(*this);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
inline bool isSym() const
|
|
115
|
-
{
|
|
116
|
-
return isSymbolAbsValue(*this);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
static bool isSymbolAbsValue(const SingleAbsValue &expr)
|
|
120
|
-
{
|
|
121
|
-
return !eq(expr, topConstant()) && !eq(expr, bottomConstant()) && !expr.is_numeral();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/// Less then or equal
|
|
125
|
-
bool leq(const SingleAbsValue &rhs) const
|
|
126
|
-
{
|
|
127
|
-
assert(is_numeral() && rhs.is_numeral());
|
|
128
|
-
return (getExpr() <= rhs.getExpr()).simplify().is_true();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Greater than or equal
|
|
132
|
-
bool geq(const SingleAbsValue &rhs) const
|
|
133
|
-
{
|
|
134
|
-
assert(is_numeral() && rhs.is_numeral());
|
|
135
|
-
return (getExpr() >= rhs.getExpr()).simplify().is_true();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/// Reload operator
|
|
140
|
-
//{%
|
|
141
|
-
friend SingleAbsValue operator==(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
142
|
-
{
|
|
143
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
144
|
-
{
|
|
145
|
-
return bottomConstant();
|
|
146
|
-
}
|
|
147
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
148
|
-
{
|
|
149
|
-
return topConstant();
|
|
150
|
-
}
|
|
151
|
-
else
|
|
152
|
-
{
|
|
153
|
-
return static_cast<BoundedZ3Expr>(lhs) == static_cast<BoundedZ3Expr>(rhs);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
friend SingleAbsValue operator!=(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
158
|
-
{
|
|
159
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
160
|
-
{
|
|
161
|
-
return bottomConstant();
|
|
162
|
-
}
|
|
163
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
164
|
-
return topConstant();
|
|
165
|
-
else
|
|
166
|
-
return static_cast<BoundedZ3Expr>(lhs) != static_cast<BoundedZ3Expr>(rhs);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
friend SingleAbsValue operator>(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
170
|
-
{
|
|
171
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
172
|
-
{
|
|
173
|
-
return bottomConstant();
|
|
174
|
-
}
|
|
175
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
176
|
-
return topConstant();
|
|
177
|
-
else
|
|
178
|
-
return static_cast<BoundedZ3Expr>(lhs) > static_cast<BoundedZ3Expr>(rhs);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
friend SingleAbsValue operator<(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
182
|
-
{
|
|
183
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
184
|
-
{
|
|
185
|
-
return bottomConstant();
|
|
186
|
-
}
|
|
187
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
188
|
-
return topConstant();
|
|
189
|
-
else
|
|
190
|
-
return static_cast<BoundedZ3Expr>(lhs) < static_cast<BoundedZ3Expr>(rhs);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
friend SingleAbsValue operator<=(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
194
|
-
{
|
|
195
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
196
|
-
{
|
|
197
|
-
return bottomConstant();
|
|
198
|
-
}
|
|
199
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
200
|
-
return topConstant();
|
|
201
|
-
else
|
|
202
|
-
return static_cast<BoundedZ3Expr>(lhs) <= static_cast<BoundedZ3Expr>(rhs);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
friend SingleAbsValue operator>=(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
206
|
-
{
|
|
207
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
208
|
-
{
|
|
209
|
-
return bottomConstant();
|
|
210
|
-
}
|
|
211
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
212
|
-
return topConstant();
|
|
213
|
-
else
|
|
214
|
-
return static_cast<BoundedZ3Expr>(lhs) >= static_cast<BoundedZ3Expr>(rhs);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
friend SingleAbsValue operator+(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
218
|
-
{
|
|
219
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
220
|
-
{
|
|
221
|
-
return bottomConstant();
|
|
222
|
-
}
|
|
223
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
224
|
-
return topConstant();
|
|
225
|
-
else
|
|
226
|
-
return static_cast<BoundedZ3Expr>(lhs) + static_cast<BoundedZ3Expr>(rhs);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
friend SingleAbsValue operator-(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
230
|
-
{
|
|
231
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
232
|
-
{
|
|
233
|
-
return bottomConstant();
|
|
234
|
-
}
|
|
235
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
236
|
-
return topConstant();
|
|
237
|
-
else
|
|
238
|
-
return static_cast<BoundedZ3Expr>(lhs) - static_cast<BoundedZ3Expr>(rhs);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
friend SingleAbsValue operator*(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
242
|
-
{
|
|
243
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
244
|
-
{
|
|
245
|
-
return bottomConstant();
|
|
246
|
-
}
|
|
247
|
-
else if (isZero(lhs) || isZero(rhs))
|
|
248
|
-
return 0;
|
|
249
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
250
|
-
return topConstant();
|
|
251
|
-
else
|
|
252
|
-
return static_cast<BoundedZ3Expr>(lhs) * static_cast<BoundedZ3Expr>(rhs);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
friend SingleAbsValue operator/(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
256
|
-
{
|
|
257
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs) || isZero(rhs))
|
|
258
|
-
{
|
|
259
|
-
return bottomConstant();
|
|
260
|
-
}
|
|
261
|
-
else if (isZero(lhs))
|
|
262
|
-
return 0;
|
|
263
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
264
|
-
return topConstant();
|
|
265
|
-
else
|
|
266
|
-
return static_cast<BoundedZ3Expr>(lhs) / static_cast<BoundedZ3Expr>(rhs);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
friend SingleAbsValue operator%(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
270
|
-
{
|
|
271
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs) || isZero(rhs))
|
|
272
|
-
{
|
|
273
|
-
return bottomConstant();
|
|
274
|
-
}
|
|
275
|
-
else if (isZero(lhs))
|
|
276
|
-
return 0;
|
|
277
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
278
|
-
return topConstant();
|
|
279
|
-
else
|
|
280
|
-
return static_cast<BoundedZ3Expr>(lhs) % static_cast<BoundedZ3Expr>(rhs);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
friend SingleAbsValue operator^(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
284
|
-
{
|
|
285
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
286
|
-
return bottomConstant();
|
|
287
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
288
|
-
return topConstant();
|
|
289
|
-
else
|
|
290
|
-
return static_cast<BoundedZ3Expr>(lhs) ^ static_cast<BoundedZ3Expr>(rhs);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
friend SingleAbsValue operator&(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
294
|
-
{
|
|
295
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
296
|
-
{
|
|
297
|
-
return bottomConstant();
|
|
298
|
-
}
|
|
299
|
-
else if (isZero(lhs) || isZero(rhs))
|
|
300
|
-
return 0;
|
|
301
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
302
|
-
return topConstant();
|
|
303
|
-
else
|
|
304
|
-
return static_cast<BoundedZ3Expr>(lhs) & static_cast<BoundedZ3Expr>(rhs);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
friend SingleAbsValue operator|(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
308
|
-
{
|
|
309
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
310
|
-
{
|
|
311
|
-
return bottomConstant();
|
|
312
|
-
}
|
|
313
|
-
else if ((lhs.is_numeral() && eq(lhs, -1)) ||
|
|
314
|
-
(rhs.is_numeral() && eq(rhs, -1)))
|
|
315
|
-
return -1;
|
|
316
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
317
|
-
return topConstant();
|
|
318
|
-
else
|
|
319
|
-
return static_cast<BoundedZ3Expr>(lhs) | static_cast<BoundedZ3Expr>(rhs);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
friend SingleAbsValue ashr(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
323
|
-
{
|
|
324
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs) || (rhs.is_numeral() && !rhs.geq(0)))
|
|
325
|
-
return bottomConstant();
|
|
326
|
-
else if (isZero(lhs))
|
|
327
|
-
return 0;
|
|
328
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
329
|
-
return topConstant();
|
|
330
|
-
else
|
|
331
|
-
return ashr(static_cast<BoundedZ3Expr>(lhs), static_cast<BoundedZ3Expr>(rhs));
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
friend SingleAbsValue shl(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
335
|
-
{
|
|
336
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs) || (rhs.is_numeral() && !rhs.geq(0)))
|
|
337
|
-
return bottomConstant();
|
|
338
|
-
else if (isZero(lhs))
|
|
339
|
-
return 0;
|
|
340
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
341
|
-
return topConstant();
|
|
342
|
-
else
|
|
343
|
-
return shl(static_cast<BoundedZ3Expr>(lhs), static_cast<BoundedZ3Expr>(rhs));
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
friend SingleAbsValue lshr(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
347
|
-
{
|
|
348
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs) || (rhs.is_numeral() && !rhs.geq(0)))
|
|
349
|
-
return bottomConstant();
|
|
350
|
-
else if (isZero(lhs))
|
|
351
|
-
return 0;
|
|
352
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
353
|
-
return topConstant();
|
|
354
|
-
else
|
|
355
|
-
return lshr(static_cast<BoundedZ3Expr>(lhs), static_cast<BoundedZ3Expr>(rhs));
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
friend SingleAbsValue int2bv(u32_t n, const SingleAbsValue &e)
|
|
359
|
-
{
|
|
360
|
-
if (isBottomAbsValue(e))
|
|
361
|
-
{
|
|
362
|
-
return bottomConstant();
|
|
363
|
-
}
|
|
364
|
-
else if (isTopAbsValue(e))
|
|
365
|
-
return topConstant();
|
|
366
|
-
else
|
|
367
|
-
return int2bv(n, static_cast<BoundedZ3Expr>(e));
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
friend SingleAbsValue bv2int(const SingleAbsValue &e, bool isSigned)
|
|
371
|
-
{
|
|
372
|
-
if (isBottomAbsValue(e))
|
|
373
|
-
{
|
|
374
|
-
return bottomConstant();
|
|
375
|
-
}
|
|
376
|
-
else if (isTopAbsValue(e))
|
|
377
|
-
return topConstant();
|
|
378
|
-
else
|
|
379
|
-
return bv2int(static_cast<BoundedZ3Expr>(e), isSigned);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
friend SingleAbsValue operator&&(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
383
|
-
{
|
|
384
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
385
|
-
{
|
|
386
|
-
return bottomConstant();
|
|
387
|
-
}
|
|
388
|
-
else if (eq(lhs, getContext().bool_val(false)) || eq(rhs, getContext().bool_val(false)))
|
|
389
|
-
return getContext().bool_val(false);
|
|
390
|
-
else if (eq(lhs, getContext().bool_val(true)))
|
|
391
|
-
return rhs;
|
|
392
|
-
else if (eq(rhs, getContext().bool_val(true)))
|
|
393
|
-
return lhs;
|
|
394
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
395
|
-
return topConstant();
|
|
396
|
-
else
|
|
397
|
-
return static_cast<BoundedZ3Expr>(lhs) && static_cast<BoundedZ3Expr>(rhs);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
friend SingleAbsValue operator||(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
401
|
-
{
|
|
402
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs))
|
|
403
|
-
{
|
|
404
|
-
return bottomConstant();
|
|
405
|
-
}
|
|
406
|
-
else if (eq(lhs, getContext().bool_val(true)) || eq(rhs, getContext().bool_val(true)))
|
|
407
|
-
return getContext().bool_val(true);
|
|
408
|
-
else if (eq(lhs, getContext().bool_val(false)))
|
|
409
|
-
return rhs;
|
|
410
|
-
else if (eq(rhs, getContext().bool_val(false)))
|
|
411
|
-
return lhs;
|
|
412
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs))
|
|
413
|
-
return topConstant();
|
|
414
|
-
else
|
|
415
|
-
return static_cast<BoundedZ3Expr>(lhs) || static_cast<BoundedZ3Expr>(rhs);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
friend SingleAbsValue operator!(const SingleAbsValue &lhs)
|
|
419
|
-
{
|
|
420
|
-
if (isBottomAbsValue(lhs))
|
|
421
|
-
{
|
|
422
|
-
return bottomConstant();
|
|
423
|
-
}
|
|
424
|
-
else if (isTopAbsValue(lhs))
|
|
425
|
-
return topConstant();
|
|
426
|
-
else
|
|
427
|
-
return !static_cast<BoundedZ3Expr>(lhs);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
friend SingleAbsValue ite(const SingleAbsValue &cond, const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
431
|
-
{
|
|
432
|
-
if (isBottomAbsValue(lhs) || isBottomAbsValue(rhs) || isBottomAbsValue(cond))
|
|
433
|
-
{
|
|
434
|
-
return bottomConstant();
|
|
435
|
-
}
|
|
436
|
-
else if (eq(cond, getContext().bool_val(true)))
|
|
437
|
-
return lhs;
|
|
438
|
-
else if (eq(cond, getContext().bool_val(false)))
|
|
439
|
-
return rhs;
|
|
440
|
-
else if (isTopAbsValue(lhs) || isTopAbsValue(rhs) || isTopAbsValue(cond))
|
|
441
|
-
return topConstant();
|
|
442
|
-
else
|
|
443
|
-
return ite(static_cast<BoundedZ3Expr>(cond), static_cast<BoundedZ3Expr>(lhs),
|
|
444
|
-
static_cast<BoundedZ3Expr>(rhs));
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
friend std::ostream &operator<<(std::ostream &out, const SingleAbsValue &expr)
|
|
448
|
-
{
|
|
449
|
-
out << static_cast<BoundedZ3Expr>(expr);
|
|
450
|
-
return out;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
friend bool eq(const SingleAbsValue &lhs, const SingleAbsValue &rhs)
|
|
454
|
-
{
|
|
455
|
-
return eq(static_cast<BoundedZ3Expr>(lhs), static_cast<BoundedZ3Expr>(rhs));
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
inline SingleAbsValue simplify() const
|
|
459
|
-
{
|
|
460
|
-
return getExpr().simplify();
|
|
461
|
-
}
|
|
462
|
-
//%}
|
|
463
|
-
}; // end class ConZ3Expr
|
|
464
|
-
} // end namespace SVF
|
|
465
|
-
|
|
466
|
-
/// Specialise hash for ConZ3Expr
|
|
467
|
-
template<>
|
|
468
|
-
struct std::hash<SVF::SingleAbsValue>
|
|
469
|
-
{
|
|
470
|
-
size_t operator()(const SVF::SingleAbsValue &z3Expr) const
|
|
471
|
-
{
|
|
472
|
-
return z3Expr.hash();
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
#endif //SVF_SINGLEABSVALUE_H
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
//===- SymState.h ----Symbolic State-------------------------//
|
|
2
|
-
//
|
|
3
|
-
// SVF: Static Value-Flow Analysis
|
|
4
|
-
//
|
|
5
|
-
// Copyright (C) <2013-2022> <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
|
-
// Created by jiawei and xiao on 6/1/23.
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
#ifndef SVF_SYMSTATE_H
|
|
28
|
-
#define SVF_SYMSTATE_H
|
|
29
|
-
|
|
30
|
-
#include "AE/Core/ConsExeState.h"
|
|
31
|
-
|
|
32
|
-
namespace SVF
|
|
33
|
-
{
|
|
34
|
-
/*!
|
|
35
|
-
* Symbolic state
|
|
36
|
-
*
|
|
37
|
-
* Execution State + Type State
|
|
38
|
-
*/
|
|
39
|
-
class SymState
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
public:
|
|
43
|
-
typedef std::string TypeState;
|
|
44
|
-
typedef std::vector<u32_t> KeyNodes;
|
|
45
|
-
typedef Set<KeyNodes> KeyNodesSet;
|
|
46
|
-
|
|
47
|
-
private:
|
|
48
|
-
ConsExeState _exeState; ///< Execution state: values of variables
|
|
49
|
-
TypeState _typeState; ///< Type state: FSM node
|
|
50
|
-
|
|
51
|
-
private:
|
|
52
|
-
/// Only for bug report
|
|
53
|
-
KeyNodesSet _keyNodesSet; ///< The nodes where abstract state changes
|
|
54
|
-
Z3Expr _branchCondition; ///< The branches current state passes
|
|
55
|
-
|
|
56
|
-
public:
|
|
57
|
-
/// Constructor
|
|
58
|
-
SymState() : _exeState(ConsExeState::nullExeState()), _typeState("") {}
|
|
59
|
-
|
|
60
|
-
/// Constructor
|
|
61
|
-
SymState(ConsExeState _es, TypeState _as);
|
|
62
|
-
|
|
63
|
-
/// Destructor
|
|
64
|
-
virtual ~SymState() = default;
|
|
65
|
-
|
|
66
|
-
/// Copy Constructor
|
|
67
|
-
SymState(const SymState &rhs) : _exeState(rhs._exeState), _typeState(rhs._typeState), _keyNodesSet(rhs._keyNodesSet),
|
|
68
|
-
_branchCondition(rhs._branchCondition)
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/// Operator=
|
|
74
|
-
SymState &operator=(const SymState &rhs)
|
|
75
|
-
{
|
|
76
|
-
if (*this != rhs)
|
|
77
|
-
{
|
|
78
|
-
_typeState = rhs._typeState;
|
|
79
|
-
_exeState = rhs._exeState;
|
|
80
|
-
_keyNodesSet = rhs._keyNodesSet;
|
|
81
|
-
_branchCondition = rhs._branchCondition;
|
|
82
|
-
}
|
|
83
|
-
return *this;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/// Move Constructor
|
|
88
|
-
SymState(SymState &&rhs) noexcept: _exeState(SVFUtil::move(rhs._exeState)),
|
|
89
|
-
_typeState(SVFUtil::move(rhs._typeState)),
|
|
90
|
-
_keyNodesSet(SVFUtil::move(rhs._keyNodesSet)),
|
|
91
|
-
_branchCondition(rhs._branchCondition)
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/// Move operator=
|
|
97
|
-
SymState &operator=(SymState &&rhs) noexcept
|
|
98
|
-
{
|
|
99
|
-
if (this != &rhs)
|
|
100
|
-
{
|
|
101
|
-
_typeState = SVFUtil::move(rhs._typeState);
|
|
102
|
-
_exeState = SVFUtil::move(rhs._exeState);
|
|
103
|
-
_keyNodesSet = SVFUtil::move(rhs._keyNodesSet);
|
|
104
|
-
_branchCondition = rhs._branchCondition;
|
|
105
|
-
}
|
|
106
|
-
return *this;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const KeyNodesSet &getKeyNodesSet() const
|
|
110
|
-
{
|
|
111
|
-
return _keyNodesSet;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
void insertKeyNode(NodeID id)
|
|
116
|
-
{
|
|
117
|
-
if (_keyNodesSet.empty())
|
|
118
|
-
{
|
|
119
|
-
_keyNodesSet.insert(KeyNodes{id});
|
|
120
|
-
}
|
|
121
|
-
else
|
|
122
|
-
{
|
|
123
|
-
for (const auto &df: _keyNodesSet)
|
|
124
|
-
{
|
|
125
|
-
const_cast<KeyNodes &>(df).push_back(id);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
void setKeyNodesSet(KeyNodesSet ns)
|
|
131
|
-
{
|
|
132
|
-
_keyNodesSet = SVFUtil::move(ns);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
void clearKeyNodesSet()
|
|
136
|
-
{
|
|
137
|
-
_keyNodesSet.clear();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
inline const Z3Expr &getBranchCondition() const
|
|
141
|
-
{
|
|
142
|
-
return _branchCondition;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
inline void setBranchCondition(const Z3Expr &br)
|
|
146
|
-
{
|
|
147
|
-
_branchCondition = br;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const TypeState &getAbstractState() const
|
|
151
|
-
{
|
|
152
|
-
return _typeState;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
TypeState &getAbstractState()
|
|
156
|
-
{
|
|
157
|
-
return _typeState;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
void setAbsState(const TypeState &absState)
|
|
161
|
-
{
|
|
162
|
-
_typeState = absState;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const ConsExeState &getExecutionState() const
|
|
166
|
-
{
|
|
167
|
-
return _exeState;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
ConsExeState &getExecutionState()
|
|
171
|
-
{
|
|
172
|
-
return _exeState;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/// Overloading Operator==
|
|
176
|
-
inline bool operator==(const SymState &rhs) const
|
|
177
|
-
{
|
|
178
|
-
return _typeState == rhs.getAbstractState() && _exeState == rhs.getExecutionState();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/// Overloading Operator!=
|
|
182
|
-
inline bool operator!=(const SymState &rhs) const
|
|
183
|
-
{
|
|
184
|
-
return !(*this == rhs);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/// Overloading Operator==
|
|
188
|
-
inline bool operator<(const SymState &rhs) const
|
|
189
|
-
{
|
|
190
|
-
if (_typeState != rhs.getAbstractState())
|
|
191
|
-
return _typeState < rhs.getAbstractState();
|
|
192
|
-
if (_exeState != rhs.getExecutionState())
|
|
193
|
-
return _exeState < rhs.getExecutionState();
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
inline bool isNullSymState() const
|
|
198
|
-
{
|
|
199
|
-
return getExecutionState().isNullState() && getAbstractState().empty();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
} // end namespace SVF
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
/// Specialise hash for SymState
|
|
209
|
-
template<>
|
|
210
|
-
struct std::hash<SVF::SymState>
|
|
211
|
-
{
|
|
212
|
-
size_t operator()(const SVF::SymState &symState) const
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
SVF::Hash<std::pair<SVF::SymState::TypeState, SVF::ConsExeState>> pairH;
|
|
216
|
-
|
|
217
|
-
return pairH(make_pair(symState.getAbstractState(), symState.getExecutionState()));
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
#endif // SVF_SYMSTATE_H
|