Skip to content

Commit 705f150

Browse files
author
Enrico Steffinlongo
committed
Use new improved functions for c_enum_typet
1 parent f371b86 commit 705f150

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/ansi-c/c_typecheck_type.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,8 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type)
12701270
// we also track min and max to find a nice base type
12711271
mp_integer value=0, min_value=0, max_value=0;
12721272

1273-
std::list<c_enum_typet::c_enum_membert> enum_members;
1273+
std::vector<c_enum_typet::c_enum_membert> enum_members;
1274+
enum_members.reserve(as_expr.operands().size());
12741275

12751276
// We need to determine a width, and a signedness
12761277
// to obtain an 'underlying type'.
@@ -1413,14 +1414,11 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type)
14131414
enum_tag_symbol.is_file_local=true;
14141415
enum_tag_symbol.base_name=base_name;
14151416

1416-
// throw in the enum members as 'body'
1417-
irept::subt &body=enum_tag_symbol.type.add(ID_body).get_sub();
1418-
1419-
for(const auto &member : enum_members)
1420-
body.push_back(member);
1421-
14221417
enum_tag_symbol.type.add_subtype() = underlying_type;
14231418

1419+
// throw in the enum members as 'body'
1420+
to_c_enum_type(enum_tag_symbol.type).members() = std::move(enum_members);
1421+
14241422
// is it in the symbol table already?
14251423
symbolt *existing_symbol = symbol_table.get_writeable(identifier);
14261424

0 commit comments

Comments
 (0)