@@ -144,7 +144,6 @@ class java_object_factoryt
144
144
allocation_typet alloc_type,
145
145
bool override_,
146
146
const typet &override_type,
147
- bool allow_null,
148
147
size_t depth,
149
148
update_in_placet);
150
149
@@ -155,7 +154,6 @@ class java_object_factoryt
155
154
const irep_idt &class_identifier,
156
155
allocation_typet alloc_type,
157
156
const pointer_typet &pointer_type,
158
- bool allow_null,
159
157
size_t depth,
160
158
const update_in_placet &update_in_place);
161
159
@@ -452,7 +450,6 @@ void java_object_factoryt::gen_pointer_target_init(
452
450
alloc_type,
453
451
false , // override
454
452
typet (), // override type immaterial
455
- true , // allow_null always enabled in sub-objects
456
453
depth+1 ,
457
454
update_in_place);
458
455
}
@@ -727,11 +724,6 @@ static bool add_nondet_string_pointer_initialization(
727
724
// / others.
728
725
// / \param alloc_type:
729
726
// / Allocation type (global, local or dynamic)
730
- // / \param allow_null:
731
- // / true iff the the non-det initialization code is allowed to set null as a
732
- // / value to the pointer \p expr; note that the current value of allow_null is
733
- // / _not_ inherited by subsequent recursive calls; those will always be
734
- // / authorized to assign null to a pointer
735
727
// / \param depth:
736
728
// / Number of times that a pointer has been dereferenced from the root of the
737
729
// / object tree that we are initializing.
@@ -748,7 +740,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
748
740
const irep_idt &class_identifier,
749
741
allocation_typet alloc_type,
750
742
const pointer_typet &pointer_type,
751
- bool allow_null,
752
743
size_t depth,
753
744
const update_in_placet &update_in_place)
754
745
{
@@ -870,7 +861,9 @@ void java_object_factoryt::gen_nondet_pointer_init(
870
861
871
862
// Determine whether the pointer can be null. In particular the pointers
872
863
// inside the java.lang.Class class shall not be null
873
- const bool not_null = !allow_null || class_identifier == " java.lang.Class" ;
864
+ const bool not_null =
865
+ depth <= object_factory_parameters.max_nonnull_tree_depth ||
866
+ class_identifier == " java.lang.Class" ;
874
867
875
868
// Alternatively, if this is a void* we *must* initialise with null:
876
869
// (This can currently happen for some cases of #exception_value)
@@ -970,7 +963,6 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
970
963
alloc_type,
971
964
false , // override
972
965
typet (), // override_type
973
- true , // allow_null
974
966
depth,
975
967
update_in_placet::NO_UPDATE_IN_PLACE);
976
968
@@ -1079,7 +1071,6 @@ void java_object_factoryt::gen_nondet_struct_init(
1079
1071
alloc_type,
1080
1072
false , // override
1081
1073
typet (), // override_type
1082
- true , // allow_null always true for sub-objects
1083
1074
depth,
1084
1075
substruct_in_place);
1085
1076
}
@@ -1129,9 +1120,6 @@ void java_object_factoryt::gen_nondet_struct_init(
1129
1120
// / If true, initialize with `override_type` instead of `expr.type()`. Used at
1130
1121
// / the moment for reference arrays, which are implemented as void* arrays but
1131
1122
// / should be init'd as their true type with appropriate casts.
1132
- // / \param allow_null:
1133
- // / True iff the the non-det initialization code is allowed to set null as a
1134
- // / value to a pointer.
1135
1123
// / \param depth:
1136
1124
// / Number of times that a pointer has been dereferenced from the root of the
1137
1125
// / object tree that we are initializing.
@@ -1151,7 +1139,6 @@ void java_object_factoryt::gen_nondet_init(
1151
1139
allocation_typet alloc_type,
1152
1140
bool override_,
1153
1141
const typet &override_type,
1154
- bool allow_null,
1155
1142
size_t depth,
1156
1143
update_in_placet update_in_place)
1157
1144
{
@@ -1178,7 +1165,6 @@ void java_object_factoryt::gen_nondet_init(
1178
1165
class_identifier,
1179
1166
alloc_type,
1180
1167
pointer_type,
1181
- allow_null,
1182
1168
depth,
1183
1169
update_in_place);
1184
1170
}
@@ -1262,8 +1248,7 @@ void java_object_factoryt::allocate_nondet_length_array(
1262
1248
allocation_typet::LOCAL, // immaterial, type is primitive
1263
1249
false , // override
1264
1250
typet (), // override type is immaterial
1265
- false , // allow_null
1266
- 0 , // depth is immaterial
1251
+ 0 , // depth is immaterial, always non-null
1267
1252
update_in_placet::NO_UPDATE_IN_PLACE);
1268
1253
1269
1254
// Insert assumptions to bound its length:
@@ -1410,7 +1395,6 @@ void java_object_factoryt::gen_nondet_array_init(
1410
1395
allocation_typet::DYNAMIC,
1411
1396
true , // override
1412
1397
element_type,
1413
- true , // allow_null
1414
1398
depth,
1415
1399
child_update_in_place);
1416
1400
@@ -1460,7 +1444,6 @@ exprt object_factory(
1460
1444
const typet &type,
1461
1445
const irep_idt base_name,
1462
1446
code_blockt &init_code,
1463
- bool allow_null,
1464
1447
symbol_table_baset &symbol_table,
1465
1448
const object_factory_parameterst ¶meters,
1466
1449
allocation_typet alloc_type,
@@ -1502,8 +1485,7 @@ exprt object_factory(
1502
1485
alloc_type,
1503
1486
false , // override
1504
1487
typet (), // override_type is immaterial
1505
- allow_null,
1506
- 0 , // initial depth
1488
+ 1 , // initial depth
1507
1489
update_in_placet::NO_UPDATE_IN_PLACE);
1508
1490
1509
1491
declare_created_symbols (symbols_created, loc, init_code);
@@ -1534,13 +1516,6 @@ exprt object_factory(
1534
1516
// / \param alloc_type:
1535
1517
// / Allocate new objects as global objects (GLOBAL) or as local variables
1536
1518
// / (LOCAL) or using malloc (DYNAMIC).
1537
- // / \param allow_null:
1538
- // / When \p expr is a pointer, the non-det initializing code will
1539
- // / unconditionally set \p expr to a non-null object iff \p allow_null is
1540
- // / true. Note that other references down the object hierarchy *can* be null
1541
- // / when \p allow_null is false (as this parameter is not inherited by
1542
- // / subsequent recursive calls). Has no effect when \p expr is not
1543
- // / pointer-typed.
1544
1519
// / \param object_factory_parameters:
1545
1520
// / Parameters for the generation of non deterministic objects.
1546
1521
// / \param pointer_type_selector:
@@ -1561,7 +1536,6 @@ void gen_nondet_init(
1561
1536
const source_locationt &loc,
1562
1537
bool skip_classid,
1563
1538
allocation_typet alloc_type,
1564
- bool allow_null,
1565
1539
const object_factory_parameterst &object_factory_parameters,
1566
1540
const select_pointer_typet &pointer_type_selector,
1567
1541
update_in_placet update_in_place)
@@ -1584,8 +1558,7 @@ void gen_nondet_init(
1584
1558
alloc_type,
1585
1559
false , // override
1586
1560
typet (), // override_type is immaterial
1587
- allow_null,
1588
- 0 , // initial depth
1561
+ 1 , // initial depth
1589
1562
update_in_place);
1590
1563
1591
1564
declare_created_symbols (symbols_created, loc, init_code);
@@ -1598,7 +1571,6 @@ exprt object_factory(
1598
1571
const typet &type,
1599
1572
const irep_idt base_name,
1600
1573
code_blockt &init_code,
1601
- bool allow_null,
1602
1574
symbol_tablet &symbol_table,
1603
1575
const object_factory_parameterst &object_factory_parameters,
1604
1576
allocation_typet alloc_type,
@@ -1609,7 +1581,6 @@ exprt object_factory(
1609
1581
type,
1610
1582
base_name,
1611
1583
init_code,
1612
- allow_null,
1613
1584
symbol_table,
1614
1585
object_factory_parameters,
1615
1586
alloc_type,
@@ -1625,7 +1596,6 @@ void gen_nondet_init(
1625
1596
const source_locationt &loc,
1626
1597
bool skip_classid,
1627
1598
allocation_typet alloc_type,
1628
- bool allow_null,
1629
1599
const object_factory_parameterst &object_factory_parameters,
1630
1600
update_in_placet update_in_place)
1631
1601
{
@@ -1637,7 +1607,6 @@ void gen_nondet_init(
1637
1607
loc,
1638
1608
skip_classid,
1639
1609
alloc_type,
1640
- allow_null,
1641
1610
object_factory_parameters,
1642
1611
pointer_type_selector,
1643
1612
update_in_place);
0 commit comments