Skip to content

Commit d2f803a

Browse files
author
Daniel Kroening
committed
c++: use struct_tag instead of symbol_type
1 parent e15e407 commit d2f803a

5 files changed

+26
-14
lines changed

src/cpp/cpp_typecheck_bases.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type)
4343
// elaborate any class template instances given as bases
4444
elaborate_class_template(base_symbol_expr.type());
4545

46+
if(base_symbol_expr.type().id() == ID_struct_tag)
47+
base_symbol_expr.type().id(ID_symbol_type);
48+
4649
if(base_symbol_expr.type().id() != ID_symbol_type)
4750
{
4851
error().source_location=name.source_location();

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ void cpp_typecheckt::typecheck_compound_type(
273273
}
274274
else
275275
{
276-
// create type symbol
277-
symbol_typet symbol_type(symbol_name);
278-
qualifiers.write(symbol_type);
279-
type.swap(symbol_type);
276+
// create struct tag
277+
struct_tag_typet tag_type(symbol_name);
278+
qualifiers.write(tag_type);
279+
type.swap(tag_type);
280280
}
281281
}
282282

@@ -569,7 +569,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
569569
// add a virtual-table pointer
570570
struct_typet::componentt compo(
571571
id2string(symbol.name) + "::@vtable_pointer",
572-
pointer_type(symbol_typet(vt_name)));
572+
pointer_type(struct_tag_typet(vt_name)));
573573
compo.set_base_name("@vtable_pointer");
574574
compo.set_pretty_name(id2string(symbol.base_name) + "@vtable_pointer");
575575
compo.set(ID_is_vtptr, true);
@@ -1356,7 +1356,12 @@ void cpp_typecheckt::add_this_to_method_type(
13561356
parameter.set_base_name(ID_this);
13571357
parameter.set_this();
13581358

1359-
typet subtype = symbol_typet(compound_symbol.name);
1359+
typet subtype;
1360+
1361+
if(compound_symbol.type.id() == ID_union)
1362+
subtype = union_tag_typet(compound_symbol.name);
1363+
else
1364+
subtype = struct_tag_typet(compound_symbol.name);
13601365

13611366
if(has_const(method_qualifier))
13621367
subtype.set(ID_C_constant, true);
@@ -1452,7 +1457,7 @@ void cpp_typecheckt::convert_anon_struct_union_member(
14521457
if(struct_union_symbol.type.id() == ID_union)
14531458
compound_type = union_tag_typet(struct_union_symbol.name);
14541459
else
1455-
compound_type = symbol_typet(struct_union_symbol.name);
1460+
compound_type = struct_tag_typet(struct_union_symbol.name);
14561461

14571462
struct_typet::componentt component(identifier, compound_type);
14581463
component.set_access(access);

src/cpp/cpp_typecheck_expr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr)
120120
{
121121
// these appear to have type "struct _GUID"
122122
// and they are lvalues!
123-
expr.type()=symbol_typet("tag-_GUID");
123+
expr.type() = struct_tag_typet("tag-_GUID");
124124
follow(expr.type());
125125
expr.set(ID_C_lvalue, true);
126126
}
@@ -717,7 +717,7 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr)
717717
if(args.size() > 0 && args[0].get(ID_C_base_name)==ID_this)
718718
{
719719
// it's a pointer to member function
720-
const symbol_typet symbol(code_type.get(ID_C_member_name));
720+
const struct_tag_typet symbol(code_type.get(ID_C_member_name));
721721
expr.op0().type().add("to-member")=symbol;
722722

723723
if(code_type.get_bool(ID_C_is_virtual))
@@ -980,11 +980,11 @@ void cpp_typecheckt::typecheck_expr_explicit_constructor_call(exprt &expr)
980980
{
981981
assert(expr.type().id()==ID_struct);
982982

983-
symbol_typet symb(expr.type().get(ID_name));
984-
symb.add_source_location()=expr.source_location();
983+
struct_tag_typet tag(expr.type().get(ID_name));
984+
tag.add_source_location() = expr.source_location();
985985

986986
exprt e=expr;
987-
new_temporary(e.source_location(), symb, e.operands(), expr);
987+
new_temporary(e.source_location(), tag, e.operands(), expr);
988988
}
989989
}
990990

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ void cpp_typecheck_resolvet::remove_duplicates(
162162
id = to_symbol_expr(old_id).get_identifier();
163163
else if(old_id.id() == ID_type && old_id.type().id() == ID_symbol_type)
164164
id = to_symbol_type(old_id.type()).get_identifier();
165+
else if(old_id.id() == ID_type && old_id.type().id() == ID_struct_tag)
166+
id = to_struct_tag_type(old_id.type()).get_identifier();
167+
else if(old_id.id() == ID_type && old_id.type().id() == ID_union_tag)
168+
id = to_union_tag_type(old_id.type()).get_identifier();
165169

166170
if(id=="")
167171
{

src/cpp/cpp_typecheck_virtual_table.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol)
7474
vt_symb_var.mode=ID_cpp;
7575
vt_symb_var.module=module;
7676
vt_symb_var.location=vt_symb_type.location;
77-
vt_symb_var.type=symbol_typet(vt_symb_type.name);
77+
vt_symb_var.type = struct_tag_typet(vt_symb_type.name);
7878
vt_symb_var.is_lvalue=true;
7979
vt_symb_var.is_static_lifetime=true;
8080

8181
// do the values
8282
const struct_typet &vt_type=to_struct_type(vt_symb_type.type);
8383

84-
struct_exprt values(symbol_typet(vt_symb_type.name));
84+
struct_exprt values(struct_tag_typet(vt_symb_type.name));
8585

8686
for(const auto &compo : vt_type.components())
8787
{

0 commit comments

Comments
 (0)