Go to the documentation of this file.
28 const typet &array_op_type = array.
type();
32 if(array_op_type.
id()==ID_array)
53 final_array.
id() == ID_symbol || final_array.
id() == ID_nondet_symbol)
57 final_array.
get(ID_identifier),
59 array_width_opt.value_or(0));
73 if(array.
id() == ID_symbol || array.
id() == ID_nondet_symbol)
77 array.
get(ID_identifier), array_type, array_width_opt.value_or(0));
95 auto maybe_index_value = numeric_cast<mp_integer>(index);
96 if(maybe_index_value.has_value())
106 #define UNIFORM_ARRAY_HACK
107 #ifdef UNIFORM_ARRAY_HACK
108 bool is_uniform = array.
id() == ID_array_of;
110 if(array.
id() == ID_constant || array.
id() == ID_array)
112 is_uniform = array.
operands().size() <= 1 ||
116 [&array](
const exprt &expr) {
117 return expr == to_multi_ary_expr(array).op0();
123 static int uniform_array_counter;
125 const std::string identifier =
CPROVER_PREFIX "internal_uniform_array_" +
143 and_exprt range_condition(std::move(lower_bound), std::move(upper_bound));
145 std::move(range_condition), std::move(value_equality));
155 #define ACTUAL_ARRAY_HACK
156 #ifdef ACTUAL_ARRAY_HACK
159 if((array.
id()==ID_constant || array.
id()==ID_array) &&
162 #ifdef CONSTANT_ARRAY_HACK
167 static int actual_array_counter;
169 const std::string identifier =
CPROVER_PREFIX "internal_actual_array_" +
177 #ifdef COMPACT_EQUAL_CONST
182 exprt::operandst::const_iterator it = array.
operands().begin();
188 "this loop iterates over the array, so `it` shouldn't be increased "
189 "past the array's end");
211 const bvt &array_bv =
212 convert_bv(array, numeric_cast_v<std::size_t>(array_size * width));
224 #ifdef COMPACT_EQUAL_CONST
229 equal_bv.resize(width);
235 for(std::size_t j=0; j<width; j++)
237 bv[j], array_bv[numeric_cast_v<std::size_t>(offset + j)]);
248 #ifdef COMPACT_EQUAL_CONST
256 "non-positive array sizes are forbidden in goto programs");
265 for(std::size_t j=0; j<width; j++)
267 literalt l = array_bv[numeric_cast_v<std::size_t>(offset + j)];
317 std::size_t offset_int = numeric_cast_v<std::size_t>(offset);
318 return bvt(tmp.begin() + offset_int, tmp.begin() + offset_int + width);
320 else if(array.
id() == ID_member || array.
id() == ID_index)
328 const auto subtype_bytes_opt =
343 array.
id() == ID_byte_extract_big_endian ||
344 array.
id() == ID_byte_extract_little_endian)
348 const auto subtype_bytes_opt =
355 byte_extract_expr.
offset(),
357 index * (*subtype_bytes_opt), byte_extract_expr.
offset().
type())},
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.
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...
virtual bvt new_variables(std::size_t width)
generates a bitvector of given width with new variables
bool is_unbounded_array(const typet &type) const override
#define CHECK_RETURN(CONDITION)
The type of an expression, extends irept.
std::vector< literalt > bvt
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.
bool has_byte_operator(const exprt &src)
const bvt & get_literals(const irep_idt &identifier, const typet &type, std::size_t width)
Split an expression into a base object and a (byte) offset.
The plus expression Associativity is not specified.
virtual bvt convert_index(const exprt &array, const mp_integer &index)
index operator with constant index
Base class for all expressions.
void l_set_to_true(literalt a)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
Expression to hold a symbol (variable)
virtual literalt land(literalt a, literalt b)=0
virtual optionalt< std::size_t > get_width_opt(const typet &type) const
static const exprt & root_object(const exprt &expr)
const irep_idt & get(const irep_idt &name) const
const exprt & size() const
typet & type()
Return the type of the expression.
Expression classes for byte-level operators.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
bool has_operands() const
Return true if there is at least one operand.
virtual literalt limplies(literalt a, literalt b)=0
virtual std::size_t boolbv_width(const typet &type) const
virtual const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
static exprt implication(exprt lhs, exprt rhs)
exprt lower_byte_operators(const exprt &src, const namespacet &ns)
Rewrite an expression possibly containing byte-extract or -update expressions to more fundamental ope...
exprt simplify_expr(exprt src, const namespacet &ns)
const irep_idt & id() const
void record_array_index(const index_exprt &expr)
literalt convert(const exprt &expr) override
Convert a Boolean expression and return the corresponding literal.
virtual literalt lequal(literalt a, literalt b)=0
optionalt< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
A base class for relations, i.e., binary predicates whose two operands have the same type.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
virtual bool has_set_to() const
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
virtual literalt lselect(literalt a, literalt b, literalt c)=0
const typet & element_type() const
The type of the elements of the array.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.