Skip to content

Commit 73635f0

Browse files
author
Daniel Kroening
authored
Merge pull request #447 from tautschnig/no-gen_zero
Remove gen_zero/gen_one
2 parents 46e0b9f + 31ce11f commit 73635f0

File tree

130 files changed

+521
-578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+521
-578
lines changed

regression/cbmc-java/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
default: tests.log
22

33
test:
4-
@../test.pl -c ../../../src/cbmc/cbmc
4+
@if ! ../test.pl -c ../../../src/cbmc/cbmc ; then \
5+
../failed-tests-printer.pl ; \
6+
exit 1 ; \
7+
fi
58

69
tests.log: ../test.pl
7-
@../test.pl -c ../../../src/cbmc/cbmc
10+
@if ! ../test.pl -c ../../../src/cbmc/cbmc ; then \
11+
../failed-tests-printer.pl ; \
12+
exit 1 ; \
13+
fi
814

915
show:
1016
@for dir in *; do \

src/aa-path-symex/path_symex.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111
#include <util/simplify_expr.h>
1212
#include <util/byte_operators.h>
1313
#include <util/pointer_offset_size.h>
14-
#include <util/expr_util.h>
1514
#include <util/base_type.h>
1615

1716
#include <ansi-c/c_types.h>
@@ -353,7 +352,7 @@ void path_symext::symex_malloc(
353352
rhs.type()=pointer_typet(value_symbol.type.subtype());
354353
index_exprt index_expr(value_symbol.type.subtype());
355354
index_expr.array()=value_symbol.symbol_expr();
356-
index_expr.index()=gen_zero(index_type());
355+
index_expr.index()=from_integer(0, index_type());
357356
rhs.op0()=index_expr;
358357
}
359358
else
@@ -486,7 +485,7 @@ void path_symext::assign_rec(
486485
else if(compound_type.id()==ID_union)
487486
{
488487
// rewrite into byte_extract, and do again
489-
exprt offset=gen_zero(index_type());
488+
exprt offset=from_integer(0, index_type());
490489

491490
byte_extract_exprt
492491
new_lhs(byte_update_id(), struct_op, offset, ssa_rhs.type());

src/aa-path-symex/path_symex_state.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Author: Daniel Kroening, [email protected]
99

1010
#include <util/simplify_expr.h>
1111
#include <util/arith_tools.h>
12-
#include <util/expr_util.h>
1312
#include <util/decision_procedure.h>
1413

1514
#include <ansi-c/c_types.h>

src/analyses/ai.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include <util/std_expr.h>
1313
#include <util/std_code.h>
14-
#include <util/expr_util.h>
1514

1615
#include "is_threaded.h"
1716

src/analyses/flow_insensitive_analysis.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include <util/std_expr.h>
1313
#include <util/std_code.h>
14-
#include <util/expr_util.h>
1514

1615
#include "flow_insensitive_analysis.h"
1716

src/analyses/goto_check.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void goto_checkt::div_by_zero_check(
188188

189189
// add divison by zero subgoal
190190

191-
exprt zero=gen_zero(expr.op1().type());
191+
exprt zero=from_integer(0, expr.op1().type());
192192

193193
if(zero.is_nil())
194194
throw "no zero of argument type of operator "+expr.id_string();
@@ -233,7 +233,7 @@ void goto_checkt::undefined_shift_check(
233233
if(distance_type.id()==ID_signedbv)
234234
{
235235
binary_relation_exprt inequality(
236-
expr.distance(), ID_ge, gen_zero(distance_type));
236+
expr.distance(), ID_ge, from_integer(0, distance_type));
237237

238238
add_guarded_claim(
239239
inequality,
@@ -289,7 +289,7 @@ void goto_checkt::mod_by_zero_check(
289289

290290
// add divison by zero subgoal
291291

292-
exprt zero=gen_zero(expr.op1().type());
292+
exprt zero=from_integer(0, expr.op1().type());
293293

294294
if(zero.is_nil())
295295
throw "no zero of argument type of operator "+expr.id_string();
@@ -802,8 +802,8 @@ void goto_checkt::nan_check(
802802
// 0/0 = NaN and x/inf = NaN
803803
// (note that x/0 = +-inf for x!=0 and x!=inf)
804804
exprt zero_div_zero=and_exprt(
805-
ieee_float_equal_exprt(expr.op0(), gen_zero(expr.op0().type())),
806-
ieee_float_equal_exprt(expr.op1(), gen_zero(expr.op1().type())));
805+
ieee_float_equal_exprt(expr.op0(), from_integer(0, expr.op0().type())),
806+
ieee_float_equal_exprt(expr.op1(), from_integer(0, expr.op1().type())));
807807

808808
exprt div_inf=unary_exprt(ID_isinf, expr.op1(), bool_typet());
809809

@@ -819,10 +819,10 @@ void goto_checkt::nan_check(
819819
// Inf * 0 is NaN
820820
exprt inf_times_zero=and_exprt(
821821
unary_exprt(ID_isinf, expr.op0(), bool_typet()),
822-
ieee_float_equal_exprt(expr.op1(), gen_zero(expr.op1().type())));
822+
ieee_float_equal_exprt(expr.op1(), from_integer(0, expr.op1().type())));
823823

824824
exprt zero_times_inf=and_exprt(
825-
ieee_float_equal_exprt(expr.op1(), gen_zero(expr.op1().type())),
825+
ieee_float_equal_exprt(expr.op1(), from_integer(0, expr.op1().type())),
826826
unary_exprt(ID_isinf, expr.op0(), bool_typet()));
827827

828828
isnan=or_exprt(inf_times_zero, zero_times_inf);
@@ -972,7 +972,8 @@ void goto_checkt::pointer_validity_check(
972972
return;
973973

974974
const exprt &pointer=expr.op0();
975-
const typet &pointer_type=to_pointer_type(ns.follow(pointer.type()));
975+
const pointer_typet &pointer_type=
976+
to_pointer_type(ns.follow(pointer.type()));
976977

977978
assert(base_type_eq(pointer_type.subtype(), expr.type(), ns));
978979

@@ -986,7 +987,7 @@ void goto_checkt::pointer_validity_check(
986987
{
987988
if(flags.is_unknown() || flags.is_null())
988989
{
989-
notequal_exprt not_eq_null(pointer, gen_zero(pointer.type()));
990+
notequal_exprt not_eq_null(pointer, null_pointer_exprt(pointer_type));
990991

991992
add_guarded_claim(
992993
not_eq_null,
@@ -1175,7 +1176,7 @@ void goto_checkt::bounds_check(
11751176
effective_offset=plus_exprt(p_offset, effective_offset);
11761177
}
11771178

1178-
exprt zero=gen_zero(ode.offset().type());
1179+
exprt zero=from_integer(0, ode.offset().type());
11791180
assert(zero.is_not_nil());
11801181

11811182
// the final offset must not be negative
@@ -1612,7 +1613,9 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
16121613

16131614
if(flags.is_unknown() || flags.is_null())
16141615
{
1615-
notequal_exprt not_eq_null(pointer, gen_zero(pointer.type()));
1616+
notequal_exprt not_eq_null(
1617+
pointer,
1618+
null_pointer_exprt(to_pointer_type(pointer.type())));
16161619

16171620
add_guarded_claim(
16181621
not_eq_null,
@@ -1651,7 +1654,9 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
16511654

16521655
if(pointer.type().subtype().get(ID_identifier)!="java::java.lang.AssertionError")
16531656
{
1654-
notequal_exprt not_eq_null(pointer, gen_zero(pointer.type()));
1657+
notequal_exprt not_eq_null(
1658+
pointer,
1659+
null_pointer_exprt(to_pointer_type(pointer.type())));
16551660

16561661
add_guarded_claim(
16571662
not_eq_null,
@@ -1718,7 +1723,9 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
17181723
source_locationt source_location;
17191724
source_location.set_function(i.function);
17201725

1721-
equal_exprt eq(leak_expr, gen_zero(ns.follow(leak.type)));
1726+
equal_exprt eq(
1727+
leak_expr,
1728+
null_pointer_exprt(to_pointer_type(leak.type)));
17221729
add_guarded_claim(
17231730
eq,
17241731
"dynamically allocated memory never freed",

src/analyses/invariant_propagation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9-
#include <util/expr_util.h>
109
#include <util/simplify_expr.h>
1110
#include <util/base_type.h>
1211
#include <util/symbol_table.h>

src/analyses/invariant_set.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Author: Daniel Kroening, [email protected]
1010

1111
#include <util/symbol_table.h>
1212
#include <util/namespace.h>
13-
#include <util/expr_util.h>
1413
#include <util/arith_tools.h>
1514
#include <util/std_expr.h>
1615
#include <util/simplify_expr.h>
@@ -992,7 +991,7 @@ void invariant_sett::nnf(exprt &expr, bool negate)
992991
{
993992
equal_exprt tmp;
994993
tmp.lhs()=expr.op0();
995-
tmp.rhs()=gen_zero(expr.op0().type());
994+
tmp.rhs()=from_integer(0, expr.op0().type());
996995
nnf(tmp, !negate);
997996
expr.swap(tmp);
998997
}

src/analyses/local_may_alias.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, [email protected]
99
#include <iterator>
1010
#include <algorithm>
1111

12+
#include <util/arith_tools.h>
1213
#include <util/std_expr.h>
1314
#include <util/std_code.h>
1415
#include <util/expr_util.h>
@@ -272,7 +273,7 @@ void local_may_aliast::get_rec(
272273
if(index_expr.array().id()==ID_symbol)
273274
{
274275
index_exprt tmp1=index_expr;
275-
tmp1.index()=gen_zero(index_type());
276+
tmp1.index()=from_integer(0, index_type());
276277
address_of_exprt tmp2(tmp1);
277278
unsigned object_nr=objects.number(tmp2);
278279
dest.insert(object_nr);
@@ -284,7 +285,7 @@ void local_may_aliast::get_rec(
284285
else if(index_expr.array().id()==ID_string_constant)
285286
{
286287
index_exprt tmp1=index_expr;
287-
tmp1.index()=gen_zero(index_type());
288+
tmp1.index()=from_integer(0, index_type());
288289
address_of_exprt tmp2(tmp1);
289290
unsigned object_nr=objects.number(tmp2);
290291
dest.insert(object_nr);

src/analyses/static_analysis.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include <util/std_expr.h>
1313
#include <util/std_code.h>
14-
#include <util/expr_util.h>
1514

1615
#include "is_threaded.h"
1716

0 commit comments

Comments
 (0)