22
22
#include < iomanip>
23
23
#include < stack>
24
24
#include < util/expr_iterator.h>
25
- #include < util/optional .h>
25
+ #include < util/arith_tools .h>
26
26
#include < util/simplify_expr.h>
27
27
#include < solvers/sat/satcheck.h>
28
28
#include < solvers/refinement/string_constraint_instantiation.h>
29
29
#include < java_bytecode/java_types.h>
30
- #include " expr_cast.h"
31
30
32
31
static exprt substitute_array_with_expr (const exprt &expr, const exprt &index);
33
32
@@ -852,7 +851,6 @@ static optionalt<exprt> get_array(
852
851
// / \return a string
853
852
static std::string string_of_array (const array_exprt &arr)
854
853
{
855
- unsigned n;
856
854
if (arr.type ().id ()!=ID_array)
857
855
return std::string (" " );
858
856
@@ -1010,7 +1008,7 @@ exprt fill_in_array_with_expr(
1010
1008
std::map<std::size_t , exprt> initial_map;
1011
1009
1012
1010
// Set the last index to be sure the array will have the right length
1013
- const auto &array_size_opt = expr_cast <std::size_t >(array_type.size ());
1011
+ const auto &array_size_opt = numeric_cast <std::size_t >(array_type.size ());
1014
1012
if (array_size_opt && *array_size_opt > 0 )
1015
1013
initial_map.emplace (
1016
1014
*array_size_opt - 1 ,
@@ -1022,7 +1020,8 @@ exprt fill_in_array_with_expr(
1022
1020
// statements
1023
1021
const with_exprt &with_expr = to_with_expr (it);
1024
1022
const exprt &then_expr=with_expr.new_value ();
1025
- const auto index =expr_cast_v<std::size_t >(with_expr.where ());
1023
+ const auto index =
1024
+ numeric_cast_v<std::size_t >(to_constant_expr (with_expr.where ()));
1026
1025
if (
1027
1026
index < string_max_length && (!array_size_opt || index < *array_size_opt))
1028
1027
initial_map.emplace (index , then_expr);
@@ -1047,7 +1046,7 @@ exprt fill_in_array_expr(const array_exprt &expr, std::size_t string_max_length)
1047
1046
1048
1047
// Map of the parts of the array that are initialized
1049
1048
std::map<std::size_t , exprt> initial_map;
1050
- const auto &array_size_opt = expr_cast <std::size_t >(array_type.size ());
1049
+ const auto &array_size_opt = numeric_cast <std::size_t >(array_type.size ());
1051
1050
1052
1051
if (array_size_opt && *array_size_opt > 0 )
1053
1052
initial_map.emplace (
@@ -1180,14 +1179,14 @@ static exprt negation_of_not_contains_constraint(
1180
1179
const exprt &ubu=axiom.univ_upper_bound ();
1181
1180
if (lbu.id ()==ID_constant && ubu.id ()==ID_constant)
1182
1181
{
1183
- const auto lb_int=expr_cast <mp_integer>(lbu);
1184
- const auto ub_int=expr_cast <mp_integer>(ubu);
1182
+ const auto lb_int = numeric_cast <mp_integer>(lbu);
1183
+ const auto ub_int = numeric_cast <mp_integer>(ubu);
1185
1184
if (!lb_int || !ub_int || *ub_int<=*lb_int)
1186
1185
return false_exprt ();
1187
1186
}
1188
1187
1189
- const auto lbe=expr_cast_v <mp_integer>(axiom.exists_lower_bound ());
1190
- const auto ube=expr_cast_v <mp_integer>(axiom.exists_upper_bound ());
1188
+ const auto lbe = numeric_cast_v <mp_integer>(axiom.exists_lower_bound ());
1189
+ const auto ube = numeric_cast_v <mp_integer>(axiom.exists_upper_bound ());
1191
1190
1192
1191
// If the premise is false, the implication is trivially true, so the
1193
1192
// negation is false.
@@ -1230,8 +1229,8 @@ static exprt negation_of_constraint(const string_constraintt &axiom)
1230
1229
const exprt &ub=axiom.upper_bound ();
1231
1230
if (lb.id ()==ID_constant && ub.id ()==ID_constant)
1232
1231
{
1233
- const auto lb_int=expr_cast <mp_integer>(lb);
1234
- const auto ub_int=expr_cast <mp_integer>(ub);
1232
+ const auto lb_int = numeric_cast <mp_integer>(lb);
1233
+ const auto ub_int = numeric_cast <mp_integer>(ub);
1235
1234
if (!lb_int || !ub_int || ub_int<=lb_int)
1236
1235
return false_exprt ();
1237
1236
}
@@ -1786,7 +1785,7 @@ static void add_to_index_set(
1786
1785
exprt i)
1787
1786
{
1788
1787
simplify (i, ns);
1789
- const bool is_size_t =expr_cast <std::size_t >(i).has_value ();
1788
+ const bool is_size_t = numeric_cast <std::size_t >(i).has_value ();
1790
1789
if (i.id ()!=ID_constant || is_size_t )
1791
1790
{
1792
1791
std::vector<exprt> sub_arrays;
@@ -2047,7 +2046,7 @@ exprt substitute_array_lists(exprt expr, size_t string_max_length)
2047
2046
{
2048
2047
const exprt &index =expr.operands ()[i];
2049
2048
const exprt &value=expr.operands ()[i+1 ];
2050
- const auto index_value=expr_cast <std::size_t >(index );
2049
+ const auto index_value = numeric_cast <std::size_t >(index );
2051
2050
if (!index .is_constant () ||
2052
2051
(index_value && *index_value<string_max_length))
2053
2052
ret_expr=with_exprt (ret_expr, index , value);
@@ -2097,7 +2096,7 @@ exprt string_refinementt::get(const exprt &expr) const
2097
2096
if (set.find (arr) != set.end ())
2098
2097
{
2099
2098
exprt length = super_get (arr.length ());
2100
- if (const auto n = expr_cast <std::size_t >(length))
2099
+ if (const auto n = numeric_cast <std::size_t >(length))
2101
2100
{
2102
2101
exprt arr_model =
2103
2102
array_exprt (array_typet (arr.type ().subtype (), length));
0 commit comments