@@ -623,6 +623,52 @@ void goto_symex_statet::rename_address(
623
623
}
624
624
}
625
625
626
+ static bool requires_renaming (const typet &type, const namespacet &ns)
627
+ {
628
+ if (type.id () == ID_array)
629
+ {
630
+ const auto &array_type = to_array_type (type);
631
+ return requires_renaming (array_type.subtype (), ns) ||
632
+ !array_type.size ().is_constant ();
633
+ }
634
+ else if (
635
+ type.id () == ID_struct || type.id () == ID_union || type.id () == ID_class)
636
+ {
637
+ const struct_union_typet &s_u_type = to_struct_union_type (type);
638
+ const struct_union_typet::componentst &components = s_u_type.components ();
639
+
640
+ for (auto &component : components)
641
+ {
642
+ // be careful, or it might get cyclic
643
+ if (component.type ().id () != ID_pointer)
644
+ return requires_renaming (component.type (), ns);
645
+ }
646
+
647
+ return false ;
648
+ }
649
+ else if (type.id () == ID_pointer)
650
+ {
651
+ return requires_renaming (to_pointer_type (type).subtype (), ns);
652
+ }
653
+ else if (type.id () == ID_symbol_type)
654
+ {
655
+ const symbolt &symbol = ns.lookup (to_symbol_type (type));
656
+ return requires_renaming (symbol.type , ns);
657
+ }
658
+ else if (type.id () == ID_union_tag)
659
+ {
660
+ const symbolt &symbol = ns.lookup (to_union_tag_type (type));
661
+ return requires_renaming (symbol.type , ns);
662
+ }
663
+ else if (type.id () == ID_struct_tag)
664
+ {
665
+ const symbolt &symbol = ns.lookup (to_struct_tag_type (type));
666
+ return requires_renaming (symbol.type , ns);
667
+ }
668
+
669
+ return false ;
670
+ }
671
+
626
672
void goto_symex_statet::rename (
627
673
typet &type,
628
674
const irep_idt &l1_identifier,
@@ -631,7 +677,6 @@ void goto_symex_statet::rename(
631
677
{
632
678
// rename all the symbols with their last known value
633
679
// to the given level
634
-
635
680
std::pair<l1_typest::iterator, bool > l1_type_entry;
636
681
if (level==L2 &&
637
682
!l1_identifier.empty ())
@@ -655,6 +700,11 @@ void goto_symex_statet::rename(
655
700
}
656
701
}
657
702
703
+ // check whether there are symbol expressions in the type; if not, there
704
+ // is no need to expand the struct/union tags in the type
705
+ if (!requires_renaming (type, ns))
706
+ return ; // no action
707
+
658
708
if (type.id ()==ID_array)
659
709
{
660
710
auto &array_type = to_array_type (type);
0 commit comments