Skip to content

Commit 7d98112

Browse files
author
Remi Delmas
committed
CONTRACTS (DFCC) add new command line switch --dyncontracts
1 parent d1290de commit 7d98112

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,10 +1145,49 @@ void goto_instrument_parse_optionst::instrument_goto_program()
11451145
// recalculate numbers, etc.
11461146
goto_model.goto_functions.update();
11471147
}
1148+
bool new_contracts = false;
1149+
if(cmdline.isset(FLAG_DFCC))
1150+
{
1151+
new_contracts = true;
1152+
if(cmdline.get_values(FLAG_DFCC).size() == 1)
1153+
{
1154+
const std::string &harness_id = *cmdline.get_values(FLAG_DFCC).begin();
1155+
1156+
do_indirect_call_and_rtti_removal();
1157+
1158+
std::set<std::string> to_replace(
1159+
cmdline.get_values(FLAG_REPLACE_CALL).begin(),
1160+
cmdline.get_values(FLAG_REPLACE_CALL).end());
1161+
1162+
std::set<std::string> to_check(
1163+
cmdline.get_values(FLAG_ENFORCE_CONTRACT).begin(),
1164+
cmdline.get_values(FLAG_ENFORCE_CONTRACT).end());
1165+
1166+
std::set<std::string> to_exclude_from_nondet_static(
1167+
cmdline.get_values("nondet-static-exclude").begin(),
1168+
cmdline.get_values("nondet-static-exclude").end());
1169+
1170+
dfcc(
1171+
goto_model,
1172+
harness_id,
1173+
to_check,
1174+
to_replace,
1175+
cmdline.isset(FLAG_LOOP_CONTRACTS),
1176+
to_exclude_from_nondet_static,
1177+
log);
1178+
}
1179+
else
1180+
{
1181+
log.error() << "only one --dyncontracts entry point allowed"
1182+
<< messaget::eom;
1183+
throw 0;
1184+
}
1185+
}
11481186

11491187
if(
1150-
cmdline.isset(FLAG_LOOP_CONTRACTS) || cmdline.isset(FLAG_REPLACE_CALL) ||
1151-
cmdline.isset(FLAG_ENFORCE_CONTRACT))
1188+
!new_contracts &&
1189+
(cmdline.isset(FLAG_LOOP_CONTRACTS) || cmdline.isset(FLAG_REPLACE_CALL) ||
1190+
cmdline.isset(FLAG_ENFORCE_CONTRACT)))
11521191
{
11531192
do_indirect_call_and_rtti_removal();
11541193
code_contractst contracts(goto_model, log);
@@ -1894,6 +1933,7 @@ void goto_instrument_parse_optionst::help()
18941933
" force aggressive slicer to preserve all direct paths\n" // NOLINT(*)
18951934
"\n"
18961935
"Code contracts:\n"
1936+
HELP_DFCC
18971937
HELP_LOOP_CONTRACTS
18981938
HELP_REPLACE_CALL
18991939
HELP_ENFORCE_CONTRACT

src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Author: Daniel Kroening, [email protected]
4141
#include "unwindset.h"
4242

4343
#include "contracts/contracts.h"
44+
#include "contracts/dfcc.h"
4445
#include "wmm/weak_memory.h"
4546

4647
// clang-format off
@@ -95,6 +96,7 @@ Author: Daniel Kroening, [email protected]
9596
"(z3)(add-library)(show-dependence-graph)" \
9697
"(horn)(skip-loops):(model-argc-argv):" \
9798
"(" FLAG_LOOP_CONTRACTS ")" \
99+
"(" FLAG_DFCC "):" \
98100
"(" FLAG_REPLACE_CALL "):" \
99101
"(" FLAG_ENFORCE_CONTRACT "):" \
100102
"(show-threaded)(list-calls-args)" \

0 commit comments

Comments
 (0)