CBMC
|
Entry point into the contracts transformation. More...
#include <dfcc.h>
Public Member Functions | |
dfcct (const optionst &options, goto_modelt &goto_model, const irep_idt &harness_id, const std::optional< std::pair< irep_idt, irep_idt >> &to_check, const bool allow_recursive_calls, const std::map< irep_idt, irep_idt > &to_replace, const loop_contract_configt loop_contract_config, message_handlert &message_handler, const std::set< std::string > &to_exclude_from_nondet_static) | |
Class constructor. More... | |
void | transform_goto_model () |
Applies function contracts and loop contracts transformation to GOTO model using the dynamic frame condition checking approach. More... | |
Protected Member Functions | |
void | check_transform_goto_model_preconditions () |
Checks preconditions on arguments of transform_goto_model. More... | |
void | partition_function_symbols (std::set< irep_idt > &pure_contract_symbols, std::set< irep_idt > &other_symbols) |
Partitions the function symbols of the symbol table into pure contracts and other function symbols symbols. More... | |
void | link_model_and_load_dfcc_library () |
void | instrument_harness_function () |
void | lift_memory_predicates () |
void | wrap_checked_function () |
void | wrap_replaced_functions () |
void | wrap_discovered_function_pointer_contracts () |
void | instrument_other_functions () |
void | reinitialize_model () |
Re-initialise the GOTO model. More... | |
dfcct::dfcct | ( | const optionst & | options, |
goto_modelt & | goto_model, | ||
const irep_idt & | harness_id, | ||
const std::optional< std::pair< irep_idt, irep_idt >> & | to_check, | ||
const bool | allow_recursive_calls, | ||
const std::map< irep_idt, irep_idt > & | to_replace, | ||
const loop_contract_configt | loop_contract_config, | ||
message_handlert & | message_handler, | ||
const std::set< std::string > & | to_exclude_from_nondet_static | ||
) |
Class constructor.
options | CLI options (used to lookup options for language config when re-defining the model's entry point) |
goto_model | GOTO model to transform |
harness_id | Proof harness name, must be the entry point of the model |
to_check | (function,contract) pair for contract checking |
allow_recursive_calls | Allow the checked function to be recursive |
to_replace | functions-to-contract mapping for replacement |
loop_contract_config | configuration for applying loop contracts |
message_handler | used for debug/warning/error messages |
to_exclude_from_nondet_static | set of symbols to exclude when |
|
protected |
Checks preconditions on arguments of transform_goto_model.
The preconditions are:
__CPROVER_*
functions cannot be checked against a contract (because they cannot be instrumented),to_exclude_from_nondet_static
exist in the model.
|
protected |
Re-initialise the GOTO model.
The new entry point must be the proof harness function specified for instrumentation.
The "initialize" (aka INITIALIZE_FUNCTION) is the function that assigns initial values to all statics of the model;
The initialize function must do the following:
A call to nondet_static
will re-generate the initialize function with nondet values. The instrumentation statics will not get nondet initialised by virtue of being tagged with ID_C_no_nondet_initialization.
However, nondet_static expects instructions to be either function calls or assignments with a symbol_exprt LHS. Since entries for the instrumented function maps are not symbol_exprts but index_exprts they need to be moved to the harness function.
The "start" function (aka goto_functionst::entry_point()) is the function from which SymEx starts.
The start function must do the following:
All of which can be done using a call to generate_ansi_c_start_function
, assuming the initialize function is already available in the symbol table.
So we do the following:
void dfcct::transform_goto_model | ( | ) |
Applies function contracts and loop contracts transformation to GOTO model using the dynamic frame condition checking approach.
Functions to check/replace are explicitly mapped to contracts. When checking function foo
against contract bar
, we require the actual contract symbol to exist as contract::bar
in the symbol table.
Transformation steps:
contract::
symbols
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |