@@ -113,7 +113,6 @@ class java_object_factoryt
113
113
allocation_typet alloc_type,
114
114
bool override_,
115
115
const typet &override_type,
116
- bool allow_null,
117
116
size_t depth,
118
117
update_in_placet);
119
118
@@ -124,7 +123,6 @@ class java_object_factoryt
124
123
const irep_idt &class_identifier,
125
124
allocation_typet alloc_type,
126
125
const pointer_typet &pointer_type,
127
- bool allow_null,
128
126
size_t depth,
129
127
const update_in_placet &update_in_place);
130
128
@@ -434,7 +432,6 @@ void java_object_factoryt::gen_pointer_target_init(
434
432
alloc_type,
435
433
false , // override
436
434
typet (), // override type immaterial
437
- true , // allow_null always enabled in sub-objects
438
435
depth+1 ,
439
436
update_in_place);
440
437
}
@@ -717,11 +714,6 @@ static bool add_nondet_string_pointer_initialization(
717
714
// / others.
718
715
// / \param alloc_type:
719
716
// / Allocation type (global, local or dynamic)
720
- // / \param allow_null:
721
- // / true iff the the non-det initialization code is allowed to set null as a
722
- // / value to the pointer \p expr; note that the current value of allow_null is
723
- // / _not_ inherited by subsequent recursive calls; those will always be
724
- // / authorized to assign null to a pointer
725
717
// / \param depth:
726
718
// / Number of times that a pointer has been dereferenced from the root of the
727
719
// / object tree that we are initializing.
@@ -738,7 +730,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
738
730
const irep_idt &class_identifier,
739
731
allocation_typet alloc_type,
740
732
const pointer_typet &pointer_type,
741
- bool allow_null,
742
733
size_t depth,
743
734
const update_in_placet &update_in_place)
744
735
{
@@ -843,7 +834,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
843
834
// Note string-type-specific initialization might fail, e.g. if java.lang.CharSequence does not
844
835
// have the expected fields (typically this happens if --refine-strings was not passed). In this
845
836
// case we fall back to normal pointer target init.
846
-
847
837
bool string_init_succeeded = false ;
848
838
849
839
if (java_string_library_preprocesst::implements_java_char_sequence_pointer (
@@ -873,6 +863,9 @@ void java_object_factoryt::gen_nondet_pointer_init(
873
863
874
864
auto set_null_inst=get_null_assignment (expr, pointer_type);
875
865
866
+ const bool allow_null =
867
+ depth > object_factory_parameters.max_nonnull_tree_depth ;
868
+
876
869
// Alternatively, if this is a void* we *must* initialise with null:
877
870
// (This can currently happen for some cases of #exception_value)
878
871
bool must_be_null=
@@ -977,7 +970,6 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
977
970
alloc_type,
978
971
false , // override
979
972
typet (), // override_type
980
- true , // allow_null
981
973
depth,
982
974
update_in_placet::NO_UPDATE_IN_PLACE);
983
975
@@ -1099,7 +1091,6 @@ void java_object_factoryt::gen_nondet_struct_init(
1099
1091
alloc_type,
1100
1092
false , // override
1101
1093
typet (), // override_type
1102
- true , // allow_null always true for sub-objects
1103
1094
depth,
1104
1095
substruct_in_place);
1105
1096
}
@@ -1149,9 +1140,6 @@ void java_object_factoryt::gen_nondet_struct_init(
1149
1140
// / If true, initialize with `override_type` instead of `expr.type()`. Used at
1150
1141
// / the moment for reference arrays, which are implemented as void* arrays but
1151
1142
// / should be init'd as their true type with appropriate casts.
1152
- // / \param allow_null:
1153
- // / True iff the the non-det initialization code is allowed to set null as a
1154
- // / value to a pointer.
1155
1143
// / \param depth:
1156
1144
// / Number of times that a pointer has been dereferenced from the root of the
1157
1145
// / object tree that we are initializing.
@@ -1171,7 +1159,6 @@ void java_object_factoryt::gen_nondet_init(
1171
1159
allocation_typet alloc_type,
1172
1160
bool override_,
1173
1161
const typet &override_type,
1174
- bool allow_null,
1175
1162
size_t depth,
1176
1163
update_in_placet update_in_place)
1177
1164
{
@@ -1198,7 +1185,6 @@ void java_object_factoryt::gen_nondet_init(
1198
1185
class_identifier,
1199
1186
alloc_type,
1200
1187
pointer_type,
1201
- allow_null,
1202
1188
depth,
1203
1189
update_in_place);
1204
1190
}
@@ -1278,14 +1264,13 @@ void java_object_factoryt::allocate_nondet_length_array(
1278
1264
gen_nondet_init (
1279
1265
assignments,
1280
1266
length_sym_expr,
1281
- false , // is_sub
1267
+ false , // is_sub
1282
1268
irep_idt (),
1283
- false , // skip_classid
1269
+ false , // skip_classid
1284
1270
allocation_typet::LOCAL, // immaterial, type is primitive
1285
- false , // override
1286
- typet (), // override type is immaterial
1287
- false , // allow_null
1288
- 0 , // depth is immaterial
1271
+ false , // override
1272
+ typet (), // override type is immaterial
1273
+ 0 , // depth is immaterial, always non-null
1289
1274
update_in_placet::NO_UPDATE_IN_PLACE);
1290
1275
1291
1276
// Insert assumptions to bound its length:
@@ -1436,7 +1421,6 @@ void java_object_factoryt::gen_nondet_array_init(
1436
1421
allocation_typet::DYNAMIC,
1437
1422
true , // override
1438
1423
element_type,
1439
- true , // allow_null
1440
1424
depth,
1441
1425
child_update_in_place);
1442
1426
@@ -1486,7 +1470,6 @@ exprt object_factory(
1486
1470
const typet &type,
1487
1471
const irep_idt base_name,
1488
1472
code_blockt &init_code,
1489
- bool allow_null,
1490
1473
symbol_table_baset &symbol_table,
1491
1474
const object_factory_parameterst ¶meters,
1492
1475
allocation_typet alloc_type,
@@ -1522,14 +1505,13 @@ exprt object_factory(
1522
1505
state.gen_nondet_init (
1523
1506
assignments,
1524
1507
object,
1525
- false , // is_sub
1526
- " " , // class_identifier
1527
- false , // skip_classid
1508
+ false , // is_sub
1509
+ " " , // class_identifier
1510
+ false , // skip_classid
1528
1511
alloc_type,
1529
1512
false , // override
1530
1513
typet (), // override_type is immaterial
1531
- allow_null,
1532
- 0 , // initial depth
1514
+ 1 , // initial depth
1533
1515
update_in_placet::NO_UPDATE_IN_PLACE);
1534
1516
1535
1517
declare_created_symbols (symbols_created, loc, init_code);
@@ -1560,13 +1542,6 @@ exprt object_factory(
1560
1542
// / \param alloc_type:
1561
1543
// / Allocate new objects as global objects (GLOBAL) or as local variables
1562
1544
// / (LOCAL) or using malloc (DYNAMIC).
1563
- // / \param allow_null:
1564
- // / When \p expr is a pointer, the non-det initializing code will
1565
- // / unconditionally set \p expr to a non-null object iff \p allow_null is
1566
- // / true. Note that other references down the object hierarchy *can* be null
1567
- // / when \p allow_null is false (as this parameter is not inherited by
1568
- // / subsequent recursive calls). Has no effect when \p expr is not
1569
- // / pointer-typed.
1570
1545
// / \param object_factory_parameters:
1571
1546
// / Parameters for the generation of non deterministic objects.
1572
1547
// / \param pointer_type_selector:
@@ -1587,7 +1562,6 @@ void gen_nondet_init(
1587
1562
const source_locationt &loc,
1588
1563
bool skip_classid,
1589
1564
allocation_typet alloc_type,
1590
- bool allow_null,
1591
1565
const object_factory_parameterst &object_factory_parameters,
1592
1566
const select_pointer_typet &pointer_type_selector,
1593
1567
update_in_placet update_in_place)
@@ -1604,14 +1578,13 @@ void gen_nondet_init(
1604
1578
state.gen_nondet_init (
1605
1579
assignments,
1606
1580
expr,
1607
- false , // is_sub
1608
- " " , // class_identifier
1581
+ false , // is_sub
1582
+ " " , // class_identifier
1609
1583
skip_classid,
1610
1584
alloc_type,
1611
1585
false , // override
1612
1586
typet (), // override_type is immaterial
1613
- allow_null,
1614
- 0 , // initial depth
1587
+ 1 , // initial depth
1615
1588
update_in_place);
1616
1589
1617
1590
declare_created_symbols (symbols_created, loc, init_code);
@@ -1624,7 +1597,6 @@ exprt object_factory(
1624
1597
const typet &type,
1625
1598
const irep_idt base_name,
1626
1599
code_blockt &init_code,
1627
- bool allow_null,
1628
1600
symbol_tablet &symbol_table,
1629
1601
const object_factory_parameterst &object_factory_parameters,
1630
1602
allocation_typet alloc_type,
@@ -1635,7 +1607,6 @@ exprt object_factory(
1635
1607
type,
1636
1608
base_name,
1637
1609
init_code,
1638
- allow_null,
1639
1610
symbol_table,
1640
1611
object_factory_parameters,
1641
1612
alloc_type,
@@ -1651,7 +1622,6 @@ void gen_nondet_init(
1651
1622
const source_locationt &loc,
1652
1623
bool skip_classid,
1653
1624
allocation_typet alloc_type,
1654
- bool allow_null,
1655
1625
const object_factory_parameterst &object_factory_parameters,
1656
1626
update_in_placet update_in_place)
1657
1627
{
@@ -1663,7 +1633,6 @@ void gen_nondet_init(
1663
1633
loc,
1664
1634
skip_classid,
1665
1635
alloc_type,
1666
- allow_null,
1667
1636
object_factory_parameters,
1668
1637
pointer_type_selector,
1669
1638
update_in_place);
0 commit comments