|
20 | 20 |
|
21 | 21 | #include <util/invariant.h>
|
22 | 22 | #include <util/namespace.h>
|
23 |
| -#include <util/symbol_table.h> |
24 | 23 | #include <util/source_location.h>
|
25 |
| -#include <util/std_expr.h> |
26 | 24 | #include <util/std_code.h>
|
| 25 | +#include <util/std_expr.h> |
| 26 | +#include <util/symbol_table.h> |
| 27 | + |
| 28 | +enum class validation_modet; |
27 | 29 |
|
28 | 30 | /// The type of an instruction in a GOTO program.
|
29 | 31 | enum goto_program_instruction_typet
|
@@ -398,6 +400,12 @@ class goto_programt
|
398 | 400 | /// only be evaluated in the context of a goto_programt (see
|
399 | 401 | /// goto_programt::equals).
|
400 | 402 | bool equals(const instructiont &other) const;
|
| 403 | + |
| 404 | + /// Check that the instruction is well-formed |
| 405 | + /// |
| 406 | + /// The validation mode indicates whether well-formedness check failures are |
| 407 | + /// reported via DATA_INVARIANT violations or exceptions. |
| 408 | + void validate(const namespacet &ns, const validation_modet vm) const; |
401 | 409 | };
|
402 | 410 |
|
403 | 411 | // Never try to change this to vector-we mutate the list while iterating
|
@@ -677,6 +685,18 @@ class goto_programt
|
677 | 685 | /// the same number of instructions, each pair of instructions compares equal,
|
678 | 686 | /// and relative jumps have the same distance.
|
679 | 687 | bool equals(const goto_programt &other) const;
|
| 688 | + |
| 689 | + /// Check that the goto program is well-formed |
| 690 | + /// |
| 691 | + /// The validation mode indicates whether well-formedness check failures are |
| 692 | + /// reported via DATA_INVARIANT violations or exceptions. |
| 693 | + void validate(const namespacet &ns, const validation_modet vm) const |
| 694 | + { |
| 695 | + for(const instructiont &ins : instructions) |
| 696 | + { |
| 697 | + ins.validate(ns, vm); |
| 698 | + } |
| 699 | + } |
680 | 700 | };
|
681 | 701 |
|
682 | 702 | /// Get control-flow successors of a given instruction. The instruction is
|
|
0 commit comments