Skip to content

Commit 5c4313f

Browse files
danpoePetr Bauch
authored and
Petr Bauch
committed
Add validation methods to codet
1 parent 1d55b7b commit 5c4313f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/util/std_code.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Author: Daniel Kroening, [email protected]
1515
#include "expr.h"
1616
#include "expr_cast.h"
1717
#include "invariant.h"
18+
#include "validate.h"
19+
#include "validate_code.h"
1820

1921
/// Data structure for representing an arbitrary statement in a program. Every
2022
/// specific type of statement (e.g. block of statements, assignment,
@@ -59,6 +61,49 @@ class codet:public exprt
5961
codet &last_statement();
6062
const codet &last_statement() const;
6163
class code_blockt &make_block();
64+
65+
/// Check that the code statement is well-formed (shallow checks only, i.e.,
66+
/// enclosed statements, subexpressions, etc. are not checked)
67+
///
68+
/// Subclasses may override this method to provide specific well-formedness
69+
/// checks for the corresponding types.
70+
///
71+
/// The validation mode indicates whether well-formedness check failures are
72+
/// reported via DATA_INVARIANT violations or exceptions.
73+
void check(const validation_modet vm = validation_modet::INVARIANT) const
74+
{
75+
}
76+
77+
/// Check that the code statement is well-formed, assuming that all its
78+
/// enclosed statements, subexpressions, etc. have all ready been checked for
79+
/// well-formedness.
80+
///
81+
/// Subclasses may override this method to provide specific well-formedness
82+
/// checks for the corresponding types.
83+
///
84+
/// The validation mode indicates whether well-formedness check failures are
85+
/// reported via DATA_INVARIANT violations or exceptions.
86+
void validate(
87+
const namespacet &ns,
88+
const validation_modet vm = validation_modet::INVARIANT) const
89+
{
90+
check_code_pick(*this, vm);
91+
}
92+
93+
/// Check that the code statement is well-formed (full check, including checks
94+
/// of all subexpressions)
95+
///
96+
/// Subclasses may override this method to provide specific well-formedness
97+
/// checks for the corresponding types.
98+
///
99+
/// The validation mode indicates whether well-formedness check failures are
100+
/// reported via DATA_INVARIANT violations or exceptions.
101+
void validate_full(
102+
const namespacet &ns,
103+
const validation_modet vm = validation_modet::INVARIANT) const
104+
{
105+
check_code_pick(*this, vm);
106+
}
62107
};
63108

64109
namespace detail // NOLINT

0 commit comments

Comments
 (0)