Skip to content

Commit 37a4de4

Browse files
committed
Validate goto models in cbmc (if enabled via command line flag)
1 parent 68d4dcb commit 37a4de4

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/cbmc/cbmc_parse_options.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,12 @@ int cbmc_parse_optionst::doit()
526526
if(set_properties())
527527
return CPROVER_EXIT_SET_PROPERTIES_FAILED;
528528

529+
if(cmdline.isset("validate-goto-model"))
530+
{
531+
const namespacet ns(goto_model.symbol_table);
532+
goto_model.validate(ns, validation_modet::INVARIANT);
533+
}
534+
529535
return bmct::do_language_agnostic_bmc(
530536
path_strategy_chooser, options, goto_model, ui_message_handler);
531537
}
@@ -972,6 +978,7 @@ void cbmc_parse_optionst::help()
972978
" --xml-ui use XML-formatted output\n"
973979
" --xml-interface bi-directional XML interface\n"
974980
" --json-ui use JSON-formatted output\n"
981+
" --validate-goto-model enables additional well-formedness checks on the goto program\n" // NOLINT(*)
975982
HELP_GOTO_TRACE
976983
HELP_FLUSH
977984
" --verbosity # verbosity level\n"

src/cbmc/cbmc_parse_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class optionst;
7272
OPT_FLUSH \
7373
"(localize-faults)(localize-faults-method):" \
7474
OPT_GOTO_TRACE \
75+
"(validate-goto-model)" \
7576
"(claim):(show-claims)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
7677
// clang-format on
7778

src/goto-programs/initialize_goto_model.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ goto_modelt initialize_goto_model(
166166
goto_model.goto_functions,
167167
message_handler);
168168

169+
if(cmdline.isset("validate-goto-model"))
170+
{
171+
const namespacet ns(goto_model.symbol_table);
172+
goto_model.validate(ns, validation_modet::EXCEPTION);
173+
}
174+
169175
// stupid hack
170176
config.set_object_bits_from_symbol_table(
171177
goto_model.symbol_table);

0 commit comments

Comments
 (0)