25 : goto_model(goto_model),
26 message_handler(message_handler),
29 instrument(instrument),
30 spec_functions(spec_functions),
31 contract_handler(contract_handler),
32 ns(goto_model.symbol_table)
39 std::pair<irep_idt, std::pair<dfcc_contract_modet, loop_contract_configt>>>
47 std::set<irep_idt> &function_pointer_contracts,
48 bool allow_recursive_calls)
51 {function_id, {
contract_id, {contract_mode, loop_contract_config}}});
52 auto inserted =
pair.second;
59 pair.first->second.second.second;
67 err_msg <<
"DFCC: multiple attempts to swap and wrap function '"
68 << function_id <<
"':\n";
74 << loop_contract_config.
to_string() <<
"\n";
90 function_pointer_contracts,
91 allow_recursive_calls);
106 dest.insert(it.first);
138 std::set<irep_idt> &function_pointer_contracts,
139 bool allow_recursive_calls)
150 const auto &wrapper_symbol =
157 "__contract_check_in_progress",
158 wrapper_symbol.location,
160 wrapper_symbol.module,
168 "__contract_checked_once",
169 wrapper_symbol.location,
171 wrapper_symbol.module,
185 sl.set_function(wrapper_symbol.name);
186 sl.set_property_class(
"single_top_level_call");
188 "Only a single top-level call to function " +
id2string(function_id) +
197 "__write_set_to_check",
207 function_pointer_contracts);
223 if(allow_recursive_calls)
232 function_pointer_contracts);
237 sl.set_function(wrapper_symbol.name);
238 sl.set_property_class(
"no_recursive_call");
240 "No recursive call to function " +
id2string(function_id) +
269 std::set<irep_idt> &function_pointer_contracts)
273 id2string(function_id) +
"_wrapped_for_replacement_with_contract";
279 "__write_set_to_check",
291 function_pointer_contracts);
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
A contract is represented by a function declaration or definition with contract clauses attached to i...
void add_contract_instructions(const dfcc_contract_modet contract_mode, const irep_idt &wrapper_id, const irep_idt &wrapped_id, const irep_idt &contract_id, const symbolt &wrapper_write_set_symbol, goto_programt &dest, std::set< irep_idt > &function_pointer_contracts)
Adds instructions in dest modeling contract checking, assuming that ret_t wrapper_id(params) is the f...
This class instruments GOTO functions or instruction sequences for frame condition checking and loop ...
void instrument_wrapped_function(const irep_idt &wrapped_function_id, const irep_idt &initial_function_id, const loop_contract_configt &loop_contract_config, std::set< irep_idt > &function_pointer_contracts)
Instruments a GOTO function by adding an extra write set parameter and inserting frame condition chec...
Class interface to library types and functions defined in cprover_contracts.c.
std::map< dfcc_typet, typet > dfcc_type
Maps enum values to the actual types (dynamically loaded)
This class rewrites GOTO functions that use the built-ins:
void check_contract(const loop_contract_configt &loop_contract_config, const irep_idt &function_id, const irep_idt &contract_id, std::set< irep_idt > &function_pointer_contracts, bool allow_recursive_calls)
Swaps-and-wraps the given function_id in a wrapper function that checks the given contract_id.
dfcc_swap_and_wrapt(goto_modelt &goto_model, message_handlert &message_handler, dfcc_libraryt &library, dfcc_instrumentt &instrument, dfcc_spec_functionst &spec_functions, dfcc_contract_handlert &contract_handler)
void get_swapped_functions(std::set< irep_idt > &dest) const
Adds the set of swapped functions to dest.
static std::map< irep_idt, std::pair< irep_idt, std::pair< dfcc_contract_modet, loop_contract_configt > > > cache
remember all functions that were swapped/wrapped and in which mode
dfcc_instrumentt & instrument
dfcc_contract_handlert & contract_handler
void replace_with_contract(const irep_idt &function_id, const irep_idt &contract_id, std::set< irep_idt > &function_pointer_contracts)
Swaps-and-wraps the given function_id in a wrapper function that models the abstract behaviour of con...
void swap_and_wrap(const dfcc_contract_modet contract_mode, const loop_contract_configt &loop_contract_config, const irep_idt &function_id, const irep_idt &contract_id, std::set< irep_idt > &function_pointer_contracts, bool allow_recursive_calls)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
The Boolean constant false.
function_mapt function_map
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
A generic container class for the GOTO intermediate representation of one function.
static instructiont make_assumption(const exprt &g, const source_locationt &l=source_locationt::nil())
static instructiont make_end_function(const source_locationt &l=source_locationt::nil())
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
static instructiont make_skip(const source_locationt &l=source_locationt::nil())
targett add(instructiont &&instruction)
Adds a given instruction at the end.
static instructiont make_assertion(const exprt &g, const source_locationt &l=source_locationt::nil())
static instructiont make_incomplete_goto(const exprt &_cond, const source_locationt &l=source_locationt::nil())
The Boolean constant true.
Specialisation of dfcc_contract_handlert for contracts.
std::string dfcc_contract_mode_to_string(const dfcc_contract_modet mode)
dfcc_contract_modet
Enum type representing the contract checking and replacement modes.
Add instrumentation to a goto program to perform frame condition checks.
Dynamic frame condition checking library loading.
@ CAR_SET_PTR
type of pointers to sets of CAR
Given a function_id and contract_id, swaps its body to a function with a fresh mangled name,...
Dynamic frame condition checking utility functions.
const std::string & id2string(const irep_idt &d)
static symbolt & get_function_symbol(symbol_table_baset &, const irep_idt &function_id)
Returns the symbolt for function_id.
static const symbolt & create_new_parameter_symbol(symbol_table_baset &, const irep_idt &function_id, const std::string &base_name, const typet &type)
Creates a new parameter symbol for the given function_id.
static void wrap_function(goto_modelt &goto_model, const irep_idt &function_id, const irep_idt &wrapped_function_id)
Given a function to wrap foo and a new name wrapped_foo
static const symbolt & create_static_symbol(symbol_table_baset &, const typet &type, const std::string &prefix, const std::string &base_name, const source_locationt &source_location, const irep_idt &mode, const irep_idt &module, const exprt &initial_value, const bool no_nondet_initialization=true)
Adds a new static symbol named prefix::base_name of type type with value initial_value in the symbol ...
static void add_parameter(goto_modelt &, const symbolt &symbol, const irep_idt &function_id)
Adds the given symbol as parameter to the function symbol's code_type.
Loop contract configurations.
std::string to_string() const