Skip to content

Commit c489ae4

Browse files
danpoePetr Bauch
authored and
Petr Bauch
committed
Validate goto models in cbmc (if enabled via command line flag)
1 parent bad06ab commit c489ae4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ int cbmc_parse_optionst::doit()
530530
if(set_properties())
531531
return CPROVER_EXIT_SET_PROPERTIES_FAILED;
532532

533+
if(cmdline.isset("validate-goto-model"))
534+
{
535+
const namespacet ns(goto_model.symbol_table);
536+
goto_model.validate(ns, validation_modet::INVARIANT);
537+
}
538+
533539
return bmct::do_language_agnostic_bmc(
534540
path_strategy_chooser, options, goto_model, ui_message_handler);
535541
}
@@ -977,6 +983,9 @@ void cbmc_parse_optionst::help()
977983
" --xml-ui use XML-formatted output\n"
978984
" --xml-interface bi-directional XML interface\n"
979985
" --json-ui use JSON-formatted output\n"
986+
// NOLINTNEXTLINE(whitespace/line_length)
987+
" --validate-goto-model enable additional well-formedness checks on the\n"
988+
" goto program\n"
980989
HELP_GOTO_TRACE
981990
HELP_FLUSH
982991
" --verbosity # verbosity level\n"

src/cbmc/cbmc_parse_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class optionst;
7373
OPT_FLUSH \
7474
"(localize-faults)(localize-faults-method):" \
7575
OPT_GOTO_TRACE \
76+
"(validate-goto-model)" \
7677
"(claim):(show-claims)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
7778
// clang-format on
7879

src/goto-programs/initialize_goto_model.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ goto_modelt initialize_goto_model(
165165
goto_model.goto_functions,
166166
message_handler);
167167

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

0 commit comments

Comments
 (0)