diff --git a/src/util/bitvector_expr.h b/src/util/bitvector_expr.h index 727ad213c10..694dded3873 100644 --- a/src/util/bitvector_expr.h +++ b/src/util/bitvector_expr.h @@ -37,7 +37,7 @@ class bswap_exprt : public unary_exprt void set_bits_per_byte(std::size_t bits_per_byte) { - set(ID_bits_per_byte, narrow_cast(bits_per_byte)); + set_size_t(ID_bits_per_byte, bits_per_byte); } }; diff --git a/src/util/bitvector_types.h b/src/util/bitvector_types.h index 4193031e5eb..777123354ba 100644 --- a/src/util/bitvector_types.h +++ b/src/util/bitvector_types.h @@ -273,7 +273,7 @@ class fixedbv_typet : public bitvector_typet void set_integer_bits(std::size_t b) { - set(ID_integer_bits, narrow_cast(b)); + set_size_t(ID_integer_bits, b); } static void check( @@ -335,7 +335,7 @@ class floatbv_typet : public bitvector_typet void set_f(std::size_t b) { - set(ID_f, narrow_cast(b)); + set_size_t(ID_f, b); } static void check( diff --git a/src/util/irep.cpp b/src/util/irep.cpp index 579b2978957..4261928b76d 100644 --- a/src/util/irep.cpp +++ b/src/util/irep.cpp @@ -90,6 +90,15 @@ void irept::set(const irep_namet &name, const long long value) #endif } +void irept::set_size_t(const irep_namet &name, const std::size_t value) +{ +#ifdef USE_DSTRING + add(name).id(to_dstring(value)); +#else + add(name).id(std::to_string(value)); +#endif +} + void irept::remove(const irep_namet &name) { #if NAMED_SUB_IS_FORWARD_LIST diff --git a/src/util/irep.h b/src/util/irep.h index 1fbdd96cac4..43a0863639c 100644 --- a/src/util/irep.h +++ b/src/util/irep.h @@ -437,6 +437,7 @@ class irept add(name, std::move(irep)); } void set(const irep_namet &name, const long long value); + void set_size_t(const irep_namet &name, const std::size_t value); void remove(const irep_namet &name); void move_to_sub(irept &irep); diff --git a/src/util/std_expr.h b/src/util/std_expr.h index 3988f8b0777..79a0b8f297b 100644 --- a/src/util/std_expr.h +++ b/src/util/std_expr.h @@ -15,7 +15,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr_cast.h" #include "invariant.h" -#include "narrow.h" #include "std_types.h" /// An expression without operands @@ -1539,7 +1538,7 @@ class union_exprt:public unary_exprt void set_component_number(std::size_t component_number) { - set(ID_component_number, narrow_cast(component_number)); + set_size_t(ID_component_number, component_number); } }; diff --git a/src/util/std_types.h b/src/util/std_types.h index 3c91431fe60..2ac86c57087 100644 --- a/src/util/std_types.h +++ b/src/util/std_types.h @@ -18,7 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "invariant.h" #include "mp_arith.h" #include "validate.h" -#include #include @@ -842,7 +841,7 @@ class bitvector_typet : public typet void set_width(std::size_t width) { - set(ID_width, narrow_cast(width)); + set_size_t(ID_width, width); } static void check(