@@ -249,9 +249,11 @@ void java_object_factoryt::gen_pointer_target_init(
249
249
PRECONDITION (expr.type ().id () == ID_pointer);
250
250
PRECONDITION (update_in_place != update_in_placet::MAY_UPDATE_IN_PLACE);
251
251
252
- if (target_type.id () == ID_struct)
252
+ const typet &followed_target_type = ns.follow (target_type);
253
+
254
+ if (followed_target_type.id () == ID_struct)
253
255
{
254
- const auto &target_class_type = to_java_class_type (target_type );
256
+ const auto &target_class_type = to_java_class_type (followed_target_type );
255
257
if (has_prefix (id2string (target_class_type.get_tag ()), " java::array[" ))
256
258
{
257
259
gen_nondet_array_init (
@@ -565,10 +567,11 @@ void java_object_factoryt::gen_nondet_pointer_init(
565
567
// When we visit for 2nd time a type AND the maximum depth is exceeded, we set
566
568
// the pointer to NULL instead of recursively initializing the struct to which
567
569
// it points.
568
- const typet &subtype=ns.follow (pointer_type.subtype ());
569
- if (subtype.id ()==ID_struct)
570
+ const typet &subtype = pointer_type.subtype ();
571
+ const typet &followed_subtype = ns.follow (subtype);
572
+ if (followed_subtype.id () == ID_struct)
570
573
{
571
- const struct_typet &struct_type= to_struct_type (subtype );
574
+ const struct_typet &struct_type = to_struct_type (followed_subtype );
572
575
const irep_idt &struct_tag=struct_type.get_tag ();
573
576
574
577
// If this is a recursive type of some kind AND the depth is exceeded, set
@@ -604,7 +607,9 @@ void java_object_factoryt::gen_nondet_pointer_init(
604
607
// decide to do this for all types, we should do it here.
605
608
// Note also that this logic is mirrored in
606
609
// ci_lazy_methodst::initialize_instantiated_classes.
607
- if (const auto class_type = type_try_dynamic_cast<java_class_typet>(subtype))
610
+ if (
611
+ const auto class_type =
612
+ type_try_dynamic_cast<java_class_typet>(followed_subtype))
608
613
{
609
614
if (class_type->get_base (" java::java.lang.Enum" ) && !must_be_null)
610
615
{
@@ -1024,8 +1029,8 @@ void java_object_factoryt::gen_nondet_init(
1024
1029
update_in_placet update_in_place,
1025
1030
const source_locationt &location)
1026
1031
{
1027
- const typet &type = override_type.has_value () ? ns. follow ( *override_type)
1028
- : ns.follow (expr. type () );
1032
+ const typet &type = override_type.has_value () ? *override_type : expr. type ();
1033
+ const typet &followed_type = ns.follow (type);
1029
1034
1030
1035
if (type.id ()==ID_pointer)
1031
1036
{
@@ -1049,9 +1054,9 @@ void java_object_factoryt::gen_nondet_init(
1049
1054
update_in_place,
1050
1055
location);
1051
1056
}
1052
- else if (type .id ()== ID_struct)
1057
+ else if (followed_type .id () == ID_struct)
1053
1058
{
1054
- const struct_typet struct_type= to_struct_type (type );
1059
+ const struct_typet struct_type = to_struct_type (followed_type );
1055
1060
1056
1061
// If we are about to initialize a generic class (as a superclass object
1057
1062
// for a different object), add its concrete types to the map and delete
0 commit comments