Go to the documentation of this file.
10 #ifndef CPROVER_UTIL_ARITH_TOOLS_H
11 #define CPROVER_UTIL_ARITH_TOOLS_H
31 template <
typename Target,
typename =
void>
42 if(expr.
id() != ID_constant)
61 typename std::enable_if<std::is_integral<T>::value>::type>
65 template <
typename U = T,
66 typename std::enable_if<std::is_signed<U>::value,
int>::type = 0>
73 template <
typename U = T,
74 typename std::enable_if<!std::is_signed<U>::value,
int>::type = 0>
77 return mpi.to_ulong();
85 std::numeric_limits<T>::max() <=
86 std::numeric_limits<decltype(get_val(mpi))>::max() &&
87 std::numeric_limits<T>::min() >=
88 std::numeric_limits<decltype(get_val(mpi))>::min(),
89 "Numeric cast only works for types smaller than long long");
92 mpi <= std::numeric_limits<T>::max() &&
93 mpi >= std::numeric_limits<T>::min())
95 return static_cast<T
>(get_val(mpi));
103 if(expr.
id() == ID_constant)
124 template <
typename Target>
135 template <
typename Target>
139 INVARIANT(maybe,
"mp_integer should be convertible to target integral type");
148 template <
typename Target>
154 "expression should be convertible to target integral type",
173 std::size_t bit_index);
176 make_bvrep(
const std::size_t width,
const std::function<
bool(std::size_t)> f);
181 #endif // CPROVER_UTIL_ARITH_TOOLS_H
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
The type of an expression, extends irept.
bool is_signed(const typet &t)
Convenience function – is the type signed?
Base class for all expressions.
Numerical cast provides a unified way of converting from one numerical type to another.
Convert expression to mp_integer.
#define INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
Same as invariant, with one or more diagnostics attached Diagnostics can be of any type that has a sp...
optionalt< T > operator()(const mp_integer &mpi) const
static auto get_val(const mp_integer &mpi) -> decltype(mpi.to_long())
optionalt< T > operator()(const exprt &expr) const
optionalt< T > operator()(const constant_exprt &expr) const
const irep_idt & id() const
nonstd::optional< T > optionalt
static auto get_val(const mp_integer &mpi) -> decltype(mpi.to_ulong())
optionalt< mp_integer > operator()(const exprt &expr) const
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
optionalt< mp_integer > operator()(const constant_exprt &expr) const
A constant literal expression.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.