@@ -116,8 +116,7 @@ class java_object_factoryt
116
116
irep_idt class_identifier,
117
117
bool skip_classid,
118
118
lifetimet lifetime,
119
- bool override_,
120
- const typet &override_type,
119
+ const optionalt<typet> &override_type,
121
120
size_t depth,
122
121
update_in_placet,
123
122
const source_locationt &location);
@@ -295,8 +294,7 @@ void java_object_factoryt::gen_pointer_target_init(
295
294
" " , // class_identifier
296
295
false , // skip_classid
297
296
lifetime,
298
- false , // override
299
- typet (), // override type immaterial
297
+ {}, // no override type
300
298
depth + 1 ,
301
299
update_in_place,
302
300
location);
@@ -763,8 +761,7 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
763
761
" " , // class_identifier
764
762
false , // skip_classid
765
763
lifetime,
766
- false , // override
767
- typet (), // override_type
764
+ {}, // no override_type
768
765
depth,
769
766
update_in_placet::NO_UPDATE_IN_PLACE,
770
767
location);
@@ -968,8 +965,7 @@ void java_object_factoryt::gen_nondet_struct_init(
968
965
class_identifier,
969
966
false , // skip_classid
970
967
lifetime,
971
- false , // override
972
- typet (), // override_type
968
+ {}, // no override_type
973
969
depth,
974
970
substruct_in_place,
975
971
location);
@@ -1007,15 +1003,14 @@ void java_object_factoryt::gen_nondet_struct_init(
1007
1003
// / \param lifetime:
1008
1004
// / Lifetime of the allocated objects (AUTOMATIC_LOCAL, STATIC_GLOBAL, or
1009
1005
// / DYNAMIC)
1010
- // / \param override_:
1011
- // / If true, initialize with `override_type` instead of `expr.type()`. Used at
1012
- // / the moment for reference arrays, which are implemented as void* arrays but
1013
- // / should be init'd as their true type with appropriate casts.
1014
1006
// / \param depth:
1015
1007
// / Number of times that a pointer has been dereferenced from the root of the
1016
1008
// / object tree that we are initializing.
1017
1009
// / \param override_type:
1018
- // / Override type per above.
1010
+ // / If not empty, initialize with `override_type` instead of `expr.type()`.
1011
+ // / Used at the moment for reference arrays, which are implemented as
1012
+ // / void* arrays but should be init'd as their true type with appropriate
1013
+ // / casts.
1019
1014
// / \param update_in_place:
1020
1015
// / NO_UPDATE_IN_PLACE: initialize `expr` from scratch
1021
1016
// / MAY_UPDATE_IN_PLACE: generate a runtime nondet branch between the NO_
@@ -1030,15 +1025,13 @@ void java_object_factoryt::gen_nondet_init(
1030
1025
irep_idt class_identifier,
1031
1026
bool skip_classid,
1032
1027
lifetimet lifetime,
1033
- bool override_,
1034
- const typet &override_type,
1028
+ const optionalt<typet> &override_type,
1035
1029
size_t depth,
1036
1030
update_in_placet update_in_place,
1037
1031
const source_locationt &location)
1038
1032
{
1039
- const typet &type=
1040
- override_ ? ns.follow (override_type) : ns.follow (expr.type ());
1041
-
1033
+ const typet &type = override_type.has_value () ? ns.follow (*override_type)
1034
+ : ns.follow (expr.type ());
1042
1035
1043
1036
if (type.id ()==ID_pointer)
1044
1037
{
@@ -1074,7 +1067,8 @@ void java_object_factoryt::gen_nondet_init(
1074
1067
generic_parameter_specialization_map);
1075
1068
if (is_sub)
1076
1069
{
1077
- const typet &symbol = override_ ? override_type : expr.type ();
1070
+ const typet &symbol =
1071
+ override_type.has_value () ? *override_type : expr.type ();
1078
1072
PRECONDITION (symbol.id () == ID_struct_tag);
1079
1073
generic_parameter_specialization_map_keys.insert_pairs_for_symbol (
1080
1074
to_struct_tag_type (symbol), struct_type);
@@ -1146,8 +1140,7 @@ const symbol_exprt java_object_factoryt::gen_nondet_int_init(
1146
1140
irep_idt (),
1147
1141
false , // skip_classid
1148
1142
lifetimet::AUTOMATIC_LOCAL, // immaterial, type is primitive
1149
- false , // override
1150
- typet (), // override type is immaterial
1143
+ {}, // no override type
1151
1144
0 , // depth is immaterial, always non-null
1152
1145
update_in_placet::NO_UPDATE_IN_PLACE,
1153
1146
location);
@@ -1369,8 +1362,7 @@ void java_object_factoryt::array_loop_init_code(
1369
1362
false , // skip_classid
1370
1363
// These are variable in number, so use dynamic allocator:
1371
1364
lifetimet::DYNAMIC,
1372
- true , // override
1373
- element_type,
1365
+ element_type, // override
1374
1366
depth,
1375
1367
child_update_in_place,
1376
1368
location);
@@ -1555,9 +1547,8 @@ exprt object_factory(
1555
1547
" " , // class_identifier
1556
1548
false , // skip_classid
1557
1549
lifetime,
1558
- false , // override
1559
- typet (), // override_type is immaterial
1560
- 1 , // initial depth
1550
+ {}, // no override_type
1551
+ 1 , // initial depth
1561
1552
update_in_placet::NO_UPDATE_IN_PLACE,
1562
1553
loc);
1563
1554
@@ -1627,9 +1618,8 @@ void gen_nondet_init(
1627
1618
" " , // class_identifier
1628
1619
skip_classid,
1629
1620
lifetime,
1630
- false , // override
1631
- typet (), // override_type is immaterial
1632
- 1 , // initial depth
1621
+ {}, // no override_type
1622
+ 1 , // initial depth
1633
1623
update_in_place,
1634
1624
loc);
1635
1625
0 commit comments