34 : goto_model(goto_model),
36 instrument(instrument),
64 instruction.is_function_call() &&
65 instruction.call_function().id() ==
ID_symbol)
95 iter->second.body_available())
130 : function_id(function_id)
149 for(
const auto &instruction :
153 instruction.is_function_call() &&
154 instruction.call_function().id() ==
ID_symbol)
161 mstream <<
"Memory predicate dependency " << caller <<
" -> "
162 << callee << messaget::eom;
176 "could not determine instrumentation order for memory predicates, most "
177 "likely due to mutual recursion");
178 for(
const auto &idx : sorted)
203 return {
found->second};
225 for(std::size_t
rank = 0;
rank < parameters.size();
rank++)
235 if(it.is_function_call() && it.call_function().id() ==
ID_symbol)
297 auto ¶meters =
code_type.parameters();
301 mstream <<
"adding pointer type to " << function_id <<
" " << parameter_id
304 const symbolt &old_symbol = entry->second;
311 new_symbol.module = old_symbol.module;
319 std::pair<symbolt &, bool>
res =
342 for(
auto &instruction : body.instructions)
347 return changed ? std::optional<exprt>{expr} : std::nullopt;
353 instruction.is_function_call() &&
354 instruction.call_function().id() ==
ID_symbol)
363 const auto arg = instruction.call_arguments()[
rank];
365 mstream <<
"Adding address_of to call " <<
callee_id
382 log.
status() <<
"Instrumenting memory predicate '" << function_id <<
"'"
393 mstream <<
"Ranks of lifted parameters for " << function_id <<
": ";
394 for(const auto rank : lifted_parameters[function_id])
395 mstream << rank <<
", ";
396 mstream << messaget::eom;
419 if(target->is_function_call())
421 const auto &function = target->call_function();
432 target->call_arguments()[
rank] =
pointer_typet pointer_type(const typet &subtype)
Operator to return the address of an object.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Operator to dereference a pointer.
This class instruments GOTO functions or instruction sequences for frame condition checking and loop ...
void instrument_function(const irep_idt &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 instrumenting its body instruc...
bool do_not_instrument(const irep_idt &id) const
True iff the symbol must not be instrumented because it is an internal symbol or a CPROVER symbol.
Class interface to library types and functions defined in cprover_contracts.c.
dfcc_instrumentt & instrument
void fix_calls(goto_programt &program)
Fixes calls to user-defined memory predicates in the given program, by adding an address-of to argume...
void collect_parameters_to_lift(const irep_idt &function_id)
Computes the subset of function parameters of function_id that are passed directly to core predicates...
void lift_predicate(const irep_idt &function_id, std::set< irep_idt > &discovered_function_pointer_contracts)
void add_pointer_type(const irep_idt &function_id, const std::size_t parameter_rank, replace_symbolt &replace_lifted_param)
adds a pointer_type to the parameter of a function
dfcc_lift_memory_predicatest(goto_modelt &goto_model, dfcc_libraryt &library, dfcc_instrumentt &instrument, message_handlert &message_handler)
std::map< irep_idt, std::set< std::size_t > > lifted_parameters
void lift_parameters_and_update_body(const irep_idt &function_id, std::set< irep_idt > &discovered_function_pointer_contracts)
bool calls_memory_predicates(const goto_programt &goto_program, const std::set< irep_idt > &predicates)
Returns true iff goto_program calls core memory predicates.
bool is_lifted_function(const irep_idt &function_id)
True if a function at least had one of its parameters lifted.
std::set< irep_idt > lift_predicates(std::set< irep_idt > &discovered_function_pointer_contracts)
Collects and lifts all user-defined memory predicates.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
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.
instructionst instructions
The list of instructions in the goto program.
instructionst::iterator targett
This class represents a node in a directed graph.
const irep_idt & id() const
void conditional_output(mstreamt &mstream, const std::function< void(mstreamt &)> &output_generator) const
Generate output to message_stream using output_generator if the configured verbosity is at least as h...
mstreamt & status() const
Replace a symbol expression by a given expression.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
virtual void erase(const symbolst::const_iterator &entry) override
Remove a symbol from the symbol table.
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
source_locationt location
Source code location of definition of symbol.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
typet type
Type of symbol.
irep_idt name
The unique identifier.
irep_idt irep_idt base_name
Name of module the symbol belongs to.
irep_idt mode
Language mode.
Add instrumentation to a goto program to perform frame condition checks.
Dynamic frame condition checking library loading.
static bool is_core_memory_predicate(const irep_idt &function_id)
True iff function_id is a core memory predicate.
static std::optional< std::size_t > is_param_expr(const exprt &expr, const std::map< irep_idt, std::size_t > ¶meter_rank)
Collects all user-defined predicates that call functions is_fresh, pointer_in_range,...
Dynamic frame condition checking utility functions.
A Template Class for Graphs.
API to expression classes for Pointers.
#define PRECONDITION_WITH_DIAGNOSTICS(CONDITION,...)
#define CHECK_RETURN(CONDITION)
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
static symbolt & get_function_symbol(symbol_table_baset &, const irep_idt &function_id)
Returns the symbolt for function_id.
Loop contract configurations.