Go to the documentation of this file.
45 out << itr->first <<
":" << itr->second;
52 for(rw_range_sett::objectst::iterator it=
r_range_set.begin();
57 for(rw_range_sett::objectst::iterator it=
w_range_set.begin();
66 for(
const auto &read_object_entry :
get_r_set())
68 out <<
" " << read_object_entry.first;
69 read_object_entry.second->output(
ns, out);
76 for(
const auto &written_object_entry :
get_w_set())
78 out <<
" " << written_object_entry.first;
79 written_object_entry.second->output(
ns, out);
155 auto index = numeric_cast<mp_integer>(simp_offset);
157 range_start.
is_unknown() || !index.has_value() ||
158 !object_size_bits_opt.has_value())
165 if(*index >= *object_size_bits_opt)
170 be.
id()==ID_byte_extract_little_endian,
176 map.
map_bit(numeric_cast_v<std::size_t>(*index)));
202 const auto dist = numeric_cast<mp_integer>(simp_distance);
220 if(shift.
id()==ID_ashr || shift.
id()==ID_lshr)
223 sh_range_start+=dist_r;
225 range_spect sh_size=std::min(size, src_size-sh_range_start);
227 if(sh_range_start >=
range_spect{0} && sh_range_start < src_size)
230 if(src_size >= dist_r)
232 range_spect sh_size=std::min(size, src_size-dist_r);
248 type.
id() == ID_union || type.
id() == ID_union_tag ||
262 if(offset_bits.has_value())
265 offset += range_start;
277 if(expr.
array().
id() == ID_null_object)
283 if(type.
id()==ID_vector)
289 if(subtype_bits.has_value())
292 else if(type.
id()==ID_array)
298 if(subtype_bits.has_value())
306 const auto index = numeric_cast<mp_integer>(simp_index);
307 if(!index.has_value())
332 if(!subtype_bits.has_value())
352 if(full_r_s<=offset+sub_size && full_r_e>offset)
355 full_r_s <= offset ?
range_spect{0} : full_r_s - offset;
357 full_r_e>offset+sub_size ? sub_size : full_r_e-offset;
402 if(full_r_e.
is_unknown() || full_r_e > offset)
405 full_r_s <= offset ?
range_spect{0} : full_r_s - offset;
414 if(full_r_s<=offset+sub_size)
417 full_r_s <= offset ?
range_spect{0} : full_r_s - offset;
424 else if(full_r_s<=offset+sub_size && full_r_e>offset)
427 full_r_s <= offset ?
range_spect{0} : full_r_s - offset;
429 full_r_e>offset+sub_size ? sub_size : full_r_e-offset;
456 if(new_size<=range_start)
459 new_size-=range_start;
460 new_size=std::min(size, new_size);
469 object.
id() == ID_string_constant ||
object.
id() == ID_label ||
470 object.
id() == ID_array ||
object.
id() == ID_null_object ||
471 object.
id() == ID_symbol)
476 else if(
object.
id()==ID_dereference)
480 else if(
object.
id()==ID_index)
487 else if(
object.
id()==ID_member)
493 else if(
object.
id()==ID_if)
501 else if(
object.
id()==ID_byte_extract_little_endian ||
502 object.
id()==ID_byte_extract_big_endian)
508 else if(
object.
id()==ID_typecast)
515 throw "rw_range_sett: address_of '" +
object.id_string() +
"' not handled";
524 objectst::iterator entry=
527 std::pair<
const irep_idt &, std::unique_ptr<range_domain_baset>>(
528 identifier,
nullptr))
531 if(entry->second==
nullptr)
532 entry->second=util_make_unique<range_domaint>();
535 {range_start, range_end});
544 if(expr.
id() == ID_complex_real)
547 else if(expr.
id() == ID_complex_imag)
550 else if(expr.
id()==ID_typecast)
556 else if(expr.
id()==ID_if)
558 else if(expr.
id()==ID_dereference)
564 else if(expr.
id()==ID_byte_extract_little_endian ||
565 expr.
id()==ID_byte_extract_big_endian)
571 else if(expr.
id()==ID_shl ||
572 expr.
id()==ID_ashr ||
575 else if(expr.
id()==ID_member)
577 else if(expr.
id()==ID_index)
579 else if(expr.
id()==ID_array)
581 else if(expr.
id()==ID_struct)
583 else if(expr.
id()==ID_symbol)
598 range_start >= full_size)))
608 if(!size.is_unknown() && !full_size.
is_unknown())
609 range_end=std::min(range_end, full_size);
611 add(mode, identifier, range_start, range_end);
626 else if(expr.
id() == ID_null_object ||
627 expr.
id() == ID_string_constant)
637 throw "rw_range_sett: assignment to '" + expr.
id_string() +
"' not handled";
654 if(type.
id()==ID_array)
666 const exprt &pointer)
693 if(type_bits.has_value())
697 if(range_start.
is_unknown() || new_size <= range_start)
701 new_size -= range_start;
702 new_size = std::min(size, new_size);
708 if(
object.is_not_nil() && !
has_subexpr(
object, ID_dereference))
713 const namespacet &ns, std::ostream &out)
const
722 out << itr->first <<
":" << itr->second.first;
752 guard = std::move(copy);
762 objectst::iterator entry=
765 std::pair<
const irep_idt &, std::unique_ptr<range_domain_baset>>(
766 identifier,
nullptr))
769 if(entry->second==
nullptr)
770 entry->second=util_make_unique<guarded_range_domaint>();
796 if(statement == ID_printf)
799 for(
const auto &op : code.
operands())
805 else if(statement == ID_array_equal)
817 else if(statement == ID_array_set)
825 else if(statement == ID_array_copy || statement == ID_array_replace)
833 else if(statement == ID_havoc_object)
847 const exprt &function_expr,
858 for(
const auto &argument : arguments)
870 switch(target->type())
890 goto_rw_other(
function, target, target->get_other(), rw_set);
907 function, target, target->assign_lhs(), target->assign_rhs(), rw_set);
916 rw_set.
get_objects_rec(
function, target, target->decl_symbol().type());
926 target->call_function(),
927 target->call_arguments(),
939 goto_rw(
function, i_it, rw_set);
946 goto_functionst::function_mapt::const_iterator f_it=
953 goto_rw(f_it->first, body, rw_set);
#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 objectst & get_r_set() const
virtual void get_objects_if(get_modet mode, const if_exprt &if_expr, const range_spect &range_start, const range_spect &size)
virtual void get_objects_shift(get_modet mode, const shift_exprt &shift, const range_spect &range_start, const range_spect &size)
const exprt & skip_typecast(const exprt &expr)
find the expression nested inside typecasts, if any
bool has_subexpr(const exprt &expr, const std::function< bool(const exprt &)> &pred)
returns true if the expression has a subexpression that satisfies pred
sub_typet::const_iterator const_iterator
virtual void get_objects_address_of(const exprt &object)
virtual void get_objects_array(get_modet mode, const array_exprt &expr, const range_spect &range_start, const range_spect &size)
const array_exprt & to_array_expr(const exprt &expr)
Cast an exprt to an array_exprt.
void build(const exprt &expr, const namespacet &ns)
Given an expression expr, attempt to find the underlying object it represents by skipping over type c...
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
virtual void get_array_objects(const irep_idt &, goto_programt::const_targett, get_modet, const exprt &)
virtual void get_objects_byte_extract(get_modet mode, const byte_extract_exprt &be, const range_spect &range_start, const range_spect &size)
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
#define CHECK_RETURN(CONDITION)
optionalt< mp_integer > member_offset_bits(const struct_typet &type, const irep_idt &member, const namespacet &ns)
The type of an expression, extends irept.
virtual void get_objects_dereference(get_modet mode, const dereference_exprt &deref, const range_spect &range_start, const range_spect &size)
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Operator to dereference a pointer.
virtual void get_objects_typecast(get_modet mode, const typecast_exprt &tc, const range_spect &range_start, const range_spect &size)
The trinary if-then-else operator.
Split an expression into a base object and a (byte) offset.
Real part of the expression describing a complex number.
Data type to describe upper and lower bounds of the range of bits that a read or write access may aff...
Base class for all expressions.
bool is_true() const
Return whether the expression is a constant representing true.
virtual void get_objects_struct(get_modet mode, const struct_exprt &expr, const range_spect &range_start, const range_spect &size)
function_mapt function_map
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
void output(const namespacet &ns, std::ostream &out) const override
Expression to hold a symbol (variable)
virtual void get_objects_member(get_modet mode, const member_exprt &expr, const range_spect &range_start, const range_spect &size)
bool is_false() const
Return whether the expression is a constant representing false.
static const exprt & root_object(const exprt &expr)
const complex_real_exprt & to_complex_real_expr(const exprt &expr)
Cast an exprt to a complex_real_exprt.
Struct constructor from list of elements.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
void get_objects_rec(const irep_idt &_function, goto_programt::const_targett _target, get_modet mode, const exprt &expr) override
typet & type()
Return the type of the expression.
const array_typet & type() const
Expression classes for byte-level operators.
const typet & element_type() const
The type of the elements of the vector.
void get_objects_dereference(get_modet mode, const dereference_exprt &deref, const range_spect &range_start, const range_spect &size) override
virtual void get_objects_rec(const irep_idt &, goto_programt::const_targett, get_modet mode, const exprt &expr)
void get_objects_rec(const irep_idt &_function, goto_programt::const_targett _target, get_modet mode, const exprt &expr) override
#define forall_operands(it, expr)
const exprt & struct_op() const
void add(const exprt &expr)
#define PRECONDITION(CONDITION)
const irep_idt & get_identifier() const
optionalt< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
size_t map_bit(size_t bit) const
void add(get_modet mode, const irep_idt &identifier, const range_spect &range_start, const range_spect &range_end) override
virtual void add(get_modet mode, const irep_idt &identifier, const range_spect &range_start, const range_spect &range_end)
const std::string & id_string() const
virtual void get_objects_complex_imag(get_modet mode, const complex_imag_exprt &expr, const range_spect &range_start, const range_spect &size)
exprt simplify_expr(exprt src, const namespacet &ns)
virtual void get_objects_index(get_modet mode, const index_exprt &expr, const range_spect &range_start, const range_spect &size)
virtual ~range_domain_baset()
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
goto_programt::const_targett target
const irep_idt & id() const
std::vector< exprt > operandst
const complex_imag_exprt & to_complex_imag_expr(const exprt &expr)
Cast an exprt to a complex_imag_exprt.
void output(std::ostream &out) const
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
Extract member of struct or union.
Deprecated expression utility functions.
A collection of goto functions.
A base class for shift and rotate operators.
Structure type, corresponds to C style structs.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
static void goto_rw_other(const irep_idt &function, goto_programt::const_targett target, const codet &code, rw_range_sett &rw_set)
Imaginary part of the expression describing a complex number.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
Maps a big-endian offset to a little-endian offset.
A generic container class for the GOTO intermediate representation of one function.
const typet & subtype() const
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
virtual void get_objects_complex_real(get_modet mode, const complex_real_exprt &expr, const range_spect &range_start, const range_spect &size)
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
instructionst::const_iterator const_targett
static range_spect unknown()
static void goto_rw(const irep_idt &function, goto_programt::const_targett target, const exprt &lhs, const exprt &function_expr, const exprt::operandst &arguments, rw_range_sett &rw_set)
irep_idt get_component_name() const
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
virtual void output(const namespacet &ns, std::ostream &out) const override
void dereference(const irep_idt &function_id, goto_programt::const_targett target, exprt &expr, const namespacet &ns, value_setst &value_sets)
Remove dereferences in expr using value_sets to determine to what objects the pointers may be pointin...
Operator to return the address of an object.
Semantic type conversion.
sub_typet::const_iterator const_iterator
const irep_idt & get_statement() const
void get_objects_if(get_modet mode, const if_exprt &if_expr, const range_spect &range_start, const range_spect &size) override
static void goto_rw_assign(const irep_idt &function, goto_programt::const_targett target, const exprt &lhs, const exprt &rhs, rw_range_sett &rw_set)
Array constructor from list of elements.
std::string from_expr(const namespacet &ns, const irep_idt &identifier, const exprt &expr)
const objectst & get_w_set() const
#define forall_goto_program_instructions(it, program)
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
const typet & element_type() const
The type of the elements of the array.
static range_spect to_range_spect(const mp_integer &size)
Data structure for representing an arbitrary statement in a program.