@@ -199,10 +199,8 @@ void java_object_factoryt::gen_pointer_target_init(
199199 PRECONDITION (update_in_place != update_in_placet::MAY_UPDATE_IN_PLACE);
200200
201201 const namespacet ns (symbol_table);
202- const typet &followed_target_type = ns.follow (target_type);
203- PRECONDITION (followed_target_type.id () == ID_struct);
204-
205- const auto &target_class_type = to_java_class_type (followed_target_type);
202+ const auto &target_class_type =
203+ to_java_class_type (ns.follow_tag (to_struct_tag_type (target_type)));
206204 if (target_class_type.get_tag ().starts_with (" java::array[" ))
207205 {
208206 assignments.append (gen_nondet_array_init (
@@ -374,7 +372,7 @@ void initialize_nondet_string_fields(
374372{
375373 namespacet ns (symbol_table);
376374 const struct_typet &struct_type =
377- to_struct_type ( ns.follow (struct_expr.type ()));
375+ ns.follow_tag ( to_struct_tag_type (struct_expr.type ()));
378376 PRECONDITION (is_java_string_type (struct_type));
379377
380378 // We allow type StringBuffer and StringBuilder to be initialized
@@ -481,9 +479,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
481479{
482480 PRECONDITION (expr.type ().id ()==ID_pointer);
483481 const namespacet ns (symbol_table);
484- const typet &subtype = pointer_type.base_type ();
485- const typet &followed_subtype = ns.follow (subtype);
486- PRECONDITION (followed_subtype.id () == ID_struct);
487482 const pointer_typet &replacement_pointer_type =
488483 pointer_type_selector.convert_pointer_type (
489484 pointer_type, generic_parameter_specialization_map, ns);
@@ -501,7 +496,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
501496 generic_parameter_specialization_map);
502497 generic_parameter_specialization_map_keys.insert (
503498 replacement_pointer_type,
504- ns.follow ( replacement_pointer_type.base_type ()));
499+ ns.follow_tag ( to_struct_tag_type ( replacement_pointer_type.base_type () )));
505500
506501 const symbol_exprt real_pointer_symbol = gen_nondet_subtype_pointer_init (
507502 assignments, lifetime, replacement_pointer_type, depth, location);
@@ -529,7 +524,9 @@ void java_object_factoryt::gen_nondet_pointer_init(
529524 // When we visit for 2nd time a type AND the maximum depth is exceeded, we set
530525 // the pointer to NULL instead of recursively initializing the struct to which
531526 // it points.
532- const struct_typet &struct_type = to_struct_type (followed_subtype);
527+ const struct_tag_typet &tag_type =
528+ to_struct_tag_type (pointer_type.base_type ());
529+ const struct_typet &struct_type = ns.follow_tag (tag_type);
533530 const irep_idt &struct_tag = struct_type.get_tag ();
534531
535532 // If this is a recursive type of some kind AND the depth is exceeded, set
@@ -564,7 +561,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
564561 // ci_lazy_methodst::initialize_instantiated_classes.
565562 if (
566563 const auto class_type =
567- type_try_dynamic_cast<java_class_typet>(followed_subtype ))
564+ type_try_dynamic_cast<java_class_typet>(struct_type ))
568565 {
569566 if (class_type->get_base (" java::java.lang.Enum" ))
570567 {
@@ -581,13 +578,13 @@ void java_object_factoryt::gen_nondet_pointer_init(
581578 // if the initialization mode is MAY_UPDATE or MUST_UPDATE in place, then we
582579 // emit to `update_in_place_assignments` code for in-place initialization of
583580 // the object pointed by `expr`, assuming that such object is of type
584- // `subtype `
581+ // `tag_type `
585582 if (update_in_place!=update_in_placet::NO_UPDATE_IN_PLACE)
586583 {
587584 gen_pointer_target_init (
588585 update_in_place_assignments,
589586 expr,
590- subtype ,
587+ tag_type ,
591588 lifetime,
592589 depth,
593590 update_in_placet::MUST_UPDATE_IN_PLACE,
@@ -610,7 +607,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
610607 gen_pointer_target_init (
611608 non_null_inst,
612609 expr,
613- subtype ,
610+ tag_type ,
614611 lifetime,
615612 depth,
616613 update_in_placet::NO_UPDATE_IN_PLACE,
@@ -773,7 +770,7 @@ void java_object_factoryt::gen_nondet_struct_init(
773770 const source_locationt &location)
774771{
775772 const namespacet ns (symbol_table);
776- PRECONDITION (ns. follow ( expr.type ()) .id ()==ID_struct );
773+ PRECONDITION (expr.type ().id () == ID_struct_tag );
777774
778775 typedef struct_typet::componentst componentst;
779776 const irep_idt &struct_tag=struct_type.get_tag ();
@@ -1008,7 +1005,6 @@ void java_object_factoryt::gen_nondet_init(
10081005{
10091006 const typet &type = override_type.has_value () ? *override_type : expr.type ();
10101007 const namespacet ns (symbol_table);
1011- const typet &followed_type = ns.follow (type);
10121008
10131009 if (type.id ()==ID_pointer)
10141010 {
@@ -1021,7 +1017,8 @@ void java_object_factoryt::gen_nondet_init(
10211017 generic_parameter_specialization_map_keys (
10221018 generic_parameter_specialization_map);
10231019 generic_parameter_specialization_map_keys.insert (
1024- pointer_type, ns.follow (pointer_type.base_type ()));
1020+ pointer_type,
1021+ ns.follow_tag (to_struct_tag_type (pointer_type.base_type ())));
10251022
10261023 gen_nondet_pointer_init (
10271024 assignments,
@@ -1032,9 +1029,9 @@ void java_object_factoryt::gen_nondet_init(
10321029 update_in_place,
10331030 location);
10341031 }
1035- else if (followed_type .id () == ID_struct )
1032+ else if (type .id () == ID_struct_tag )
10361033 {
1037- const struct_typet struct_type = to_struct_type (followed_type );
1034+ const struct_typet struct_type = ns. follow_tag ( to_struct_tag_type (type) );
10381035
10391036 // If we are about to initialize a generic class (as a superclass object
10401037 // for a different object), add its concrete types to the map and delete
@@ -1388,8 +1385,8 @@ code_blockt gen_nondet_array_init(
13881385 code_blockt statements;
13891386
13901387 const namespacet ns (symbol_table);
1391- const typet &type = ns. follow ( to_pointer_type (expr. type ()). base_type ());
1392- const struct_typet &struct_type = to_struct_type ( type);
1388+ const struct_typet &struct_type =
1389+ ns. follow_tag ( to_struct_tag_type ( to_pointer_type (expr. type ()). base_type ()) );
13931390 const typet &element_type = static_cast <const typet &>(
13941391 to_pointer_type (expr.type ()).base_type ().find (ID_element_type));
13951392
@@ -1492,7 +1489,8 @@ bool java_object_factoryt::gen_nondet_enum_init(
14921489
14931490 // Access members (length and data) of $VALUES array
14941491 dereference_exprt deref_expr (values.symbol_expr ());
1495- const auto &deref_struct_type = to_struct_type (ns.follow (deref_expr.type ()));
1492+ const auto &deref_struct_type =
1493+ ns.follow_tag (to_struct_tag_type (deref_expr.type ()));
14961494 PRECONDITION (is_valid_java_array (deref_struct_type));
14971495 const auto &comps = deref_struct_type.components ();
14981496 const member_exprt length_expr (deref_expr, " length" , comps[1 ].type ());
0 commit comments