30 result.copy_to_operands(what);
31 result.
set(
"lhs", write);
41 result.
set(
"lhs", write);
134 const std::string &function_name);
142 const std::string &function_name);
186 for(goto_functionst::function_mapt::iterator
191 (*this)(it->second.body);
205 if(it->is_function_call())
215 const auto &arguments =
as_const(*target).call_arguments();
222 if(identifier==
"strcoll")
225 else if(identifier==
"strncmp")
227 else if(identifier==
"strxfrm")
230 else if(identifier==
"strchr")
232 else if(identifier==
"strcspn")
235 else if(identifier==
"strpbrk")
238 else if(identifier==
"strrchr")
240 else if(identifier==
"strspn")
243 else if(identifier==
"strerror")
245 else if(identifier==
"strstr")
247 else if(identifier==
"strtok")
249 else if(identifier==
"sprintf")
251 else if(identifier==
"snprintf")
253 else if(identifier ==
"fscanf" || identifier ==
"__isoc99_fscanf")
266 if(arguments.size()<2)
269 "sprintf expected to have two or more arguments",
270 target->source_location());
292 target->turn_into_skip();
302 if(arguments.size()<3)
305 "snprintf expected to have three or more arguments",
306 target->source_location());
329 target->turn_into_skip();
339 if(arguments.size()<2)
342 "fscanf expected to have two or more arguments",
343 target->source_location());
358 target->turn_into_skip();
368 const std::string &function_name)
403 std::string
comment(
"zero-termination of string argument of ");
427 "zero-termination of format string of " + function_name);
431 for(std::size_t i=2; i<arguments.size(); i++)
433 const exprt &arg=arguments[i];
448 "zero-termination of string argument of " + function_name);
462 const std::string &function_name)
497 if(token.field_width!=0)
526 std::string
comment(
"format string buffer overflow in ");
581 std::string
comment(
"format string buffer overflow in ");
616 if(arguments.size()!=2)
619 "strchr expected to have two arguments", target->source_location());
625 "zero-termination of string argument of strchr");
629 target->turn_into_skip();
639 if(arguments.size()!=2)
642 "strrchr expected to have two arguments", target->source_location());
648 "zero-termination of string argument of strrchr");
652 target->turn_into_skip();
662 if(arguments.size()!=2)
665 "strstr expected to have two arguments", target->source_location());
673 "zero-termination of 1st string argument of strstr");
679 "zero-termination of 2nd string argument of strstr");
683 target->turn_into_skip();
693 if(arguments.size()!=2)
696 "strtok expected to have two arguments", target->source_location());
704 "zero-termination of 1st string argument of strtok");
710 "zero-termination of 2nd string argument of strtok");
714 target->turn_into_skip();
726 it->turn_into_skip();
794 it->turn_into_skip();
810 new_symbol.base_name=
"$counter";
811 new_symbol.pretty_name=new_symbol.base_name;
812 new_symbol.is_state_var=
true;
813 new_symbol.is_lvalue=
true;
814 new_symbol.is_static_lifetime=
true;
877 check->complete_goto(exit);
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
unsignedbv_typet unsigned_int_type()
unsignedbv_typet size_type()
bitvector_typet char_type()
bitvector_typet c_index_type()
Operator to return the address of an object.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
A base class for relations, i.e., binary predicates whose two operands have the same type.
A goto_instruction_codet representing an assignment in the program.
exprt::operandst argumentst
struct configt::ansi_ct ansi_c
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.
std::vector< exprt > operandst
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
The Boolean constant false.
A collection of goto functions.
function_mapt function_map
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
This class represents an instruction in the GOTO intermediate representation.
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())
void insert_before_swap(targett target)
Insertion that preserves jumps to "target".
instructionst::iterator targett
instructionst::const_iterator const_targett
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
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_goto(targett _target, 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())
Thrown when we can't handle something in an input source file.
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
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 plus expression Associativity is not specified.
A side_effect_exprt that returns a non-deterministically chosen value.
void do_strtok(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const exprt::operandst &arguments)
void do_function_call(goto_programt &dest, goto_programt::targett target)
bool is_string_type(const typet &t) const
void operator()(goto_programt &dest)
void do_snprintf(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const exprt::operandst &arguments)
string_instrumentationt(symbol_table_baset &_symbol_table)
void do_format_string_read(goto_programt &dest, goto_programt::const_targett target, const code_function_callt::argumentst &arguments, std::size_t format_string_inx, std::size_t argument_start_inx, const std::string &function_name)
symbol_table_baset & symbol_table
void do_strncmp(goto_programt &dest, goto_programt::targett it, const exprt &lhs, const exprt::operandst &arguments)
void make_type(exprt &dest, const typet &type)
void do_sprintf(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const exprt::operandst &arguments)
void do_strstr(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const exprt::operandst &arguments)
void do_strerror(goto_programt &dest, goto_programt::targett it, const exprt &lhs, const exprt::operandst &arguments)
void do_format_string_write(goto_programt &dest, goto_programt::const_targett target, const code_function_callt::argumentst &arguments, std::size_t format_string_inx, std::size_t argument_start_inx, const std::string &function_name)
void do_fscanf(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const exprt::operandst &arguments)
void instrument(goto_programt &dest, goto_programt::targett it)
void do_strcat(goto_programt &dest, goto_programt::targett it, const exprt &lhs, const exprt::operandst &arguments)
void do_strrchr(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const exprt::operandst &arguments)
void invalidate_buffer(goto_programt &dest, goto_programt::const_targett target, const exprt &buffer, const typet &buf_type, const mp_integer &limit)
void do_strchr(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const exprt::operandst &arguments)
The symbol table base class interface.
virtual std::pair< symbolt &, bool > insert(symbolt symbol)=0
Move or copy a new symbol to the symbol table.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
The Boolean constant true.
Semantic type conversion.
The type of an expression, extends irept.
const source_locationt & source_location() const
Generic base class for unary expressions.
#define Forall_goto_program_instructions(it, program)
const std::string & id2string(const irep_idt &d)
API to expression classes for Pointers.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
static std::string comment(const rw_set_baset::entryt &entry, bool write)
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const string_constantt & to_string_constant(const exprt &expr)
void string_instrumentation(symbol_table_baset &symbol_table, goto_programt &dest)
exprt buffer_size(const exprt &what)
exprt is_zero_string(const exprt &what, bool write)
exprt zero_string_length(const exprt &what, bool write)
const type_with_subtypet & to_type_with_subtype(const typet &type)