Go to the documentation of this file.
40 if(ins->is_function_call())
42 const auto &
function = ins->call_function();
44 if(
function.
id() != ID_symbol)
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
95 if(ins->is_function_call())
97 const auto &
function = ins->call_function();
99 if(
function.
id() == ID_symbol)
115 requires_visitor(requires);
125 ensures_visitor(ensures);
166 log.
debug() <<
"Creating declarations: \n" << decl_string <<
"\n";
168 std::istringstream iss(decl_string);
174 ansi_c_language.
parse(iss,
"");
178 ansi_c_language.
typecheck(tmp_symbol_table,
"<built-in-library>");
190 for(
const auto &symbol_pair : tmp_symbol_table.
symbols)
227 const std::string &fn_name,
234 as_const(*ins).call_arguments().size() > 0,
235 "Function must have arguments");
255 std::stringstream ssreq, ssensure, ssmemmap;
281 std::ostringstream oss;
284 <<
"(void **elem, " + cprover_prefix +
"size_t size, _Bool *mmap) { \n"
285 <<
"#pragma CPROVER check push\n"
286 <<
"#pragma CPROVER check disable \"pointer\"\n"
287 <<
"#pragma CPROVER check disable \"pointer-primitive\"\n"
288 <<
"#pragma CPROVER check disable \"pointer-overflow\"\n"
289 <<
"#pragma CPROVER check disable \"signed-overflow\"\n"
290 <<
"#pragma CPROVER check disable \"unsigned-overflow\"\n"
291 <<
"#pragma CPROVER check disable \"conversion\"\n"
292 <<
" *elem = malloc(size); \n"
293 <<
" if (!*elem) return 0; \n"
294 <<
" mmap[" + cprover_prefix +
"POINTER_OBJECT(*elem)] = 1; \n"
296 <<
"#pragma CPROVER check pop\n"
300 <<
"(void *elem, " + cprover_prefix +
"size_t size, _Bool *mmap) { \n"
301 <<
"#pragma CPROVER check push\n"
302 <<
"#pragma CPROVER check disable \"pointer\"\n"
303 <<
"#pragma CPROVER check disable \"pointer-primitive\"\n"
304 <<
"#pragma CPROVER check disable \"pointer-overflow\"\n"
305 <<
"#pragma CPROVER check disable \"signed-overflow\"\n"
306 <<
"#pragma CPROVER check disable \"unsigned-overflow\"\n"
307 <<
"#pragma CPROVER check disable \"conversion\"\n"
308 <<
" _Bool ok = (!mmap[" + cprover_prefix +
"POINTER_OBJECT(elem)] && "
309 << cprover_prefix +
"r_ok(elem, size)); \n"
310 <<
" mmap[" + cprover_prefix <<
"POINTER_OBJECT(elem)] = 1; \n"
312 <<
"#pragma CPROVER check pop\n"
334 std::stringstream ssreq, ssensure, ssmemmap;
359 std::ostringstream oss;
362 <<
"(void *elem, " + cprover_prefix +
"size_t size, _Bool *mmap) { \n"
363 <<
"#pragma CPROVER check push\n"
364 <<
"#pragma CPROVER check disable \"pointer\"\n"
365 <<
"#pragma CPROVER check disable \"pointer-primitive\"\n"
366 <<
"#pragma CPROVER check disable \"pointer-overflow\"\n"
367 <<
"#pragma CPROVER check disable \"signed-overflow\"\n"
368 <<
"#pragma CPROVER check disable \"unsigned-overflow\"\n"
369 <<
"#pragma CPROVER check disable \"conversion\"\n"
370 <<
" _Bool r_ok = " + cprover_prefix +
"r_ok(elem, size); \n"
371 <<
" if (mmap[" + cprover_prefix +
"POINTER_OBJECT(elem)]"
372 <<
" != 0 || !r_ok) return 0; \n"
373 <<
" mmap[" << cprover_prefix +
"POINTER_OBJECT(elem)] = 1; \n"
375 <<
"#pragma CPROVER check pop\n"
379 <<
"(void **elem, " + cprover_prefix +
"size_t size, _Bool *mmap) { \n"
380 <<
"#pragma CPROVER check push\n"
381 <<
"#pragma CPROVER check disable \"pointer\"\n"
382 <<
"#pragma CPROVER check disable \"pointer-primitive\"\n"
383 <<
"#pragma CPROVER check disable \"pointer-overflow\"\n"
384 <<
"#pragma CPROVER check disable \"signed-overflow\"\n"
385 <<
"#pragma CPROVER check disable \"unsigned-overflow\"\n"
386 <<
"#pragma CPROVER check disable \"conversion\"\n"
387 <<
" *elem = malloc(size); \n"
388 <<
" return (*elem != 0); \n"
389 <<
"#pragma CPROVER check pop\n"
Class that provides messages with a built-in verbosity 'level'.
#define Forall_goto_program_instructions(it, program)
#define UNREACHABLE
This should be used to mark dead code.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
void add_declarations(const std::string &decl_string)
static instructiont make_dead(const symbol_exprt &symbol, const source_locationt &l=source_locationt::nil())
std::string requires_fn_name
std::string ensures_fn_name
is_fresh_replacet(code_contractst &_parent, messaget _log, 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)
array_typet get_memmap_type()
std::set< irep_idt > & function_calls()
targett add(instructiont &&instruction)
Adds a given instruction at the end.
void operator()(const goto_programt &prog)
Base class for all expressions.
void operator()(goto_programt &prog)
struct configt::ansi_ct ansi_c
function_mapt function_map
static instructiont make_decl(const symbol_exprt &symbol, 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.
An expression denoting infinity.
void update_ensures(goto_programt &ensures)
void goto_convert(const codet &code, symbol_table_baset &symbol_table, goto_programt &dest, message_handlert &message_handler, const irep_idt &mode)
virtual void create_requires_fn_call(goto_programt::targett &target)
std::set< irep_idt > function_set
irep_idt mode
Language mode.
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
bool has_prefix(const std::string &s, const std::string &prefix)
const std::string & id2string(const irep_idt &d)
preprocessort preprocessor
source_locationt source_location
void update_fn_call(goto_programt::targett &target, const std::string &name, bool add_address_of)
virtual void create_ensures_fn_call(goto_programt::targett &target)
const irep_idt & get_identifier() const
Array constructor from single element.
std::set< goto_programt::targett > function_set
void add_pragma_disable_assigns_check(source_locationt &location)
Adds a pragma on a source_locationt to disable inclusion checking.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
#define INITIALIZE_FUNCTION
virtual void set_message_handler(message_handlert &_message_handler)
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
void add_memory_map_dead(goto_programt &program)
virtual void create_ensures_fn_call(goto_programt::targett &target)=0
Predicate to be used with the exprt::visit() function.
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
std::set< goto_programt::targett > & is_fresh_calls()
A collection of goto functions.
message_handlert & get_message_handler()
is_fresh_enforcet(code_contractst &_parent, messaget _log, const irep_idt _fun_id)
source_locationt location
Source code location of definition of symbol.
bool parse(std::istream &instream, const std::string &path) override
static optionalt< codet > static_lifetime_init(const irep_idt &identifier, symbol_tablet &symbol_table)
const symbolst & symbols
Read-only field, used to look up symbols given their names.
symbol_tablet & get_symbol_table()
virtual void create_requires_fn_call(goto_programt::targett &target)=0
A generic container class for the GOTO intermediate representation of one function.
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
const symbolt & new_tmp_symbol(const typet &type, const source_locationt &location, const irep_idt &mode, symbol_table_baset &symtab, std::string suffix, bool is_auxiliary)
Adds a fresh and uniquely named symbol to the symbol table.
virtual void create_declarations()
bool typecheck(symbol_tablet &symbol_table, const std::string &module, const bool keep_file_local) override
typecheck without removing specified entries from the symbol table
Operator to return the address of an object.
virtual void create_declarations()
unsignedbv_typet size_type()
goto_functionst & get_goto_functions()
mstreamt & warning() const
bitvector_typet c_index_type()
void set_identifier(const irep_idt &identifier)
instructionst::iterator targett
#define forall_goto_program_instructions(it, program)
void update_requires(goto_programt &requires)
void add_memory_map_decl(goto_programt &program)
const goto_functionst & goto_functions