@@ -113,7 +113,6 @@ class java_object_factoryt
113113 allocation_typet alloc_type,
114114 bool override_,
115115 const typet &override_type,
116- bool allow_null,
117116 size_t depth,
118117 update_in_placet);
119118
@@ -124,7 +123,6 @@ class java_object_factoryt
124123 const irep_idt &class_identifier,
125124 allocation_typet alloc_type,
126125 const pointer_typet &pointer_type,
127- bool allow_null,
128126 size_t depth,
129127 const update_in_placet &update_in_place);
130128
@@ -434,7 +432,6 @@ void java_object_factoryt::gen_pointer_target_init(
434432 alloc_type,
435433 false , // override
436434 typet (), // override type immaterial
437- true , // allow_null always enabled in sub-objects
438435 depth+1 ,
439436 update_in_place);
440437 }
@@ -717,11 +714,6 @@ static bool add_nondet_string_pointer_initialization(
717714// / others.
718715// / \param alloc_type:
719716// / 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
725717// / \param depth:
726718// / Number of times that a pointer has been dereferenced from the root of the
727719// / object tree that we are initializing.
@@ -738,7 +730,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
738730 const irep_idt &class_identifier,
739731 allocation_typet alloc_type,
740732 const pointer_typet &pointer_type,
741- bool allow_null,
742733 size_t depth,
743734 const update_in_placet &update_in_place)
744735{
@@ -843,7 +834,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
843834 // Note string-type-specific initialization might fail, e.g. if java.lang.CharSequence does not
844835 // have the expected fields (typically this happens if --refine-strings was not passed). In this
845836 // case we fall back to normal pointer target init.
846-
847837 bool string_init_succeeded = false ;
848838
849839 if (java_string_library_preprocesst::implements_java_char_sequence_pointer (
@@ -873,6 +863,9 @@ void java_object_factoryt::gen_nondet_pointer_init(
873863
874864 auto set_null_inst=get_null_assignment (expr, pointer_type);
875865
866+ const bool allow_null =
867+ depth > object_factory_parameters.max_nonnull_tree_depth ;
868+
876869 // Alternatively, if this is a void* we *must* initialise with null:
877870 // (This can currently happen for some cases of #exception_value)
878871 bool must_be_null=
@@ -977,7 +970,6 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
977970 alloc_type,
978971 false , // override
979972 typet (), // override_type
980- true , // allow_null
981973 depth,
982974 update_in_placet::NO_UPDATE_IN_PLACE);
983975
@@ -1099,7 +1091,6 @@ void java_object_factoryt::gen_nondet_struct_init(
10991091 alloc_type,
11001092 false , // override
11011093 typet (), // override_type
1102- true , // allow_null always true for sub-objects
11031094 depth,
11041095 substruct_in_place);
11051096 }
@@ -1149,9 +1140,6 @@ void java_object_factoryt::gen_nondet_struct_init(
11491140// / If true, initialize with `override_type` instead of `expr.type()`. Used at
11501141// / the moment for reference arrays, which are implemented as void* arrays but
11511142// / 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.
11551143// / \param depth:
11561144// / Number of times that a pointer has been dereferenced from the root of the
11571145// / object tree that we are initializing.
@@ -1171,7 +1159,6 @@ void java_object_factoryt::gen_nondet_init(
11711159 allocation_typet alloc_type,
11721160 bool override_,
11731161 const typet &override_type,
1174- bool allow_null,
11751162 size_t depth,
11761163 update_in_placet update_in_place)
11771164{
@@ -1198,7 +1185,6 @@ void java_object_factoryt::gen_nondet_init(
11981185 class_identifier,
11991186 alloc_type,
12001187 pointer_type,
1201- allow_null,
12021188 depth,
12031189 update_in_place);
12041190 }
@@ -1278,14 +1264,13 @@ void java_object_factoryt::allocate_nondet_length_array(
12781264 gen_nondet_init (
12791265 assignments,
12801266 length_sym_expr,
1281- false , // is_sub
1267+ false , // is_sub
12821268 irep_idt (),
1283- false , // skip_classid
1269+ false , // skip_classid
12841270 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
12891274 update_in_placet::NO_UPDATE_IN_PLACE);
12901275
12911276 // Insert assumptions to bound its length:
@@ -1436,7 +1421,6 @@ void java_object_factoryt::gen_nondet_array_init(
14361421 allocation_typet::DYNAMIC,
14371422 true , // override
14381423 element_type,
1439- true , // allow_null
14401424 depth,
14411425 child_update_in_place);
14421426
@@ -1486,7 +1470,6 @@ exprt object_factory(
14861470 const typet &type,
14871471 const irep_idt base_name,
14881472 code_blockt &init_code,
1489- bool allow_null,
14901473 symbol_table_baset &symbol_table,
14911474 const object_factory_parameterst ¶meters,
14921475 allocation_typet alloc_type,
@@ -1522,14 +1505,13 @@ exprt object_factory(
15221505 state.gen_nondet_init (
15231506 assignments,
15241507 object,
1525- false , // is_sub
1526- " " , // class_identifier
1527- false , // skip_classid
1508+ false , // is_sub
1509+ " " , // class_identifier
1510+ false , // skip_classid
15281511 alloc_type,
15291512 false , // override
15301513 typet (), // override_type is immaterial
1531- allow_null,
1532- 0 , // initial depth
1514+ 1 , // initial depth
15331515 update_in_placet::NO_UPDATE_IN_PLACE);
15341516
15351517 declare_created_symbols (symbols_created, loc, init_code);
@@ -1560,13 +1542,6 @@ exprt object_factory(
15601542// / \param alloc_type:
15611543// / Allocate new objects as global objects (GLOBAL) or as local variables
15621544// / (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.
15701545// / \param object_factory_parameters:
15711546// / Parameters for the generation of non deterministic objects.
15721547// / \param pointer_type_selector:
@@ -1587,7 +1562,6 @@ void gen_nondet_init(
15871562 const source_locationt &loc,
15881563 bool skip_classid,
15891564 allocation_typet alloc_type,
1590- bool allow_null,
15911565 const object_factory_parameterst &object_factory_parameters,
15921566 const select_pointer_typet &pointer_type_selector,
15931567 update_in_placet update_in_place)
@@ -1604,14 +1578,13 @@ void gen_nondet_init(
16041578 state.gen_nondet_init (
16051579 assignments,
16061580 expr,
1607- false , // is_sub
1608- " " , // class_identifier
1581+ false , // is_sub
1582+ " " , // class_identifier
16091583 skip_classid,
16101584 alloc_type,
16111585 false , // override
16121586 typet (), // override_type is immaterial
1613- allow_null,
1614- 0 , // initial depth
1587+ 1 , // initial depth
16151588 update_in_place);
16161589
16171590 declare_created_symbols (symbols_created, loc, init_code);
@@ -1624,7 +1597,6 @@ exprt object_factory(
16241597 const typet &type,
16251598 const irep_idt base_name,
16261599 code_blockt &init_code,
1627- bool allow_null,
16281600 symbol_tablet &symbol_table,
16291601 const object_factory_parameterst &object_factory_parameters,
16301602 allocation_typet alloc_type,
@@ -1635,7 +1607,6 @@ exprt object_factory(
16351607 type,
16361608 base_name,
16371609 init_code,
1638- allow_null,
16391610 symbol_table,
16401611 object_factory_parameters,
16411612 alloc_type,
@@ -1651,7 +1622,6 @@ void gen_nondet_init(
16511622 const source_locationt &loc,
16521623 bool skip_classid,
16531624 allocation_typet alloc_type,
1654- bool allow_null,
16551625 const object_factory_parameterst &object_factory_parameters,
16561626 update_in_placet update_in_place)
16571627{
@@ -1663,7 +1633,6 @@ void gen_nondet_init(
16631633 loc,
16641634 skip_classid,
16651635 alloc_type,
1666- allow_null,
16671636 object_factory_parameters,
16681637 pointer_type_selector,
16691638 update_in_place);
0 commit comments