File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
invariant-irep-diagnostic Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 12
12
#include < string>
13
13
#include < sstream>
14
14
15
+ #include < util/arith_tools.h>
16
+ #include < util/c_types.h>
15
17
#include < util/invariant.h>
16
18
#include < util/invariant_utils.h>
19
+ #include < util/irep.h>
20
+ #include < util/std_expr.h>
17
21
#include < util/std_types.h>
18
- #include < util/c_types.h>
19
22
20
23
// / An example of structured invariants-- this contains fields to
21
24
// / describe the error to a catcher, and also produces a human-readable
@@ -149,6 +152,13 @@ int main(int argc, char** argv)
149
152
" an invariant with some custom diagnostics" ,
150
153
DiagnosticA{},
151
154
DiagnosticB{});
155
+ else if (arg == " invariant-with-irep-diagnostics" )
156
+ INVARIANT_WITH_DIAGNOSTICS (
157
+ false ,
158
+ " an invariant with irep diagnostics" ,
159
+ irep_pretty_diagnosticst{
160
+ plus_exprt{from_integer (8 , signedbv_typet (32 )),
161
+ from_integer (13 , signedbv_typet (32 ))}});
152
162
else
153
163
return 1 ;
154
164
}
Original file line number Diff line number Diff line change
1
+ CORE
2
+ dummy_parameter.c
3
+ invariant-with-irep-diagnostics
4
+ ^EXIT=(0|127|134|137)$
5
+ ^SIGNAL=0$
6
+ --- begin invariant violation report ---
7
+ Invariant check failed
8
+ value: 00000000000000000000000000001000
9
+ value: 00000000000000000000000000001101
10
+
Original file line number Diff line number Diff line change @@ -463,4 +463,18 @@ struct irep_full_eq
463
463
}
464
464
};
465
465
466
+ struct irep_pretty_diagnosticst
467
+ {
468
+ const irept &irep;
469
+ };
470
+
471
+ template <>
472
+ struct diagnostics_helpert <irep_pretty_diagnosticst>
473
+ {
474
+ static std::string diagnostics_as_string (const irep_pretty_diagnosticst &irep)
475
+ {
476
+ return irep.irep .pretty ();
477
+ }
478
+ };
479
+
466
480
#endif // CPROVER_UTIL_IREP_H
You can’t perform that action at this time.
0 commit comments