49 dest.type().subtype() ==
a_t.subtype()))
52 log.warning() <<
"warning: inconsistent abstract type for "
90 : sym_suffix(
"#str$fcn"),
100 s.components()[1].set_pretty_name(
"length");
101 s.components()[2].set_pretty_name(
"size");
150 goto_functionst::function_mapt::iterator
fct_entry =
156 fct_entry->second.parameter_identifiers);
173 goto_functionst::function_mapt::iterator
206 goto_functiont::parameter_identifierst::const_iterator
param_id_it =
207 parameter_identifiers.begin();
219 parameter_identifiers.push_back(
new_param.get_identifier());
237 :
ns.
lookup(identifier).base_name) +
250 if(!identifier.
empty())
273 typedef std::unordered_map<irep_idt, goto_programt::targett>
available_declst;
281 std::make_pair(it->decl_symbol().get_identifier(), it));
284 for(
const auto &l :
locals)
316 decl1->code_nonconst().add_source_location() =
ref_instr->source_location();
332 assignment1->code_nonconst().add_source_location() =
367 struct_union_typet::componentst::const_iterator
it2=components.begin();
368 for(struct_union_typet::componentst::const_iterator
373 if(it->get_name()!=
it2->get_name())
388 assignment1->code_nonconst().add_source_location() =
397 components.size() == seen,
398 "some of the symbol's component names were not found in the source");
412 std::string suffix=
"$strdummy";
413 if(!component_name.
empty())
414 suffix=
"#"+
id2string(component_name)+suffix;
419 new_symbol.
type=type;
423 new_symbol.module=symbol.module;
434 decl->code_nonconst().add_source_location() =
ref_instr->source_location();
461 assignment1->code_nonconst().add_source_location() =
487 it->set_condition(
tmp);
528 exprt &lhs = target->assign_lhs_nonconst();
529 exprt &rhs = target->assign_rhs_nonconst();
541 const typet &type = target->assign_lhs().type();
554 auto arguments =
as_const(*target).call_arguments();
557 for(
const auto &arg : arguments)
574 "argument array type differs from formal parameter pointer type");
596 target->call_arguments() = std::move(arguments);
602 if(expr.
id()==
"is_zero_string" ||
603 expr.
id()==
"zero_string_length" ||
604 expr.
id()==
"buffer_size")
619 if(expr.
id()==
"is_zero_string")
626 else if(expr.
id()==
"zero_string_length")
633 else if(expr.
id()==
"buffer_size")
646 const exprt &pointer,
684 abstraction_types_mapt::const_iterator
map_entry =
707 ::std::pair<abstraction_types_mapt::iterator, bool>
map_entry(
738 if(
comp.get_anonymous())
747 new_comp.back().set_pretty_name(
comp.get_pretty_name());
820 if(
object.
id()==
ID_if)
893 if(!size.has_value())
896 *size ==
object.operands().size(),
897 "wrong number of array object arguments");
899 exprt::operandst::const_iterator it=
object.operands().begin();
974 locals[identifier]=identifier;
977 new_symbol.
type=type;
979 new_symbol.
name=identifier;
980 new_symbol.module=
"$tmp";
987 return ns.
lookup(identifier).symbol_expr();
1037 new_symbol.
type=type;
1040 new_symbol.
name=identifier;
1041 new_symbol.module=symbol.module;
1077 new_symbol.
name=identifier;
1135 const exprt &lhs = target->assign_lhs();
1136 const exprt rhs = target->assign_rhs();
1137 const exprt *
rhsp = &(target->assign_rhs());
1161 target->source_location();
1162 dest.insert_before_swap(target, assignment);
1164 return std::next(target);
1176 const exprt &lhs = target->assign_lhs();
1177 const exprt *
rhsp = &(target->assign_rhs());
1183 if(!
rhsp->is_zero())
1197 "failed to create length-component for the left-hand-side");
1217 "failed to create length-component for the left-hand-side");
1247 "failed to create is_zero-component for the left-hand-side");
1251 assignment1->code_nonconst().add_source_location() =
1252 target->source_location();
1256 assignment2->code_nonconst().add_source_location() =
1257 target->source_location();
1262 dest.insert_before_swap(target,
tmp);
1285 if(!size.has_value())
1305 !
comp.get_name().empty(),
"struct/union components must have a name");
1341 dest.insert_before_swap(target,
tmp);
1360 assignment->code_nonconst().add_source_location() =
1361 target->source_location();
1369 assignment->code_nonconst().add_source_location() =
1370 target->source_location();
1378 assignment->code_nonconst().add_source_location() =
1379 target->source_location();
1384 dest.insert_before_swap(target,
tmp);
1397 "either the expression is not a string or it is not a pointer to one");
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
unsignedbv_typet size_type()
pointer_typet pointer_type(const typet &subtype)
bitvector_typet c_index_type()
Operator to return the address of an object.
virtual void clear()
Reset the abstract state.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Array constructor from list of elements.
Array constructor from single element.
const exprt & size() const
Internally generated symbol table entryThis is a symbol generated as part of translation to or modifi...
A base class for relations, i.e., binary predicates whose two operands have the same type.
A codet representing an assignment in the program.
exprt::operandst argumentst
std::vector< parametert > parameterst
const parameterst & parameters() const
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.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
source_locationt & add_source_location()
A collection of goto functions.
std::vector< irep_idt > parameter_identifierst
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
This class represents an instruction in the GOTO intermediate representation.
codet & code_nonconst()
Set the code represented by this instruction.
A generic container class for the GOTO intermediate representation of one function.
instructionst instructions
The list of instructions in the goto program.
void clear()
Clear the goto program.
instructionst::iterator targett
void destructive_append(goto_programt &p)
Appends the given program p to *this. p is destroyed.
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_decl(const symbol_exprt &symbol, const source_locationt &l=source_locationt::nil())
static instructiont make_incomplete_goto(const exprt &_cond, const source_locationt &l=source_locationt::nil())
The trinary if-then-else operator.
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
Extract member of struct or union.
Class that provides messages with a built-in verbosity 'level'.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
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.
Replace all uses of char * by a struct that carries that string, and also the underlying allocation a...
goto_programt::targett abstract(goto_programt &dest, goto_programt::targett it)
goto_programt::targett value_assignments_if(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const if_exprt &rhs)
goto_programt::targett value_assignments_string_struct(goto_programt &dest, goto_programt::targett target, const exprt &lhs, const exprt &rhs)
void declare_define_locals(goto_programt &dest)
exprt make_val_or_dummy_rec(goto_programt &dest, goto_programt::targett ref_instr, const symbolt &symbol, const typet &source_type)
bool build_symbol_constant(const mp_integer &zero_length, const mp_integer &buf_size, exprt &dest)
goto_programt::targett abstract_assign(goto_programt &dest, goto_programt::targett it)
static typet build_type(whatt what)
goto_programt::targett abstract_pointer_assign(goto_programt &dest, goto_programt::targett it)
bool build_if(const if_exprt &o_if, exprt &dest, bool write)
const typet & build_abstraction_type_rec(const typet &type, const abstraction_types_mapt &known)
unsigned temporary_counter
void replace_string_macros(exprt &expr, bool lhs, const source_locationt &)
exprt build_unknown(whatt what, bool write)
string_abstractiont(symbol_tablet &_symbol_table, message_handlert &_message_handler)
void build_new_symbol(const symbolt &symbol, const irep_idt &identifier, const typet &type)
bool is_ptr_string_struct(const typet &type) const
message_handlert & message_handler
::std::map< typet, typet > abstraction_types_mapt
goto_programt initialization
goto_programt::targett value_assignments(goto_programt &dest, goto_programt::targett it, const exprt &lhs, const exprt &rhs)
symbol_exprt add_dummy_symbol_and_value(goto_programt &dest, goto_programt::targett ref_instr, const symbolt &symbol, const irep_idt &component_name, const typet &type, const typet &source_type)
bool build_wrap(const exprt &object, exprt &dest, bool write)
goto_programt::targett abstract_char_assign(goto_programt &dest, goto_programt::targett it)
bool build_array(const array_exprt &object, exprt &dest, bool write)
void apply(goto_modelt &goto_model)
Apply string abstraction to goto_model.
bool build_symbol(const symbol_exprt &sym, exprt &dest)
void move_lhs_arithmetic(exprt &lhs, exprt &rhs)
void operator()(goto_programt &dest)
abstraction_types_mapt abstraction_types_map
goto_programt::targett char_assign(goto_programt &dest, goto_programt::targett target, const exprt &new_lhs, const exprt &lhs, const exprt &rhs)
code_typet::parametert add_parameter(const symbolt &fct_symbol, const typet &type, const irep_idt &identifier)
bool build_pointer(const exprt &object, exprt &dest, bool write)
void abstract_function_call(goto_programt::targett it)
exprt member(const exprt &a, whatt what)
static bool has_string_macros(const exprt &expr)
void make_type(exprt &dest, const typet &type)
exprt build(const exprt &pointer, whatt what, bool write, const source_locationt &)
void make_decl_and_def(goto_programt &dest, goto_programt::targett ref_instr, const irep_idt &identifier, const irep_idt &source_sym)
void add_str_parameters(symbolt &fct_symbol, goto_functiont::parameter_identifierst ¶meter_identifiers)
bool is_char_type(const typet &type) const
symbol_tablet & symbol_table
const typet & build_abstraction_type(const typet &type)
Struct constructor from list of elements.
A struct tag type, i.e., struct_typet with an identifier.
Structure type, corresponds to C style structs.
Base type for structs and unions.
const componentst & components() const
std::vector< componentt > componentst
Expression to hold a symbol (variable)
std::vector< irep_idt > sorted_symbol_names() const
Build and return a lexicographically sorted vector of symbol names from all symbols stored in this sy...
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.
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.
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 pretty_name
Language-specific display name.
irep_idt irep_idt base_name
Name of module the symbol belongs to.
exprt value
Initial value of symbol.
irep_idt mode
Language mode.
The Boolean constant true.
Semantic type conversion.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
const typet & subtype() const
A union tag type, i.e., union_typet with an identifier.
#define forall_operands(it, expr)
#define Forall_operands(it, expr)
exprt boolean_negate(const exprt &src)
negate a Boolean expression, possibly removing a not_exprt, and swapping false and true
Deprecated expression utility functions.
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.
#define Forall_goto_program_instructions(it, program)
const std::string & id2string(const irep_idt &d)
const std::string integer2string(const mp_integer &n, unsigned base)
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.
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
exprt pointer_offset(const exprt &pointer)
Various predicates over pointers in programs.
static optionalt< smt_termt > get_identifier(const exprt &expr, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_handle_identifiers, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_identifiers)
#define PRECONDITION_WITH_DIAGNOSTICS(CONDITION,...)
#define CHECK_RETURN(CONDITION)
#define UNREACHABLE
This should be used to mark dead code.
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const array_exprt & to_array_expr(const exprt &expr)
Cast an exprt to an array_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_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.
bool is_constant(const typet &type)
This method tests, if the given typet is a constant.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
const tag_typet & to_tag_type(const typet &type)
Cast a typet to a tag_typet.
void string_abstraction(symbol_tablet &symbol_table, message_handlert &message_handler, goto_functionst &dest)
static bool is_ptr_argument(const typet &type)
const string_constantt & to_string_constant(const exprt &expr)