Skip to content

Commit 6538ab2

Browse files
authored
Merge pull request #3644 from diffblue/type2name-cleanup
type2name cleanup
2 parents b76eb4e + ad7bcae commit 6538ab2

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

src/ansi-c/c_typecheck_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type)
766766

767767
typecheck_compound_body(to_struct_union_type(compound_symbol.type));
768768

769-
std::string typestr=type2name(compound_symbol.type);
769+
std::string typestr = type2name(compound_symbol.type, *this);
770770
compound_symbol.base_name="#anon-"+typestr;
771771
compound_symbol.name="tag-#anon#"+typestr;
772772
identifier=compound_symbol.name;

src/ansi-c/type2name.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ static std::string type2name(
2626
const namespacet &ns,
2727
symbol_numbert &symbol_number);
2828

29-
static std::string type2name_symbol(
30-
const typet &type,
29+
static std::string type2name_tag(
30+
const tag_typet &type,
3131
const namespacet &ns,
3232
symbol_numbert &symbol_number)
3333
{
34-
const irep_idt &identifier=type.get(ID_identifier);
34+
const irep_idt &identifier = type.get_identifier();
3535

3636
const symbolt *symbol;
3737

@@ -91,7 +91,6 @@ static std::string pointer_offset_bits_as_string(
9191
return integer2string(*bits);
9292
}
9393

94-
static bool parent_is_sym_check=false;
9594
static std::string type2name(
9695
const typet &type,
9796
const namespacet &ns,
@@ -193,17 +192,14 @@ static std::string type2name(
193192
}
194193
}
195194
else if(
196-
type.id() == ID_symbol_type || type.id() == ID_c_enum_tag ||
197-
type.id() == ID_struct_tag || type.id() == ID_union_tag)
195+
type.id() == ID_c_enum_tag || type.id() == ID_struct_tag ||
196+
type.id() == ID_union_tag)
198197
{
199-
parent_is_sym_check=true;
200-
result+=type2name_symbol(type, ns, symbol_number);
198+
result += type2name_tag(to_tag_type(type), ns, symbol_number);
201199
}
202200
else if(type.id()==ID_struct ||
203201
type.id()==ID_union)
204202
{
205-
assert(parent_is_sym_check);
206-
parent_is_sym_check=false;
207203
if(type.id()==ID_struct)
208204
result+="ST";
209205
if(type.id()==ID_union)
@@ -277,13 +273,6 @@ static std::string type2name(
277273

278274
std::string type2name(const typet &type, const namespacet &ns)
279275
{
280-
parent_is_sym_check=true;
281276
symbol_numbert symbol_number;
282277
return type2name(type, ns, symbol_number);
283278
}
284-
285-
std::string type2name(const typet &type)
286-
{
287-
symbol_tablet symbol_table;
288-
return type2name(type, namespacet(symbol_table));
289-
}

src/ansi-c/type2name.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Author: Daniel Kroening, [email protected]
1818

1919
class namespacet;
2020

21-
std::string type2name(const typet &type);
2221
std::string type2name(const typet &type, const namespacet &ns);
2322

2423
#endif // CPROVER_ANSI_C_TYPE2NAME_H

0 commit comments

Comments
 (0)