@@ -133,7 +133,6 @@ class java_object_factoryt
133
133
allocation_typet alloc_type,
134
134
bool override_,
135
135
const typet &override_type,
136
- bool allow_null,
137
136
size_t depth,
138
137
update_in_placet);
139
138
@@ -144,7 +143,6 @@ class java_object_factoryt
144
143
const irep_idt &class_identifier,
145
144
allocation_typet alloc_type,
146
145
const pointer_typet &pointer_type,
147
- bool allow_null,
148
146
size_t depth,
149
147
const update_in_placet &update_in_place);
150
148
@@ -441,7 +439,6 @@ void java_object_factoryt::gen_pointer_target_init(
441
439
alloc_type,
442
440
false , // override
443
441
typet (), // override type immaterial
444
- true , // allow_null always enabled in sub-objects
445
442
depth+1 ,
446
443
update_in_place);
447
444
}
@@ -716,11 +713,6 @@ static bool add_nondet_string_pointer_initialization(
716
713
// / others.
717
714
// / \param alloc_type:
718
715
// / Allocation type (global, local or dynamic)
719
- // / \param allow_null:
720
- // / true iff the the non-det initialization code is allowed to set null as a
721
- // / value to the pointer \p expr; note that the current value of allow_null is
722
- // / _not_ inherited by subsequent recursive calls; those will always be
723
- // / authorized to assign null to a pointer
724
716
// / \param depth:
725
717
// / Number of times that a pointer has been dereferenced from the root of the
726
718
// / object tree that we are initializing.
@@ -737,7 +729,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
737
729
const irep_idt &class_identifier,
738
730
allocation_typet alloc_type,
739
731
const pointer_typet &pointer_type,
740
- bool allow_null,
741
732
size_t depth,
742
733
const update_in_placet &update_in_place)
743
734
{
@@ -858,7 +849,9 @@ void java_object_factoryt::gen_nondet_pointer_init(
858
849
859
850
// Determine whether the pointer can be null. In particular the pointers
860
851
// inside the java.lang.Class class shall not be null
861
- const bool not_null = !allow_null || class_identifier == " java.lang.Class" ;
852
+ const bool not_null =
853
+ depth <= object_factory_parameters.max_nonnull_tree_depth ||
854
+ class_identifier == " java.lang.Class" ;
862
855
863
856
// Alternatively, if this is a void* we *must* initialise with null:
864
857
// (This can currently happen for some cases of #exception_value)
@@ -958,7 +951,6 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
958
951
alloc_type,
959
952
false , // override
960
953
typet (), // override_type
961
- true , // allow_null
962
954
depth,
963
955
update_in_placet::NO_UPDATE_IN_PLACE);
964
956
@@ -1067,7 +1059,6 @@ void java_object_factoryt::gen_nondet_struct_init(
1067
1059
alloc_type,
1068
1060
false , // override
1069
1061
typet (), // override_type
1070
- true , // allow_null always true for sub-objects
1071
1062
depth,
1072
1063
substruct_in_place);
1073
1064
}
@@ -1117,9 +1108,6 @@ void java_object_factoryt::gen_nondet_struct_init(
1117
1108
// / If true, initialize with `override_type` instead of `expr.type()`. Used at
1118
1109
// / the moment for reference arrays, which are implemented as void* arrays but
1119
1110
// / should be init'd as their true type with appropriate casts.
1120
- // / \param allow_null:
1121
- // / True iff the the non-det initialization code is allowed to set null as a
1122
- // / value to a pointer.
1123
1111
// / \param depth:
1124
1112
// / Number of times that a pointer has been dereferenced from the root of the
1125
1113
// / object tree that we are initializing.
@@ -1139,7 +1127,6 @@ void java_object_factoryt::gen_nondet_init(
1139
1127
allocation_typet alloc_type,
1140
1128
bool override_,
1141
1129
const typet &override_type,
1142
- bool allow_null,
1143
1130
size_t depth,
1144
1131
update_in_placet update_in_place)
1145
1132
{
@@ -1157,7 +1144,6 @@ void java_object_factoryt::gen_nondet_init(
1157
1144
class_identifier,
1158
1145
alloc_type,
1159
1146
pointer_type,
1160
- allow_null,
1161
1147
depth,
1162
1148
update_in_place);
1163
1149
}
@@ -1220,14 +1206,13 @@ void java_object_factoryt::allocate_nondet_length_array(
1220
1206
gen_nondet_init (
1221
1207
assignments,
1222
1208
length_sym_expr,
1223
- false , // is_sub
1209
+ false , // is_sub
1224
1210
irep_idt (),
1225
- false , // skip_classid
1211
+ false , // skip_classid
1226
1212
allocation_typet::LOCAL, // immaterial, type is primitive
1227
- false , // override
1228
- typet (), // override type is immaterial
1229
- false , // allow_null
1230
- 0 , // depth is immaterial
1213
+ false , // override
1214
+ typet (), // override type is immaterial
1215
+ 0 , // depth is immaterial, always non-null
1231
1216
update_in_placet::NO_UPDATE_IN_PLACE);
1232
1217
1233
1218
// Insert assumptions to bound its length:
@@ -1374,7 +1359,6 @@ void java_object_factoryt::gen_nondet_array_init(
1374
1359
allocation_typet::DYNAMIC,
1375
1360
true , // override
1376
1361
element_type,
1377
- true , // allow_null
1378
1362
depth,
1379
1363
child_update_in_place);
1380
1364
@@ -1424,7 +1408,6 @@ exprt object_factory(
1424
1408
const typet &type,
1425
1409
const irep_idt base_name,
1426
1410
code_blockt &init_code,
1427
- bool allow_null,
1428
1411
symbol_table_baset &symbol_table,
1429
1412
const object_factory_parameterst ¶meters,
1430
1413
allocation_typet alloc_type,
@@ -1460,14 +1443,13 @@ exprt object_factory(
1460
1443
state.gen_nondet_init (
1461
1444
assignments,
1462
1445
object,
1463
- false , // is_sub
1464
- " " , // class_identifier
1465
- false , // skip_classid
1446
+ false , // is_sub
1447
+ " " , // class_identifier
1448
+ false , // skip_classid
1466
1449
alloc_type,
1467
1450
false , // override
1468
1451
typet (), // override_type is immaterial
1469
- allow_null,
1470
- 0 , // initial depth
1452
+ 1 , // initial depth
1471
1453
update_in_placet::NO_UPDATE_IN_PLACE);
1472
1454
1473
1455
declare_created_symbols (symbols_created, loc, init_code);
@@ -1498,13 +1480,6 @@ exprt object_factory(
1498
1480
// / \param alloc_type:
1499
1481
// / Allocate new objects as global objects (GLOBAL) or as local variables
1500
1482
// / (LOCAL) or using malloc (DYNAMIC).
1501
- // / \param allow_null:
1502
- // / When \p expr is a pointer, the non-det initializing code will
1503
- // / unconditionally set \p expr to a non-null object iff \p allow_null is
1504
- // / true. Note that other references down the object hierarchy *can* be null
1505
- // / when \p allow_null is false (as this parameter is not inherited by
1506
- // / subsequent recursive calls). Has no effect when \p expr is not
1507
- // / pointer-typed.
1508
1483
// / \param object_factory_parameters:
1509
1484
// / Parameters for the generation of non deterministic objects.
1510
1485
// / \param pointer_type_selector:
@@ -1525,7 +1500,6 @@ void gen_nondet_init(
1525
1500
const source_locationt &loc,
1526
1501
bool skip_classid,
1527
1502
allocation_typet alloc_type,
1528
- bool allow_null,
1529
1503
const object_factory_parameterst &object_factory_parameters,
1530
1504
const select_pointer_typet &pointer_type_selector,
1531
1505
update_in_placet update_in_place)
@@ -1542,14 +1516,13 @@ void gen_nondet_init(
1542
1516
state.gen_nondet_init (
1543
1517
assignments,
1544
1518
expr,
1545
- false , // is_sub
1546
- " " , // class_identifier
1519
+ false , // is_sub
1520
+ " " , // class_identifier
1547
1521
skip_classid,
1548
1522
alloc_type,
1549
1523
false , // override
1550
1524
typet (), // override_type is immaterial
1551
- allow_null,
1552
- 0 , // initial depth
1525
+ 1 , // initial depth
1553
1526
update_in_place);
1554
1527
1555
1528
declare_created_symbols (symbols_created, loc, init_code);
@@ -1562,7 +1535,6 @@ exprt object_factory(
1562
1535
const typet &type,
1563
1536
const irep_idt base_name,
1564
1537
code_blockt &init_code,
1565
- bool allow_null,
1566
1538
symbol_tablet &symbol_table,
1567
1539
const object_factory_parameterst &object_factory_parameters,
1568
1540
allocation_typet alloc_type,
@@ -1573,7 +1545,6 @@ exprt object_factory(
1573
1545
type,
1574
1546
base_name,
1575
1547
init_code,
1576
- allow_null,
1577
1548
symbol_table,
1578
1549
object_factory_parameters,
1579
1550
alloc_type,
@@ -1589,7 +1560,6 @@ void gen_nondet_init(
1589
1560
const source_locationt &loc,
1590
1561
bool skip_classid,
1591
1562
allocation_typet alloc_type,
1592
- bool allow_null,
1593
1563
const object_factory_parameterst &object_factory_parameters,
1594
1564
update_in_placet update_in_place)
1595
1565
{
@@ -1601,7 +1571,6 @@ void gen_nondet_init(
1601
1571
loc,
1602
1572
skip_classid,
1603
1573
alloc_type,
1604
- allow_null,
1605
1574
object_factory_parameters,
1606
1575
pointer_type_selector,
1607
1576
update_in_place);
0 commit comments