Skip to content

Commit 42b70b2

Browse files
committed
Move is_null_pointer to constant_exprt
Removes one of the functions from the expr_util translation unit that is supposed to be deprecated.
1 parent 4ae54e6 commit 42b70b2

27 files changed

+62
-57
lines changed

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ void custom_bitvector_domaint::transform(
349349
{
350350
if(
351351
lhs.is_constant() &&
352-
is_null_pointer(to_constant_expr(lhs))) // NULL means all
352+
to_constant_expr(lhs).is_null_pointer()) // NULL means all
353353
{
354354
if(mode==modet::CLEAR_MAY)
355355
{
@@ -478,7 +478,7 @@ void custom_bitvector_domaint::transform(
478478
{
479479
if(
480480
lhs.is_constant() &&
481-
is_null_pointer(to_constant_expr(lhs))) // NULL means all
481+
to_constant_expr(lhs).is_null_pointer()) // NULL means all
482482
{
483483
if(mode==modet::CLEAR_MAY)
484484
{
@@ -716,7 +716,7 @@ exprt custom_bitvector_domaint::eval(
716716

717717
if(
718718
pointer.is_constant() &&
719-
is_null_pointer(to_constant_expr(pointer))) // NULL means all
719+
to_constant_expr(pointer).is_null_pointer()) // NULL means all
720720
{
721721
if(src.id() == ID_get_may)
722722
{

src/analyses/invariant_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ std::string inv_object_storet::build_string(const exprt &expr) const
121121
if(expr.is_constant())
122122
{
123123
// NULL?
124-
if(is_null_pointer(to_constant_expr(expr)))
124+
if(to_constant_expr(expr).is_null_pointer())
125125
return "0";
126126

127127
const auto i = numeric_cast<mp_integer>(expr);

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,13 +1672,13 @@ void c_typecheck_baset::typecheck_expr_trinary(if_exprt &expr)
16721672
// (at least that's how GCC behaves)
16731673
if(
16741674
to_pointer_type(operands[1].type()).base_type().id() == ID_empty &&
1675-
tmp1.is_constant() && is_null_pointer(to_constant_expr(tmp1)))
1675+
tmp1.is_constant() && to_constant_expr(tmp1).is_null_pointer())
16761676
{
16771677
implicit_typecast(operands[1], operands[2].type());
16781678
}
16791679
else if(
16801680
to_pointer_type(operands[2].type()).base_type().id() == ID_empty &&
1681-
tmp2.is_constant() && is_null_pointer(to_constant_expr(tmp2)))
1681+
tmp2.is_constant() && to_constant_expr(tmp2).is_null_pointer())
16821682
{
16831683
implicit_typecast(operands[2], operands[1].type());
16841684
}

src/ansi-c/expr2c.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/c_types.h>
1414
#include <util/config.h>
1515
#include <util/cprover_prefix.h>
16-
#include <util/expr_util.h>
1716
#include <util/find_symbols.h>
1817
#include <util/fixedbv.h>
1918
#include <util/floatbv_expr.h>
@@ -1983,7 +1982,7 @@ std::string expr2ct::convert_constant(
19831982
}
19841983
else if(type.id()==ID_pointer)
19851984
{
1986-
if(is_null_pointer(src))
1985+
if(src.is_null_pointer())
19871986
{
19881987
if(configuration.use_library_macros)
19891988
dest = "NULL";

src/cpp/cpp_typecheck_conversions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ bool cpp_typecheckt::standard_conversion_pointer_to_member(
603603
if(expr.get_bool(ID_C_lvalue))
604604
return false;
605605

606-
if(expr.is_constant() && is_null_pointer(to_constant_expr(expr)))
606+
if(expr.is_constant() && to_constant_expr(expr).is_null_pointer())
607607
{
608608
new_expr = typecast_exprt::conditional_cast(expr, type);
609609
return true;

src/cprover/bv_pointers_wide.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ bvt bv_pointers_widet::convert_pointer_type(const exprt &expr)
387387
{
388388
const constant_exprt &c = to_constant_expr(expr);
389389

390-
if(is_null_pointer(c))
390+
if(c.is_null_pointer())
391391
return encode(pointer_logic.get_null_object(), type);
392392
else
393393
{

src/goto-instrument/dump_c.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ void dump_ct::cleanup_expr(exprt &expr)
13991399
}
14001400
// add a typecast for NULL
14011401
else if(
1402-
u.op().is_constant() && is_null_pointer(to_constant_expr(u.op())) &&
1402+
u.op().is_constant() && to_constant_expr(u.op()).is_null_pointer() &&
14031403
to_pointer_type(u.op().type()).base_type().id() == ID_empty)
14041404
{
14051405
const struct_union_typet::componentt &comp=
@@ -1459,7 +1459,7 @@ void dump_ct::cleanup_expr(exprt &expr)
14591459
// add a typecast for NULL or 0
14601460
if(
14611461
argument.is_constant() &&
1462-
is_null_pointer(to_constant_expr(argument)))
1462+
to_constant_expr(argument).is_null_pointer())
14631463
{
14641464
const typet &comp_type=
14651465
to_union_type(type).components().front().type();

src/goto-instrument/goto_program2code.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ goto_programt::const_targett goto_program2codet::convert_assign_varargs(
311311
const exprt this_va_list_expr = target->assign_lhs();
312312
const exprt &r = skip_typecast(target->assign_rhs());
313313

314-
if(r.is_constant() && is_null_pointer(to_constant_expr(r)))
314+
if(r.is_constant() && to_constant_expr(r).is_null_pointer())
315315
{
316316
code_function_callt f(
317317
symbol_exprt("va_end", code_typet({}, empty_typet())),

src/goto-programs/xml_expr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Author: Daniel Kroening
1616
#include <util/arith_tools.h>
1717
#include <util/c_types.h>
1818
#include <util/config.h>
19-
#include <util/expr_util.h>
2019
#include <util/fixedbv.h>
2120
#include <util/ieee_float.h>
2221
#include <util/invariant.h>
@@ -221,7 +220,7 @@ xmlt xml(const exprt &expr, const namespacet &ns)
221220
result.name = "pointer";
222221
result.set_attribute(
223222
"binary", integer2binary(bvrep2integer(value, width, false), width));
224-
if(is_null_pointer(constant_expr))
223+
if(constant_expr.is_null_pointer())
225224
result.data = "NULL";
226225
}
227226
else if(type.id() == ID_bool)

src/goto-symex/shadow_memory_util.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,7 @@ bool contains_null_or_invalid(
319319
const std::vector<exprt> &value_set,
320320
const exprt &address)
321321
{
322-
if(
323-
address.id() == ID_constant && address.type().id() == ID_pointer &&
324-
to_constant_expr(address).is_zero())
322+
if(address.is_constant() && to_constant_expr(address).is_null_pointer())
325323
{
326324
for(const auto &e : value_set)
327325
{

0 commit comments

Comments
 (0)