74 const irep_idt &function_name)
const override
91 const irep_idt &function_name)
const override
115 const irep_idt &function_name)
const override
210 return std::binary_search(
221 const irep_idt &function_name)
const override
232 "function " +
id2string(function_name) +
" does not take " +
234 "--generate-havocing-body"};
243 "argument number " + std::to_string(number) +
" of function " +
244 id2string(function_name) +
" is not a pointer",
245 "--generate-havocing-body"};
265 auto goto_instruction =
287 auto label_instruction =
289 goto_instruction->complete_goto(label_instruction);
313 typet type(return_type);
368 : runtime_error(reason)
376 const std::string &options,
381 if(options.empty() || options ==
"nondet-return")
383 return std::make_unique<havoc_generate_function_bodiest>(
384 std::vector<irep_idt>{},
386 object_factory_parameters,
390 if(options ==
"assume-false")
392 return std::make_unique<assume_false_generate_function_bodiest>();
395 if(options ==
"assert-false")
397 return std::make_unique<assert_false_generate_function_bodiest>();
400 if(options ==
"assert-false-assume-false")
402 return std::make_unique<
419 "Expected key_value_pair of form argument:value");
443 auto maybe_nondet_param_number = string2optional_size_t(param_id);
445 maybe_nondet_param_number.has_value(),
446 param_id +
" not a number");
447 return *maybe_nondet_param_number;
457 std::vector<irep_idt> globals_to_havoc;
461 for(
auto const &symbol : symbol_table.
symbols)
464 symbol.second.is_lvalue && symbol.second.is_static_lifetime &&
469 messages.
warning() <<
"generate function bodies: "
470 <<
"matched global '" <<
id2string(symbol.first)
471 <<
"' begins with __CPROVER, "
472 <<
"havoc-ing this global may interfere"
475 globals_to_havoc.push_back(symbol.first);
479 return std::make_unique<havoc_generate_function_bodiest>(
480 std::move(globals_to_havoc),
482 object_factory_parameters,
485 return std::make_unique<havoc_generate_function_bodiest>(
486 std::move(globals_to_havoc),
488 object_factory_parameters,
513 !function.second.body_available() &&
518 messages.
warning() <<
"generate function bodies: matched function '"
520 <<
"' begins with __CPROVER "
521 <<
"the generated body for this function "
532 <<
"generate function bodies: No function name matched regex"
538 const std::string &function_name,
558 if(symbol.type.id() ==
ID_code && symbol.name == function_name)
561 function_type = symbol.type;
589 !function.second.body_available() &&
609 std::size_t counter = 0;
612 for(
auto &instruction : function.second.body.instructions)
614 if(instruction.is_function_call())
616 auto &called_function = instruction.call_function();
@ DYNAMIC
Allocate dynamic objects (using ALLOCATE)
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
void generate_function_body_impl(goto_functiont &function, symbol_tablet &symbol_table, const irep_idt &function_name) const override
Produce a body for the passed function At this point the body of function is always empty,...
void generate_function_body_impl(goto_functiont &function, symbol_tablet &symbol_table, const irep_idt &function_name) const override
Produce a body for the passed function At this point the body of function is always empty,...
void generate_function_body_impl(goto_functiont &function, symbol_tablet &symbol_table, const irep_idt &function_name) const override
Produce a body for the passed function At this point the body of function is always empty,...
A codet representing sequential composition of program statements.
Operator to dereference a pointer.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
The Boolean constant false.
generate_function_bodies_errort(const std::string &reason)
Base class for replace_function_body implementations.
void generate_function_body(goto_functiont &function, symbol_tablet &symbol_table, const irep_idt &function_name) const
Replace the function body with one based on the replace_function_body class being used.
void generate_parameter_names(goto_functiont &function, symbol_tablet &symbol_table, const irep_idt &function_name) const
Generate parameter names for unnamed parameters.
virtual void generate_function_body_impl(goto_functiont &function, symbol_tablet &symbol_table, const irep_idt &function_name) const =0
Produce a body for the passed function At this point the body of function is always empty,...
function_mapt function_map
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
parameter_identifierst parameter_identifiers
The identifiers of the parameters of this function.
bool body_available() const
void set_parameter_identifiers(const code_typet &code_type)
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_set_return_value(exprt return_value, const source_locationt &l=source_locationt::nil())
static instructiont make_dead(const symbol_exprt &symbol, const source_locationt &l=source_locationt::nil())
static instructiont make_end_function(const source_locationt &l=source_locationt::nil())
void destructive_append(goto_programt &p)
Appends the given program p to *this. p is destroyed.
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_decl(const symbol_exprt &symbol, const source_locationt &l=source_locationt::nil())
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())
havoc_generate_function_bodiest(std::vector< irep_idt > globals_to_havoc, std::vector< std::size_t > param_numbers_to_havoc, const c_object_factory_parameterst &object_factory_parameters, message_handlert &message_handler)
std::optional< std::vector< std::size_t > > param_numbers_to_havoc
const std::vector< irep_idt > globals_to_havoc
havoc_generate_function_bodiest(std::vector< irep_idt > globals_to_havoc, std::regex parameters_to_havoc, const c_object_factory_parameterst &object_factory_parameters, message_handlert &message_handler)
bool should_havoc_param(const std::string ¶m_name, std::size_t param_number) const
std::optional< std::regex > parameters_to_havoc
void generate_function_body_impl(goto_functiont &function, symbol_tablet &symbol_table, const irep_idt &function_name) const override
Produce a body for the passed function At this point the body of function is always empty,...
const c_object_factory_parameterst & object_factory_parameters
void havoc_expr_rec(const exprt &lhs, const std::size_t initial_depth, const source_locationt &source_location, const irep_idt &function_id, symbol_tablet &symbol_table, goto_programt &dest) const
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
void remove(const irep_idt &name)
Class that provides messages with a built-in verbosity 'level'.
message_handlert & get_message_handler()
mstreamt & warning() const
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
The null pointer constant.
Symbol table entry of function parameterThis is a symbol generated as part of type checking.
void set_function(const irep_idt &function)
Expression to hold a symbol (variable)
std::set< irep_idt > recursion_sett
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
bool has_prefix(const std::string &s, const std::string &prefix)
symbolt & get_fresh_aux_symbol(const typet &type, const std::string &name_prefix, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &symbol_mode, const namespacet &ns, symbol_table_baset &symbol_table)
Installs a fresh-named symbol with respect to the given namespace ns with the requested name pattern ...
Fresh auxiliary symbol creation.
std::unique_ptr< generate_function_bodiest > generate_function_bodies_factory(const std::string &options, const c_object_factory_parameterst &object_factory_parameters, const symbol_tablet &symbol_table, message_handlert &message_handler)
Create the type that actually generates the functions.
void generate_function_bodies(const std::regex &functions_regex, const generate_function_bodiest &generate_function_body, goto_modelt &model, message_handlert &message_handler)
Generate function bodies with some default behavior: assert-false, assume-false, assert-false-assume-...
void goto_convert(const codet &code, symbol_table_baset &symbol_table, goto_programt &dest, message_handlert &message_handler, const irep_idt &mode)
Goto Programs with Functions.
const std::string & id2string(const irep_idt &d)
API to expression classes for Pointers.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
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.
std::optional< std::size_t > string2optional_size_t(const std::string &str, int base)
Convert string to size_t similar to the stoul or stoull functions, return nullopt when the conversion...
void split_string(const std::string &s, char delim, std::vector< std::string > &result, bool strip, bool remove_empty)