18
18
19
19
#include < analyses/ai.h>
20
20
21
+ // clang-format off
22
+ enum class statust { TRUE , FALSE , BOTTOM, UNKNOWN };
23
+ // clang-format on
24
+
25
+ // / Makes a status message string from a status.
26
+ static const char *message (const statust &status)
27
+ {
28
+ switch (status)
29
+ {
30
+ case statust::TRUE :
31
+ return " SUCCESS" ;
32
+ case statust::FALSE :
33
+ return " FAILURE (if reachable)" ;
34
+ case statust::BOTTOM:
35
+ return " SUCCESS (unreachable)" ;
36
+ case statust::UNKNOWN:
37
+ return " UNKNOWN" ;
38
+ }
39
+ UNREACHABLE;
40
+ }
41
+
21
42
struct static_verifier_resultt
22
43
{
23
- // clang-format off
24
- enum statust { TRUE , FALSE , BOTTOM, UNKNOWN } status;
25
- // clang-format on
44
+ statust status;
26
45
source_locationt source_location;
27
46
irep_idt function_id;
28
47
};
29
48
30
- static static_verifier_resultt:: statust
49
+ static statust
31
50
check_assertion (const ai_domain_baset &domain, exprt e, const namespacet &ns)
32
51
{
33
52
if (domain.is_bottom ())
34
53
{
35
- return static_verifier_resultt ::BOTTOM;
54
+ return statust ::BOTTOM;
36
55
}
37
56
38
57
domain.ai_simplify (e, ns);
39
58
if (e.is_true ())
40
59
{
41
- return static_verifier_resultt ::TRUE ;
60
+ return statust ::TRUE ;
42
61
}
43
62
else if (e.is_false ())
44
63
{
45
- return static_verifier_resultt ::FALSE ;
64
+ return statust ::FALSE ;
46
65
}
47
66
else
48
67
{
49
- return static_verifier_resultt ::UNKNOWN;
68
+ return statust ::UNKNOWN;
50
69
}
51
70
52
71
UNREACHABLE;
@@ -72,7 +91,7 @@ static static_verifier_resultt check_assertion(
72
91
73
92
if (trace_set.size () == 0 ) // i.e. unreachable
74
93
{
75
- result.status = static_verifier_resultt ::BOTTOM;
94
+ result.status = statust ::BOTTOM;
76
95
}
77
96
else if (trace_set.size () == 1 )
78
97
{
@@ -95,16 +114,16 @@ static static_verifier_resultt check_assertion(
95
114
result.status = check_assertion (*dp, e, ns);
96
115
switch (result.status )
97
116
{
98
- case static_verifier_resultt ::BOTTOM:
117
+ case statust ::BOTTOM:
99
118
++unreachable_traces;
100
119
break ;
101
- case static_verifier_resultt ::TRUE :
120
+ case statust ::TRUE :
102
121
++true_traces;
103
122
break ;
104
- case static_verifier_resultt ::FALSE :
123
+ case statust ::FALSE :
105
124
++false_traces;
106
125
break ;
107
- case static_verifier_resultt ::UNKNOWN:
126
+ case statust ::UNKNOWN:
108
127
++unknown_traces;
109
128
break ;
110
129
default :
@@ -116,7 +135,7 @@ static static_verifier_resultt check_assertion(
116
135
if (unknown_traces != 0 )
117
136
{
118
137
// If any trace is unknown, the final result must be unknown
119
- result.status = static_verifier_resultt ::UNKNOWN;
138
+ result.status = statust ::UNKNOWN;
120
139
}
121
140
else
122
141
{
@@ -129,13 +148,13 @@ static static_verifier_resultt check_assertion(
129
148
INVARIANT (
130
149
unreachable_traces == trace_set.size (),
131
150
" All traces must not reach the assertion" );
132
- result.status = static_verifier_resultt ::BOTTOM;
151
+ result.status = statust ::BOTTOM;
133
152
}
134
153
else
135
154
{
136
155
// At least one trace (may) reach it.
137
156
// All traces that reach it are safe.
138
- result.status = static_verifier_resultt ::TRUE ;
157
+ result.status = statust ::TRUE ;
139
158
}
140
159
}
141
160
else
@@ -144,7 +163,7 @@ static static_verifier_resultt check_assertion(
144
163
if (true_traces == 0 )
145
164
{
146
165
// All traces that (may) reach it are false
147
- result.status = static_verifier_resultt ::FALSE ;
166
+ result.status = statust ::FALSE ;
148
167
}
149
168
else
150
169
{
@@ -156,7 +175,7 @@ static static_verifier_resultt check_assertion(
156
175
// Given that all results of FAILURE from this analysis are
157
176
// caveated with some reachability questions, the following is not
158
177
// entirely unreasonable.
159
- result.status = static_verifier_resultt ::FALSE ;
178
+ result.status = statust ::FALSE ;
160
179
}
161
180
}
162
181
}
@@ -185,20 +204,20 @@ void static_verifier(
185
204
186
205
switch (result.status )
187
206
{
188
- case static_verifier_resultt ::TRUE :
207
+ case statust ::TRUE :
189
208
// if the condition simplifies to true the assertion always succeeds
190
209
property_status = property_statust::PASS;
191
210
break ;
192
- case static_verifier_resultt ::FALSE :
211
+ case statust ::FALSE :
193
212
// if the condition simplifies to false the assertion always fails
194
213
property_status = property_statust::FAIL;
195
214
break ;
196
- case static_verifier_resultt ::BOTTOM:
215
+ case statust ::BOTTOM:
197
216
// if the domain state is bottom then the assertion is definitely
198
217
// unreachable
199
218
property_status = property_statust::NOT_REACHABLE;
200
219
break ;
201
- case static_verifier_resultt ::UNKNOWN:
220
+ case statust ::UNKNOWN:
202
221
// if the condition isn't definitely true, false or unreachable
203
222
// we don't know whether or not it may fail
204
223
property_status = property_statust::UNKNOWN;
@@ -209,23 +228,6 @@ void static_verifier(
209
228
}
210
229
}
211
230
212
- // / Makes a status message string from a status.
213
- static const char *message (const static_verifier_resultt::statust &status)
214
- {
215
- switch (status)
216
- {
217
- case static_verifier_resultt::TRUE :
218
- return " SUCCESS" ;
219
- case static_verifier_resultt::FALSE :
220
- return " FAILURE (if reachable)" ;
221
- case static_verifier_resultt::BOTTOM:
222
- return " SUCCESS (unreachable)" ;
223
- case static_verifier_resultt::UNKNOWN:
224
- return " UNKNOWN" ;
225
- }
226
- UNREACHABLE;
227
- }
228
-
229
231
static void static_verifier_json (
230
232
const std::vector<static_verifier_resultt> &results,
231
233
messaget &m,
@@ -339,19 +341,19 @@ static void static_verifier_console(
339
341
340
342
switch (result.status )
341
343
{
342
- case static_verifier_resultt ::TRUE :
344
+ case statust ::TRUE :
343
345
m.result () << m.green << " SUCCESS" << m.reset ;
344
346
break ;
345
347
346
- case static_verifier_resultt ::FALSE :
348
+ case statust ::FALSE :
347
349
m.result () << m.red << " FAILURE" << m.reset << " (if reachable)" ;
348
350
break ;
349
351
350
- case static_verifier_resultt ::BOTTOM:
352
+ case statust ::BOTTOM:
351
353
m.result () << m.green << " SUCCESS" << m.reset << " (unreachable)" ;
352
354
break ;
353
355
354
- case static_verifier_resultt ::UNKNOWN:
356
+ case statust ::UNKNOWN:
355
357
m.result () << m.yellow << " UNKNOWN" << m.reset ;
356
358
break ;
357
359
}
@@ -404,16 +406,16 @@ bool static_verifier(
404
406
405
407
switch (results.back ().status )
406
408
{
407
- case static_verifier_resultt ::BOTTOM:
409
+ case statust ::BOTTOM:
408
410
++pass;
409
411
break ;
410
- case static_verifier_resultt ::TRUE :
412
+ case statust ::TRUE :
411
413
++pass;
412
414
break ;
413
- case static_verifier_resultt ::FALSE :
415
+ case statust ::FALSE :
414
416
++fail;
415
417
break ;
416
- case static_verifier_resultt ::UNKNOWN:
418
+ case statust ::UNKNOWN:
417
419
++unknown;
418
420
break ;
419
421
default :
0 commit comments