20 #define ENABLE_ARRAY_FIELD_SENSITIVITY
29 return std::move(ssa_expr);
40 if(expr.
id() != ID_address_of)
51 !
write && expr.
id() == ID_member &&
56 #ifdef ENABLE_ARRAY_FIELD_SENSITIVITY
58 !
write && expr.
id() == ID_index &&
64 else if(expr.
id() == ID_member)
89 return apply(ns, state, std::move(tmp),
write);
93 !
write && (expr.
id() == ID_byte_extract_little_endian ||
94 expr.
id() == ID_byte_extract_big_endian))
99 be.
op().
type().
id() == ID_union_tag) &&
112 auto recursive_member =
115 recursive_member.has_value() &&
116 (recursive_member->id() == ID_member ||
117 recursive_member->id() == ID_index))
124 ns, state, state.
rename(std::move(tmp), ns).get(),
write);
127 return apply(ns, state, std::move(tmp),
write);
130 recursive_member.has_value() && recursive_member->id() == ID_typecast)
137 state.
rename(std::move(*recursive_member), ns).get(),
141 return apply(ns, state, std::move(*recursive_member),
write);
146 #ifdef ENABLE_ARRAY_FIELD_SENSITIVITY
147 else if(expr.
id() == ID_index)
165 l2_index.simplify(ns);
175 if(array_from_symbol_table !=
nullptr)
184 if(l2_index.get().is_constant())
196 ns, state, state.
rename(std::move(tmp), ns).get(),
write);
199 return apply(ns, state, std::move(tmp),
write);
204 exprt expanded_array =
219 bool disjoined_fields_only)
const
222 ssa_expr.
type().
id() == ID_struct ||
223 ssa_expr.
type().
id() == ID_struct_tag ||
224 (!disjoined_fields_only && (ssa_expr.
type().
id() == ID_union ||
225 ssa_expr.
type().
id() == ID_union_tag)))
228 (ssa_expr.
type().
id() == ID_struct_tag ||
229 ssa_expr.
type().
id() == ID_union_tag)
235 fields.reserve(components.size());
239 for(
const auto &comp : components)
249 fields.emplace_back(state.
rename(std::move(field), ns).get());
252 fields.emplace_back(std::move(field));
256 disjoined_fields_only && (ssa_expr.
type().
id() == ID_struct ||
257 ssa_expr.
type().
id() == ID_struct_tag))
264 #ifdef ENABLE_ARRAY_FIELD_SENSITIVITY
266 ssa_expr.
type().
id() == ID_array &&
269 const mp_integer mp_array_size = numeric_cast_v<mp_integer>(
275 const std::size_t array_size = numeric_cast_v<std::size_t>(mp_array_size);
278 elements.reserve(array_size);
282 for(std::size_t i = 0; i < array_size; ++i)
292 elements.emplace_back(state.
rename(std::move(element), ns).get());
295 elements.emplace_back(std::move(element));
298 if(disjoined_fields_only)
314 bool allow_pointer_unsoundness)
const
321 ns, state, lhs_fs, rhs, target, allow_pointer_unsoundness);
347 const exprt &ssa_rhs,
349 bool allow_pointer_unsoundness)
const
356 .
assignment(l1_lhs, ssa_rhs, ns,
true,
true, allow_pointer_unsoundness)
378 ssa_rhs.
type().
id() == ID_struct || ssa_rhs.
type().
id() == ID_struct_tag)
381 ssa_rhs.
type().
id() == ID_struct_tag
387 components.empty() ||
390 exprt::operandst::const_iterator fs_it = lhs_fs.
operands().begin();
391 for(
const auto &comp : components)
399 const exprt &member_lhs = *fs_it;
402 expr_try_dynamic_cast<field_sensitive_ssa_exprt>(member_lhs))
407 fs_ssa->get_object_ssa(),
410 allow_pointer_unsoundness);
414 ns, state, member_lhs, member_rhs, target, allow_pointer_unsoundness);
419 ssa_rhs.
type().
id() == ID_union || ssa_rhs.
type().
id() == ID_union_tag)
422 ssa_rhs.
type().
id() == ID_union_tag
428 components.empty() ||
431 exprt::operandst::const_iterator fs_it = lhs_fs.
operands().begin();
432 for(
const auto &comp : components)
443 const exprt &member_lhs = *fs_it;
446 expr_try_dynamic_cast<field_sensitive_ssa_exprt>(member_lhs))
451 fs_ssa->get_object_ssa(),
454 allow_pointer_unsoundness);
458 ns, state, member_lhs, member_rhs, target, allow_pointer_unsoundness);
462 #ifdef ENABLE_ARRAY_FIELD_SENSITIVITY
463 else if(
const auto &type = type_try_dynamic_cast<array_typet>(ssa_rhs.
type()))
465 const std::size_t array_size =
472 exprt::operandst::const_iterator fs_it = lhs_fs.
operands().begin();
473 for(std::size_t i = 0; i < array_size; ++i)
482 const exprt &index_lhs = *fs_it;
485 expr_try_dynamic_cast<field_sensitive_ssa_exprt>(index_lhs))
490 fs_ssa->get_object_ssa(),
493 allow_pointer_unsoundness);
497 ns, state, index_lhs, index_rhs, target, allow_pointer_unsoundness);
508 exprt::operandst::const_iterator fs_it = lhs_fs.
operands().begin();
511 if(
auto fs_ssa = expr_try_dynamic_cast<field_sensitive_ssa_exprt>(*fs_it))
516 fs_ssa->get_object_ssa(),
519 allow_pointer_unsoundness);
523 ns, state, *fs_it, op, target, allow_pointer_unsoundness);
535 bool disjoined_fields_only)
const
537 if(expr.
type().
id() == ID_struct || expr.
type().
id() == ID_struct_tag)
540 #ifdef ENABLE_ARRAY_FIELD_SENSITIVITY
542 expr.
type().
id() == ID_array &&
552 !disjoined_fields_only &&
553 (expr.
type().
id() == ID_union || expr.
type().
id() == ID_union_tag))
byte_extract_exprt make_byte_extract(const exprt &_op, const exprt &_offset, const typet &_type)
Construct a byte_extract_exprt with endianness and byte width matching the current configuration.
Expression classes for byte-level operators.
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
bitvector_typet c_index_type()
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
Array constructor from list of elements.
typet index_type() const
The type of the index expressions into any instance of this type.
const exprt & size() const
Base class for all expressions.
std::vector< exprt > operandst
bool has_operands() const
Return true if there is at least one operand.
typet & type()
Return the type of the expression.
bool is_constant() const
Return whether the expression is a constant.
const bool should_simplify
exprt simplify_opt(exprt e, const namespacet &ns) const
const std::size_t max_field_sensitivity_array_size
exprt get_fields(const namespacet &ns, goto_symex_statet &state, const ssa_exprt &ssa_expr, bool disjoined_fields_only) const
Compute an expression representing the individual components of a field-sensitive SSA representation ...
void field_assignments_rec(const namespacet &ns, goto_symex_statet &state, const exprt &lhs_fs, const exprt &ssa_rhs, symex_targett &target, bool allow_pointer_unsoundness) const
Assign to the individual fields lhs_fs of a non-expanded symbol lhs.
exprt apply(const namespacet &ns, goto_symex_statet &state, exprt expr, bool write) const
Turn an expression expr into a field-sensitive SSA expression.
void field_assignments(const namespacet &ns, goto_symex_statet &state, const ssa_exprt &lhs, const exprt &rhs, symex_targett &target, bool allow_pointer_unsoundness) const
Assign to the individual fields of a non-expanded symbol lhs.
bool is_divisible(const ssa_exprt &expr, bool disjoined_fields_only) const
Determine whether expr would translate to an atomic SSA expression (returns false) or a composite obj...
sharing_mapt< irep_idt, exprt > propagation
value_sett value_set
Uses level 1 names, and is used to do dereferencing.
Central data structure: state.
renamedt< ssa_exprt, L2 > assignment(ssa_exprt lhs, const exprt &rhs, const namespacet &ns, bool rhs_is_simplified, bool record_value, bool allow_pointer_unsoundness=false)
renamedt< exprt, level > rename(exprt expr, const namespacet &ns)
Rewrites symbol expressions in exprt, applying a suffix to each symbol reflecting its most recent ver...
symex_targett::sourcet source
const irep_idt & get(const irep_idt &name) const
const irep_idt & id() const
Extract member of struct or union.
const exprt & struct_op() const
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
const symbol_table_baset & get_symbol_table() const
Return first symbol table registered with the namespace.
Expression providing an SSA-renamed symbol of expressions.
void set_expression(exprt expr)
Replace the underlying, original expression by expr while maintaining SSA indices.
const irep_idt get_level_2() const
const exprt & get_original_expr() const
Struct constructor from list of elements.
Structure type, corresponds to C style structs.
const componentst & components() const
std::vector< componentt > componentst
const irep_idt & get_identifier() const
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
typet type
Type of symbol.
The interface of the target container for symbolic execution to record its symbolic steps into.
virtual void assignment(const exprt &guard, const ssa_exprt &ssa_lhs, const exprt &ssa_full_lhs, const exprt &original_full_lhs, const exprt &ssa_rhs, const sourcet &source, assignment_typet assignment_type)=0
Write to a local variable.
void erase_symbol(const symbol_exprt &symbol_expr, const namespacet &ns)
#define Forall_operands(it, expr)
std::optional< exprt > get_subexpression_at_offset(const exprt &expr, const mp_integer &offset_bytes, const typet &target_type_raw, const namespacet &ns)
bool simplify(exprt &expr, const namespacet &ns)
exprt simplify_expr(exprt src, const namespacet &ns)
#define UNREACHABLE
This should be used to mark dead code.
#define PRECONDITION(CONDITION)
const ssa_exprt & to_ssa_expr(const exprt &expr)
Cast a generic exprt to an ssa_exprt.
bool is_ssa_expr(const exprt &expr)
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
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 struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const struct_or_union_tag_typet & to_struct_or_union_tag_type(const typet &type)
Cast a typet to a struct_or_union_tag_typet.
Generate Equation using Symbolic Execution.
ssize_t write(int fildes, const void *buf, size_t nbyte)