diff --git a/src/solvers/flattening/bv_pointers.cpp b/src/solvers/flattening/bv_pointers.cpp index 7517a6d664f..86f0361cb89 100644 --- a/src/solvers/flattening/bv_pointers.cpp +++ b/src/solvers/flattening/bv_pointers.cpp @@ -816,18 +816,14 @@ exprt bv_pointerst::bv_get_rec( bvrep, pointer_logic.pointer_expr(pointer, pt)}; } -bvt bv_pointerst::encode(std::size_t addr, const pointer_typet &type) const +bvt bv_pointerst::encode(const mp_integer &addr, const pointer_typet &type) + const { const std::size_t offset_bits = get_offset_width(type); const std::size_t object_bits = get_object_width(type); bvt zero_offset(offset_bits, const_literal(false)); - - // set variable part - bvt object; - object.reserve(object_bits); - for(std::size_t i=0; i &o) const +void pointer_logict::get_dynamic_objects(std::vector &o) const { o.clear(); - std::size_t nr=0; + mp_integer nr = 0; for(auto it = objects.cbegin(); it != objects.cend(); ++it, ++nr) if(is_dynamic_object(*it)) o.push_back(nr); } -std::size_t pointer_logict::add_object(const exprt &expr) +mp_integer pointer_logict::add_object(const exprt &expr) { // remove any index/member @@ -58,11 +58,10 @@ std::size_t pointer_logict::add_object(const exprt &expr) } exprt pointer_logict::pointer_expr( - std::size_t object, + const mp_integer &object, const pointer_typet &type) const { - pointert pointer(object, 0); - return pointer_expr(pointer, type); + return pointer_expr({object, 0}, type); } exprt pointer_logict::pointer_expr( @@ -89,10 +88,11 @@ exprt pointer_logict::pointer_expr( if(pointer.object>=objects.size()) { - return constant_exprt("INVALID-" + std::to_string(pointer.object), type); + return constant_exprt("INVALID-" + integer2string(pointer.object), type); } - const exprt &object_expr=objects[pointer.object]; + const exprt &object_expr = + objects[numeric_cast_v(pointer.object)]; typet subtype = type.base_type(); // This is a gcc extension. diff --git a/src/solvers/flattening/pointer_logic.h b/src/solvers/flattening/pointer_logic.h index 8736c4ae28c..27578cb33d1 100644 --- a/src/solvers/flattening/pointer_logic.h +++ b/src/solvers/flattening/pointer_logic.h @@ -27,14 +27,14 @@ class pointer_logict struct pointert { - std::size_t object; - mp_integer offset; + mp_integer object, offset; pointert() { } - pointert(std::size_t _obj, mp_integer _off):object(_obj), offset(_off) + pointert(mp_integer _obj, mp_integer _off) + : object(std::move(_obj)), offset(std::move(_off)) { } }; @@ -45,34 +45,32 @@ class pointer_logict const pointer_typet &type) const; /// Convert an (object,0) pair to an expression - exprt pointer_expr( - std::size_t object, - const pointer_typet &type) const; + exprt pointer_expr(const mp_integer &object, const pointer_typet &type) const; ~pointer_logict(); explicit pointer_logict(const namespacet &_ns); - std::size_t add_object(const exprt &expr); + mp_integer add_object(const exprt &expr); /// \return number of NULL object - std::size_t get_null_object() const + const mp_integer &get_null_object() const { return null_object; } /// \return number of INVALID object - std::size_t get_invalid_object() const + const mp_integer &get_invalid_object() const { return invalid_object; } bool is_dynamic_object(const exprt &expr) const; - void get_dynamic_objects(std::vector &objects) const; + void get_dynamic_objects(std::vector &objects) const; protected: const namespacet &ns; - std::size_t null_object, invalid_object; + mp_integer null_object, invalid_object; }; #endif // CPROVER_SOLVERS_FLATTENING_POINTER_LOGIC_H diff --git a/src/solvers/smt2/smt2_conv.cpp b/src/solvers/smt2/smt2_conv.cpp index b3044b21f2b..f75c577d0ec 100644 --- a/src/solvers/smt2/smt2_conv.cpp +++ b/src/solvers/smt2/smt2_conv.cpp @@ -3151,7 +3151,7 @@ void smt2_convt::convert_mod(const mod_exprt &expr) void smt2_convt::convert_is_dynamic_object(const unary_exprt &expr) { - std::vector dynamic_objects; + std::vector dynamic_objects; pointer_logic.get_dynamic_objects(dynamic_objects); if(dynamic_objects.empty())