Skip to content

Commit 600a2af

Browse files
tautschnigDaniel Kroening
authored andcommitted
Tag-type related cleanup in xml_expr.cpp
1) Don't use ns.follow unless strictly necessary. 2) Support struct/uniont tag types in xml(typet)
1 parent 0bf061b commit 600a2af

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/goto-programs/xml_expr.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ xmlt xml(const typet &type, const namespacet &ns)
103103
e.new_element("type").new_element() = xml(component.type(), ns);
104104
}
105105
}
106+
else if(type.id() == ID_struct_tag)
107+
{
108+
return xml(ns.follow_tag(to_struct_tag_type(type)), ns);
109+
}
106110
else if(type.id() == ID_union)
107111
{
108112
result.name = "union";
@@ -115,6 +119,10 @@ xmlt xml(const typet &type, const namespacet &ns)
115119
e.new_element("type").new_element() = xml(component.type(), ns);
116120
}
117121
}
122+
else if(type.id() == ID_union_tag)
123+
{
124+
return xml(ns.follow_tag(to_union_tag_type(type)), ns);
125+
}
118126
else
119127
result.name = "unknown";
120128

@@ -125,12 +133,12 @@ xmlt xml(const exprt &expr, const namespacet &ns)
125133
{
126134
xmlt result;
127135

128-
const typet &type = ns.follow(expr.type());
129-
130136
if(expr.id() == ID_constant)
131137
{
132138
const auto &constant_expr = to_constant_expr(expr);
133139

140+
const typet &type = expr.type();
141+
134142
if(
135143
type.id() == ID_unsignedbv || type.id() == ID_signedbv ||
136144
type.id() == ID_c_bit_field || type.id() == ID_c_bool)
@@ -238,6 +246,8 @@ xmlt xml(const exprt &expr, const namespacet &ns)
238246
{
239247
result.name = "struct";
240248

249+
const typet &type = ns.follow(expr.type());
250+
241251
// these are expected to have a struct type
242252
if(type.id() == ID_struct)
243253
{

0 commit comments

Comments
 (0)