Skip to content

Commit 29b76b4

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 97b4e52 commit 29b76b4

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/goto-instrument/goto_instrument_parse_options.cpp

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

126126
get_goto_program();
127127

128+
{
129+
const bool b = cmdline.isset("validate-goto-binary");
130+
131+
if(b || cmdline.isset("validate-goto-model"))
132+
{
133+
const namespacet ns(goto_model.symbol_table);
134+
goto_model.validate(ns, validation_modet::EXCEPTION);
135+
136+
if(b)
137+
{
138+
return CPROVER_EXIT_SUCCESS;
139+
}
140+
}
141+
}
142+
128143
instrument_goto_program();
129144

145+
if(cmdline.isset("validate-goto-model"))
146+
{
147+
const namespacet ns(goto_model.symbol_table);
148+
goto_model.validate(ns, validation_modet::INVARIANT);
149+
}
150+
130151
{
131152
bool unwind_given=cmdline.isset("unwind");
132153
bool unwindset_given=cmdline.isset("unwindset");
@@ -1569,6 +1590,12 @@ void goto_instrument_parse_optionst::help()
15691590
" --show-local-safe-pointers show pointer expressions that are trivially dominated by a not-null check\n" // NOLINT(*)
15701591
" --show-safe-dereferences show pointer expressions that are trivially dominated by a not-null check\n" // NOLINT(*)
15711592
" *and* used as a dereference operand\n" // NOLINT(*)
1593+
// NOLINTNEXTLINE(whitespace/line_length)
1594+
" --validate-goto-model enable additional well-formedness checks on the\n"
1595+
" goto program\n"
1596+
// NOLINTNEXTLINE(whitespace/line_length)
1597+
" --validate-goto-binary check the well-formedness of the passed in goto\n"
1598+
" binary and then exit\n"
15721599
"\n"
15731600
"Safety checks:\n"
15741601
" --no-assertions ignore user assertions\n"

src/goto-instrument/goto_instrument_parse_options.h

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Author: Daniel Kroening, [email protected]
101101
OPT_GOTO_PROGRAM_STATS \
102102
"(show-local-safe-pointers)(show-safe-dereferences)" \
103103
OPT_REPLACE_CALLS \
104+
"(validate-goto-binary)" \
105+
"(validate-goto-model)" \
104106
// empty last line
105107

106108
// clang-format on

0 commit comments

Comments
 (0)