@@ -632,54 +632,6 @@ void goto_symex_statet::rename_address(exprt &expr, const namespacet &ns)
632
632
}
633
633
}
634
634
635
- // / Return true if, and only if, the \p type or one of its subtypes requires SSA
636
- // / renaming. Renaming is necessary when symbol expressions occur within the
637
- // / type, which is the case for arrays of non-constant size.
638
- static bool requires_renaming (const typet &type, const namespacet &ns)
639
- {
640
- if (type.id () == ID_array)
641
- {
642
- const auto &array_type = to_array_type (type);
643
- return requires_renaming (array_type.subtype (), ns) ||
644
- !array_type.size ().is_constant ();
645
- }
646
- else if (
647
- type.id () == ID_struct || type.id () == ID_union || type.id () == ID_class)
648
- {
649
- const struct_union_typet &s_u_type = to_struct_union_type (type);
650
- const struct_union_typet::componentst &components = s_u_type.components ();
651
-
652
- for (auto &component : components)
653
- {
654
- // be careful, or it might get cyclic
655
- if (
656
- component.type ().id () != ID_pointer &&
657
- requires_renaming (component.type (), ns))
658
- {
659
- return true ;
660
- }
661
- }
662
-
663
- return false ;
664
- }
665
- else if (type.id () == ID_pointer)
666
- {
667
- return requires_renaming (to_pointer_type (type).subtype (), ns);
668
- }
669
- else if (type.id () == ID_union_tag)
670
- {
671
- const symbolt &symbol = ns.lookup (to_union_tag_type (type));
672
- return requires_renaming (symbol.type , ns);
673
- }
674
- else if (type.id () == ID_struct_tag)
675
- {
676
- const symbolt &symbol = ns.lookup (to_struct_tag_type (type));
677
- return requires_renaming (symbol.type , ns);
678
- }
679
-
680
- return false ;
681
- }
682
-
683
635
template <levelt level>
684
636
void goto_symex_statet::rename (
685
637
typet &type,
@@ -704,32 +656,26 @@ optionalt<typet> goto_symex_statet::rename_type(
704
656
const irep_idt &l1_identifier,
705
657
const namespacet &ns)
706
658
{
707
- // check whether there are symbol expressions in the type; if not, there
708
- // is no need to expand the struct/union tags in the type
709
- if (!requires_renaming (type, ns))
710
- return {};
711
-
712
659
// rename all the symbols with their last known value
713
660
// to the given level
714
661
715
- std::pair<l1_typest::iterator, bool > l1_type_entry;
716
662
if (level==L2 &&
717
663
!l1_identifier.empty ())
718
664
{
719
- l1_type_entry= l1_types.insert ( std::make_pair ( l1_identifier, type) );
665
+ auto l1_type_entry = l1_types.find ( l1_identifier);
720
666
721
- if (! l1_type_entry. second ) // was already in map
667
+ if (l1_type_entry != l1_types. end ())
722
668
{
723
669
// do not change a complete array type to an incomplete one
724
670
725
- const typet &type_prev= l1_type_entry. first ->second ;
671
+ const typet &type_prev = l1_type_entry->second ;
726
672
727
673
if (type.id ()!=ID_array ||
728
674
type_prev.id ()!=ID_array ||
729
675
to_array_type (type).is_incomplete () ||
730
676
to_array_type (type_prev).is_complete ())
731
677
{
732
- return l1_type_entry. first ->second ;
678
+ return l1_type_entry->second ;
733
679
}
734
680
}
735
681
}
@@ -805,14 +751,11 @@ optionalt<typet> goto_symex_statet::rename_type(
805
751
}
806
752
else if (type.id () == ID_struct_tag || type.id () == ID_union_tag)
807
753
{
808
- const typet &followed_type = ns.follow (type);
809
- result = rename_type<level>(followed_type, l1_identifier, ns);
810
- if (!result.has_value ())
811
- result = followed_type;
754
+ result = rename_type<level>(ns.follow (type), l1_identifier, ns);
812
755
}
813
756
814
757
if (level == L2 && !l1_identifier.empty () && result.has_value ())
815
- l1_type_entry. first -> second = *result;
758
+ l1_types. emplace (l1_identifier, *result) ;
816
759
817
760
return result;
818
761
}
0 commit comments