40 if(ins->is_function_call())
42 const auto &
function = ins->call_function();
44 if(
function.
id() != ID_symbol)
46 log.error().source_location = ins->source_location();
47 log.error() <<
"Function pointer used in function invoked by "
61 log.warning() <<
"Could not find function '" << fun_name
65 if(called_fun->second.body_available())
72 log.warning() <<
"No body for function: " << fun_name
81 std::set<goto_programt::targett, goto_programt::target_less_than> &
96 if(ins->is_function_call())
98 const auto &
function = ins->call_function();
100 if(
function.
id() == ID_symbol)
116 requires_visitor(requires_);
126 ensures_visitor(ensures);
169 log.debug() <<
"Creating declarations: \n" << decl_string <<
"\n";
171 std::istringstream iss(decl_string);
176 ansi_c_language.
parse(iss,
"",
log.get_message_handler());
181 tmp_symbol_table,
"<built-in-library>",
log.get_message_handler());
193 for(
const auto &symbol_pair : tmp_symbol_table.
symbols)
220 const std::string &fn_name,
227 as_const(*ins).call_arguments().size() > 0,
228 "Function must have arguments");
248 std::stringstream ssreq, ssensure, ssmemmap;
274 std::ostringstream oss;
277 <<
"(void **elem, " + cprover_prefix +
"size_t size, _Bool *mmap) { \n"
278 <<
"#pragma CPROVER check push\n"
279 <<
"#pragma CPROVER check disable \"pointer\"\n"
280 <<
"#pragma CPROVER check disable \"pointer-primitive\"\n"
281 <<
"#pragma CPROVER check disable \"pointer-overflow\"\n"
282 <<
"#pragma CPROVER check disable \"signed-overflow\"\n"
283 <<
"#pragma CPROVER check disable \"unsigned-overflow\"\n"
284 <<
"#pragma CPROVER check disable \"conversion\"\n"
285 <<
" *elem = malloc(size); \n"
286 <<
" if (!*elem) return 0; \n"
287 <<
" mmap[" + cprover_prefix +
"POINTER_OBJECT(*elem)] = 1; \n"
289 <<
"#pragma CPROVER check pop\n"
293 <<
"(void *elem, " + cprover_prefix +
"size_t size, _Bool *mmap) { \n"
294 <<
"#pragma CPROVER check push\n"
295 <<
"#pragma CPROVER check disable \"pointer\"\n"
296 <<
"#pragma CPROVER check disable \"pointer-primitive\"\n"
297 <<
"#pragma CPROVER check disable \"pointer-overflow\"\n"
298 <<
"#pragma CPROVER check disable \"signed-overflow\"\n"
299 <<
"#pragma CPROVER check disable \"unsigned-overflow\"\n"
300 <<
"#pragma CPROVER check disable \"conversion\"\n"
301 <<
" _Bool ok = (!mmap[" + cprover_prefix +
"POINTER_OBJECT(elem)] && "
302 << cprover_prefix +
"r_ok(elem, size)); \n"
303 <<
" mmap[" + cprover_prefix <<
"POINTER_OBJECT(elem)] = 1; \n"
305 <<
"#pragma CPROVER check pop\n"
327 std::stringstream ssreq, ssensure, ssmemmap;
353 std::ostringstream oss;
356 <<
"(void *elem, " + cprover_prefix +
"size_t size, _Bool *mmap) { \n"
357 <<
"#pragma CPROVER check push\n"
358 <<
"#pragma CPROVER check disable \"pointer\"\n"
359 <<
"#pragma CPROVER check disable \"pointer-primitive\"\n"
360 <<
"#pragma CPROVER check disable \"pointer-overflow\"\n"
361 <<
"#pragma CPROVER check disable \"signed-overflow\"\n"
362 <<
"#pragma CPROVER check disable \"unsigned-overflow\"\n"
363 <<
"#pragma CPROVER check disable \"conversion\"\n"
364 <<
" _Bool r_ok = " + cprover_prefix +
"r_ok(elem, size); \n"
365 <<
" if (mmap[" + cprover_prefix +
"POINTER_OBJECT(elem)]"
366 <<
" != 0 || !r_ok) return 0; \n"
367 <<
" mmap[" << cprover_prefix +
"POINTER_OBJECT(elem)] = 1; \n"
369 <<
"#pragma CPROVER check pop\n"
373 <<
"(void **elem, " + cprover_prefix +
"size_t size, _Bool *mmap) { \n"
374 <<
"#pragma CPROVER check push\n"
375 <<
"#pragma CPROVER check disable \"pointer\"\n"
376 <<
"#pragma CPROVER check disable \"pointer-primitive\"\n"
377 <<
"#pragma CPROVER check disable \"pointer-overflow\"\n"
378 <<
"#pragma CPROVER check disable \"signed-overflow\"\n"
379 <<
"#pragma CPROVER check disable \"unsigned-overflow\"\n"
380 <<
"#pragma CPROVER check disable \"conversion\"\n"
381 <<
" *elem = malloc(size); \n"
382 <<
" return (*elem != 0); \n"
383 <<
"#pragma CPROVER check pop\n"
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
unsignedbv_typet unsigned_char_type()
bitvector_typet c_index_type()
Operator to return the address of an object.
bool typecheck(symbol_table_baset &symbol_table, const std::string &module, message_handlert &message_handler, const bool keep_file_local) override
typecheck without removing specified entries from the symbol table
bool parse(std::istream &instream, const std::string &path, message_handlert &message_handler) override
Array constructor from single element.
struct configt::ansi_ct ansi_c
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
Predicate to be used with the exprt::visit() function.
void operator()(goto_programt &prog)
std::set< goto_programt::targett, goto_programt::target_less_than > & is_fresh_calls()
std::set< goto_programt::targett, goto_programt::target_less_than > function_set
void operator()(const goto_programt &prog)
const goto_functionst & goto_functions
std::set< irep_idt > & function_calls()
std::set< irep_idt > function_set
message_handlert & message_handler
A collection of goto functions.
function_mapt function_map
bool can_produce_function(const irep_idt &id) const override
Determines if this model can produce a body for the given function.
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_dead(const symbol_exprt &symbol, const source_locationt &l=source_locationt::nil())
instructionst::iterator targett
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
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())
An expression denoting infinity.
virtual void create_ensures_fn_call(goto_programt::targett &target)=0
void update_fn_call(goto_programt::targett &target, const std::string &name, bool add_address_of)
std::string ensures_fn_name
message_handlert & message_handler
std::string requires_fn_name
void add_memory_map_decl(goto_programt &program)
void update_requires(goto_programt &requires_)
void add_memory_map_dead(goto_programt &program)
array_typet get_memmap_type()
void add_declarations(const std::string &decl_string)
void update_ensures(goto_programt &ensures)
virtual void create_requires_fn_call(goto_programt::targett &target)=0
is_fresh_enforcet(goto_modelt &goto_model, message_handlert &message_handler, const irep_idt &_fun_id)
virtual void create_ensures_fn_call(goto_programt::targett &target)
virtual void create_requires_fn_call(goto_programt::targett &target)
virtual void create_declarations()
is_fresh_replacet(goto_modelt &goto_model, message_handlert &message_handler, const irep_idt &_fun_id)
virtual void create_ensures_fn_call(goto_programt::targett &target)
virtual void create_declarations()
virtual void create_requires_fn_call(goto_programt::targett &target)
Class that provides messages with a built-in verbosity 'level'.
void set_identifier(const irep_idt &identifier)
const irep_idt & get_identifier() const
const symbolst & symbols
Read-only field, used to look up symbols given their names.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
irep_idt mode
Language mode.
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.
Goto Programs with Functions.
#define forall_goto_program_instructions(it, program)
#define Forall_goto_program_instructions(it, program)
void add_pragma_disable_assigns_check(source_locationt &location)
Adds a pragma on a source_locationt to disable inclusion checking.
Specify write set in function contracts.
const std::string & id2string(const irep_idt &d)
Predicates to specify memory footprint in function contracts.
#define UNREACHABLE
This should be used to mark dead code.
void recreate_initialize_function(goto_modelt &goto_model, message_handlert &message_handler)
Regenerates the CPROVER_INITIALIZE function, which initializes all non-function symbols of the goto m...
#define INITIALIZE_FUNCTION
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
preprocessort preprocessor