diff --git a/src/ansi-c/expr2c.cpp b/src/ansi-c/expr2c.cpp index 96090faf7f2..5e8572e82b1 100644 --- a/src/ansi-c/expr2c.cpp +++ b/src/ansi-c/expr2c.cpp @@ -2219,10 +2219,7 @@ std::string expr2ct::convert_array( if(it==--src.operands().end()) break; - assert(it->is_constant()); - mp_integer i; - to_integer(*it, i); - unsigned int ch=integer2unsigned(i); + const unsigned int ch = numeric_cast_v(*it); if(last_was_hex) { diff --git a/src/solvers/flattening/boolbv_byte_update.cpp b/src/solvers/flattening/boolbv_byte_update.cpp index 71b92334a99..024128f1a79 100644 --- a/src/solvers/flattening/boolbv_byte_update.cpp +++ b/src/solvers/flattening/boolbv_byte_update.cpp @@ -60,7 +60,7 @@ bvt boolbvt::convert_byte_update(const byte_update_exprt &expr) bv_endianness_mapt map_op(op.type(), false, ns, boolbv_width); bv_endianness_mapt map_value(value.type(), false, ns, boolbv_width); - std::size_t offset_i=integer2unsigned(offset); + const std::size_t offset_i = numeric_cast_v(offset); for(std::size_t i=0; i(lower_as_int); bvt result_bv(src_bv.begin() + offset, src_bv.begin() + offset + bv_width); diff --git a/src/solvers/flattening/boolbv_replication.cpp b/src/solvers/flattening/boolbv_replication.cpp index c1e8c7068fb..25f13be6537 100644 --- a/src/solvers/flattening/boolbv_replication.cpp +++ b/src/solvers/flattening/boolbv_replication.cpp @@ -22,7 +22,7 @@ bvt boolbvt::convert_replication(const replication_exprt &expr) bvt bv; bv.resize(width); - const std::size_t u_times=integer2unsigned(times); + const std::size_t u_times = numeric_cast_v(times); const bvt &op = convert_bv(expr.op()); INVARIANT( diff --git a/src/solvers/flattening/boolbv_width.cpp b/src/solvers/flattening/boolbv_width.cpp index df8bac8821d..144387cfa19 100644 --- a/src/solvers/flattening/boolbv_width.cpp +++ b/src/solvers/flattening/boolbv_width.cpp @@ -141,7 +141,7 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const if(total>(1<<30)) // realistic limit throw analysis_exceptiont("array too large for flattening"); - entry.total_width=integer2unsigned(total); + entry.total_width = numeric_cast_v(total); } } else if(type_id==ID_vector) @@ -162,13 +162,13 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const if(total>(1<<30)) // realistic limit analysis_exceptiont("vector too large for flattening"); - entry.total_width=integer2unsigned(vector_size*sub_width); + entry.total_width = numeric_cast_v(vector_size * sub_width); } } else if(type_id==ID_complex) { - std::size_t sub_width=operator()(type.subtype()); - entry.total_width=integer2unsigned(2*sub_width); + const mp_integer sub_width = operator()(type.subtype()); + entry.total_width = numeric_cast_v(2 * sub_width); } else if(type_id==ID_code) { diff --git a/src/solvers/flattening/boolbv_with.cpp b/src/solvers/flattening/boolbv_with.cpp index 8a59abf0d5f..f8613af41eb 100644 --- a/src/solvers/flattening/boolbv_with.cpp +++ b/src/solvers/flattening/boolbv_with.cpp @@ -152,7 +152,8 @@ void boolbvt::convert_with_array( if(op1_value>=0 && op1_value(op1_value * op2_bv.size()); for(std::size_t j=0; j(i * op2_bv.size()); for(std::size_t j=0; j(num_elements); exprt::operandst op; op.reserve(width_bytes); @@ -567,10 +567,12 @@ exprt flatten_byte_update( // zero-extend the value, but only if needed exprt value_extended; - if(width>integer2unsigned(element_size)*8) + if(width > element_size * 8) value_extended = concatenation_exprt( from_integer( - 0, unsignedbv_typet(width - integer2unsigned(element_size) * 8)), + 0, + unsignedbv_typet( + width - numeric_cast_v(element_size) * 8)), src.value(), t); else diff --git a/src/solvers/qbf/qbf_qube_core.cpp b/src/solvers/qbf/qbf_qube_core.cpp index a9307b1c7a9..35d42f86b85 100644 --- a/src/solvers/qbf/qbf_qube_core.cpp +++ b/src/solvers/qbf/qbf_qube_core.cpp @@ -12,6 +12,7 @@ Author: CM Wintersteiger #include #include +#include #include #include @@ -78,9 +79,9 @@ propt::resultt qbf_qube_coret::prop_solve() { mp_integer b(line.substr(2).c_str()); if(b<0) - assignment[integer2unsigned(b.negate())]=false; + assignment[numeric_cast_v(b.negate())] = false; else - assignment[integer2unsigned(b)]=true; + assignment[numeric_cast_v(b)] = true; } else if(line=="s cnf 1") { diff --git a/src/util/arith_tools.cpp b/src/util/arith_tools.cpp index 8c307c1ccba..8422f42dbac 100644 --- a/src/util/arith_tools.cpp +++ b/src/util/arith_tools.cpp @@ -100,7 +100,7 @@ bool to_unsigned_integer(const constant_exprt &expr, unsigned &uint_value) return true; else { - uint_value=integer2unsigned(i); + uint_value = numeric_cast_v(i); return false; } } diff --git a/src/util/config.cpp b/src/util/config.cpp index 27f5f97e6f9..b7ad362da9e 100644 --- a/src/util/config.cpp +++ b/src/util/config.cpp @@ -1136,7 +1136,7 @@ static unsigned unsigned_from_ns( "symbol table configuration entry `" + id2string(id) + "' must be convertible to mp_integer"); - return integer2unsigned(int_value); + return numeric_cast_v(int_value); } void configt::set_from_symbol_table(