diff --git a/src/solvers/smt2/smt2_parser.cpp b/src/solvers/smt2/smt2_parser.cpp index 451436e04a0..add14229d3f 100644 --- a/src/solvers/smt2/smt2_parser.cpp +++ b/src/solvers/smt2/smt2_parser.cpp @@ -656,7 +656,7 @@ exprt smt2_parsert::function_application() if(next_token() != smt2_tokenizert::NUMERAL) throw error() << "expected numeral after " << id; - auto index = std::stoll(smt2_tokenizer.get_buffer()); + auto index = string2integer(smt2_tokenizer.get_buffer()); if(next_token() != smt2_tokenizert::CLOSE) throw error() << "expected ')' after " << id << " index"; @@ -681,21 +681,21 @@ exprt smt2_parsert::function_application() // we first convert to a signed type of the original width, // then extend to the new width, and then go to unsigned const auto width = to_unsignedbv_type(op[0].type()).get_width(); - const signedbv_typet small_signed_type(width); - const signedbv_typet large_signed_type(width + index); - const unsignedbv_typet unsigned_type(width + index); + const signedbv_typet small_signed_type{width}; + const signedbv_typet large_signed_type{width + index}; + const unsignedbv_typet unsigned_type{width + index}; return typecast_exprt( typecast_exprt( typecast_exprt(op[0], small_signed_type), large_signed_type), unsigned_type); } - else if(id=="zero_extend") + else if(id == ID_zero_extend) { auto width=to_unsignedbv_type(op[0].type()).get_width(); - unsignedbv_typet unsigned_type(width+index); + unsignedbv_typet unsigned_type{width + index}; - return typecast_exprt(op[0], unsigned_type); + return zero_extend_exprt{op[0], unsigned_type}; } else if(id == ID_repeat) { diff --git a/src/util/bitvector_types.h b/src/util/bitvector_types.h index 2f8a2c3b9ad..ba7a7cb7e67 100644 --- a/src/util/bitvector_types.h +++ b/src/util/bitvector_types.h @@ -107,6 +107,11 @@ class integer_bitvector_typet : public bitvector_typet { } + integer_bitvector_typet(const irep_idt &id, const mp_integer &width) + : bitvector_typet(id, width) + { + } + /// Return the smallest value that can be represented using this type. mp_integer smallest() const; /// Return the largest value that can be represented using this type. @@ -167,6 +172,11 @@ class unsignedbv_typet : public integer_bitvector_typet { } + explicit unsignedbv_typet(const mp_integer &width) + : integer_bitvector_typet(ID_unsignedbv, width) + { + } + static void check( const typet &type, const validation_modet vm = validation_modet::INVARIANT) @@ -216,6 +226,11 @@ class signedbv_typet : public integer_bitvector_typet { } + explicit signedbv_typet(const mp_integer &width) + : integer_bitvector_typet(ID_signedbv, width) + { + } + static void check( const typet &type, const validation_modet vm = validation_modet::INVARIANT)