Skip to content

Commit dc865f3

Browse files
danpoeSonny Martin
authored and
Sonny Martin
committed
Validate goto models in cbmc (if enabled via command line flag)
1 parent f173e7a commit dc865f3

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
@@ -524,6 +524,12 @@ int cbmc_parse_optionst::doit()
524524
if(set_properties())
525525
return CPROVER_EXIT_SET_PROPERTIES_FAILED;
526526

527+
if(cmdline.isset("validate-goto-model"))
528+
{
529+
const namespacet ns(goto_model.symbol_table);
530+
goto_model.validate(ns, validation_modet::INVARIANT);
531+
}
532+
527533
return bmct::do_language_agnostic_bmc(
528534
path_strategy_chooser, options, goto_model, ui_message_handler);
529535
}
@@ -970,6 +976,9 @@ void cbmc_parse_optionst::help()
970976
" --xml-ui use XML-formatted output\n"
971977
" --xml-interface bi-directional XML interface\n"
972978
" --json-ui use JSON-formatted output\n"
979+
// NOLINTNEXTLINE(whitespace/line_length)
980+
" --validate-goto-model enable additional well-formedness checks on the\n"
981+
" goto program\n"
973982
HELP_GOTO_TRACE
974983
HELP_FLUSH
975984
" --verbosity # verbosity level\n"

src/cbmc/cbmc_parse_options.h

Lines changed: 1 addition & 0 deletions
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

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

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

0 commit comments

Comments
 (0)