diff --git a/src/goto-programs/json_expr.cpp b/src/goto-programs/json_expr.cpp index 16139131b90..4be5606f613 100644 --- a/src/goto-programs/json_expr.cpp +++ b/src/goto-programs/json_expr.cpp @@ -53,7 +53,7 @@ static exprt simplify_json_expr(const exprt &src) } else if( object.id() == ID_index && to_index_expr(object).index().is_constant() && - to_constant_expr(to_index_expr(object).index()).value_is_zero_string()) + to_constant_expr(to_index_expr(object).index()).is_zero()) { // simplify expressions of the form &array[0] return simplify_json_expr(to_index_expr(object).array()); diff --git a/src/util/simplify_expr_int.cpp b/src/util/simplify_expr_int.cpp index 2087564a387..a80bf66dc89 100644 --- a/src/util/simplify_expr_int.cpp +++ b/src/util/simplify_expr_int.cpp @@ -777,7 +777,7 @@ simplify_exprt::simplify_bitwise(const multi_ary_exprt &expr) } else if( it->is_constant() && it->type().id() == ID_bv && - to_constant_expr(*it).value_is_zero_string() && + *it == to_bv_type(it->type()).all_zeros_expr() && new_expr.operands().size() > 1) { it = new_expr.operands().erase(it); diff --git a/src/util/std_expr.h b/src/util/std_expr.h index d9ca4f64bab..a9cc349741d 100644 --- a/src/util/std_expr.h +++ b/src/util/std_expr.h @@ -3005,8 +3005,6 @@ class constant_exprt : public nullary_exprt set(ID_value, value); } - bool value_is_zero_string() const; - /// Returns true if \p expr has a pointer type and a value NULL; it also /// returns true when \p expr has value zero and NULL_is_zero is true; returns /// false in all other cases. @@ -3023,6 +3021,9 @@ class constant_exprt : public nullary_exprt { check(expr, vm); } + +protected: + bool value_is_zero_string() const; }; template <> diff --git a/unit/goto-symex/goto_symex_state.cpp b/unit/goto-symex/goto_symex_state.cpp index 8e5d02395e6..7d76dd61fab 100644 --- a/unit/goto-symex/goto_symex_state.cpp +++ b/unit/goto-symex/goto_symex_state.cpp @@ -172,8 +172,7 @@ SCENARIO( const symbol_exprt object_symbol = to_symbol_expr(object_descriptor->object()); REQUIRE(object_symbol.get_identifier() == "int_value!0"); - REQUIRE(to_constant_expr(object_descriptor->offset()) - .value_is_zero_string()); + REQUIRE(to_constant_expr(object_descriptor->offset()).is_zero()); } THEN("The target equations are unchanged") {