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