@@ -611,12 +611,63 @@ void goto_symex_statet::rename_address(
611
611
}
612
612
}
613
613
614
+ static bool requires_renaming (const typet &type, const namespacet &ns)
615
+ {
616
+ if (type.id () == ID_array)
617
+ {
618
+ const auto &array_type = to_array_type (type);
619
+ return requires_renaming (array_type.subtype (), ns) ||
620
+ !array_type.size ().is_constant ();
621
+ }
622
+ else if (
623
+ type.id () == ID_struct || type.id () == ID_union || type.id () == ID_class)
624
+ {
625
+ const struct_union_typet &s_u_type = to_struct_union_type (type);
626
+ const struct_union_typet::componentst &components = s_u_type.components ();
627
+
628
+ for (auto &component : components)
629
+ {
630
+ // be careful, or it might get cyclic
631
+ if (component.type ().id () != ID_pointer)
632
+ return requires_renaming (component.type (), ns);
633
+ }
634
+
635
+ return false ;
636
+ }
637
+ else if (type.id () == ID_pointer)
638
+ {
639
+ return requires_renaming (to_pointer_type (type).subtype (), ns);
640
+ }
641
+ else if (type.id () == ID_symbol_type)
642
+ {
643
+ const symbolt &symbol = ns.lookup (to_symbol_type (type));
644
+ return requires_renaming (symbol.type , ns);
645
+ }
646
+ else if (type.id () == ID_union_tag)
647
+ {
648
+ const symbolt &symbol = ns.lookup (to_union_tag_type (type));
649
+ return requires_renaming (symbol.type , ns);
650
+ }
651
+ else if (type.id () == ID_struct_tag)
652
+ {
653
+ const symbolt &symbol = ns.lookup (to_struct_tag_type (type));
654
+ return requires_renaming (symbol.type , ns);
655
+ }
656
+
657
+ return false ;
658
+ }
659
+
614
660
void goto_symex_statet::rename (
615
661
typet &type,
616
662
const irep_idt &l1_identifier,
617
663
const namespacet &ns,
618
664
levelt level)
619
665
{
666
+ // check whether there are symbol expressions in the type; if not, there
667
+ // is no need to expand the struct/union tags in the type
668
+ if (!requires_renaming (type, ns))
669
+ return ; // no action
670
+
620
671
// rename all the symbols with their last known value
621
672
// to the given level
622
673
0 commit comments