Skip to content

Commit 215943c

Browse files
Refactor rename using expr_try_dynamic_cast
Use expr_try_dynamic_cast to check the type and convert in one instruction, which makes the code clearer.
1 parent b6707bb commit 215943c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/goto-symex/goto_symex_state.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -675,18 +675,15 @@ void goto_symex_statet::rename(
675675
}
676676
}
677677

678-
if(type.id()==ID_array)
678+
if(const auto &array_type = type_try_dynamic_cast<array_typet>(type))
679679
{
680-
auto &array_type = to_array_type(type);
681-
rename(array_type.subtype(), irep_idt(), ns, level);
682-
rename(array_type.size(), ns, level);
680+
rename(array_type->subtype(), irep_idt(), ns, level);
681+
rename(array_type->size(), ns, level);
683682
}
684-
else if(type.id() == ID_struct || type.id() == ID_union)
683+
else if(
684+
const auto &s_u_type = type_try_dynamic_cast<struct_union_typet>(type))
685685
{
686-
struct_union_typet &s_u_type=to_struct_union_type(type);
687-
struct_union_typet::componentst &components=s_u_type.components();
688-
689-
for(auto &component : components)
686+
for(auto &component : s_u_type->components())
690687
{
691688
// be careful, or it might get cyclic
692689
if(component.type().id() == ID_array)

0 commit comments

Comments
 (0)