22 auto const maybe_upper_as_int = numeric_cast<mp_integer>(expr.
upper());
23 auto const maybe_lower_as_int = numeric_cast<mp_integer>(expr.
lower());
27 if(!maybe_upper_as_int.has_value() || !maybe_lower_as_int.has_value())
30 auto upper_as_int = maybe_upper_as_int.value();
31 auto lower_as_int = maybe_lower_as_int.value();
34 upper_as_int >= 0 && upper_as_int < src_bv.size(),
35 "upper end of extracted bits must be within the bitvector",
40 lower_as_int >= 0 && lower_as_int < src_bv.size(),
41 "lower end of extracted bits must be within the bitvector",
46 lower_as_int <= upper_as_int,
47 "upper bound must be greater or equal to lower bound");
52 (upper_as_int - lower_as_int + 1) == bv_width,
53 "the difference between upper and lower end of the range must have the " 54 "same width as the resulting bitvector type",
58 const std::size_t offset = numeric_cast_v<std::size_t>(lower_as_int);
60 bvt result_bv(src_bv.begin() + offset, src_bv.begin() + offset + bv_width);
boolbv_widtht boolbv_width
typet & type()
Return the type of the expression.
virtual const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width=nullopt)
#define DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
void conversion_failed(const exprt &expr, bvt &bv)
virtual bvt convert_extractbits(const extractbits_exprt &expr)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
std::vector< literalt > bvt