Skip to content

Commit af3aa4f

Browse files
committed
Validate goto models in goto-instrument (if enabled via command line flags)
There are two flags: --validate-goto-binary reads in a goto binary and checks that it is well formed and then exits; --validate-goto-model enables additional well-formedness checks at various points during the execution of goto-instrument in addition to the normal analyses that it runs.
1 parent 5868fb5 commit af3aa4f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/goto-instrument/goto_instrument_parse_options.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,27 @@ int goto_instrument_parse_optionst::doit()
125125

126126
get_goto_program();
127127

128+
{
129+
const bool validate_only = cmdline.isset("validate-goto-binary");
130+
131+
if(validate_only || cmdline.isset("validate-goto-model"))
132+
{
133+
goto_model.validate(validation_modet::EXCEPTION);
134+
135+
if(validate_only)
136+
{
137+
return CPROVER_EXIT_SUCCESS;
138+
}
139+
}
140+
}
141+
128142
instrument_goto_program();
129143

144+
if(cmdline.isset("validate-goto-model"))
145+
{
146+
goto_model.validate(validation_modet::INVARIANT);
147+
}
148+
130149
{
131150
bool unwind_given=cmdline.isset("unwind");
132151
bool unwindset_given=cmdline.isset("unwindset");
@@ -1572,6 +1591,10 @@ void goto_instrument_parse_optionst::help()
15721591
" --show-local-safe-pointers show pointer expressions that are trivially dominated by a not-null check\n" // NOLINT(*)
15731592
" --show-safe-dereferences show pointer expressions that are trivially dominated by a not-null check\n" // NOLINT(*)
15741593
" *and* used as a dereference operand\n" // NOLINT(*)
1594+
HELP_VALIDATE
1595+
// NOLINTNEXTLINE(whitespace/line_length)
1596+
" --validate-goto-binary check the well-formedness of the passed in goto\n"
1597+
" binary and then exit\n"
15751598
"\n"
15761599
"Safety checks:\n"
15771600
" --no-assertions ignore user assertions\n"

src/goto-instrument/goto_instrument_parse_options.h

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
1515
#include <util/ui_message.h>
1616
#include <util/parse_options.h>
1717
#include <util/timestamper.h>
18+
#include <util/validation_interface.h>
1819

1920
#include <goto-programs/class_hierarchy.h>
2021
#include <goto-programs/goto_functions.h>
@@ -101,6 +102,8 @@ Author: Daniel Kroening, [email protected]
101102
OPT_GOTO_PROGRAM_STATS \
102103
"(show-local-safe-pointers)(show-safe-dereferences)" \
103104
OPT_REPLACE_CALLS \
105+
"(validate-goto-binary)" \
106+
OPT_VALIDATE \
104107
// empty last line
105108

106109
// clang-format on

0 commit comments

Comments
 (0)