Skip to content

Commit defda7b

Browse files
Uses alternatives to get_string in type2name when possible
1 parent bacb1d5 commit defda7b

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/ansi-c/type2name.cpp

+21-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Author: Daniel Kroening, [email protected]
1414
#include <util/namespace.h>
1515
#include <util/symbol.h>
1616
#include <util/symbol_table.h>
17+
#include <util/pointer_offset_size.h>
18+
#include <util/invariant.h>
1719

1820
#include "type2name.h"
1921

@@ -81,6 +83,15 @@ static std::string type2name_symbol(
8183
return result;
8284
}
8385

86+
static std::string pointer_offset_bits_as_string(
87+
const typet &type,
88+
const namespacet &ns)
89+
{
90+
mp_integer bits = pointer_offset_bits(type, ns);
91+
CHECK_RETURN(bits != -1);
92+
return integer2string(bits);
93+
}
94+
8495
static bool parent_is_sym_check=false;
8596
static std::string type2name(
8697
const typet &type,
@@ -115,9 +126,9 @@ static std::string type2name(
115126
else if(type.id()==ID_empty)
116127
result+='V';
117128
else if(type.id()==ID_signedbv)
118-
result+="S" + type.get_string(ID_width);
129+
result+="S" + pointer_offset_bits_as_string(type, ns);
119130
else if(type.id()==ID_unsignedbv)
120-
result+="U" + type.get_string(ID_width);
131+
result+="U" + pointer_offset_bits_as_string(type, ns);
121132
else if(type.id()==ID_bool ||
122133
type.id()==ID_c_bool)
123134
result+='B';
@@ -128,13 +139,13 @@ static std::string type2name(
128139
else if(type.id()==ID_complex)
129140
result+='C';
130141
else if(type.id()==ID_floatbv)
131-
result+="F" + type.get_string(ID_width);
142+
result+="F" + pointer_offset_bits_as_string(type, ns);
132143
else if(type.id()==ID_fixedbv)
133-
result+="X" + type.get_string(ID_width);
144+
result+="X" + pointer_offset_bits_as_string(type, ns);
134145
else if(type.id()==ID_natural)
135146
result+='N';
136147
else if(type.id()==ID_pointer)
137-
result+='*';
148+
result+="*" + pointer_offset_bits_as_string(type, ns);
138149
else if(type.id()==ID_reference)
139150
result+='&';
140151
else if(type.id()==ID_code)
@@ -168,7 +179,7 @@ static std::string type2name(
168179
const array_typet &t=to_array_type(type);
169180
mp_integer size;
170181
if(t.size().id()==ID_symbol)
171-
result+="ARR"+t.size().get_string(ID_identifier);
182+
result+="ARR"+id2string(t.size().get(ID_identifier));
172183
else if(to_integer(t.size(), size))
173184
result+="ARR?";
174185
else
@@ -202,7 +213,9 @@ static std::string type2name(
202213
if(it!=components.begin())
203214
result+='|';
204215
result+=type2name(it->type(), ns, symbol_number);
205-
result+="'"+it->get_string(ID_name)+"'";
216+
irep_idt component_name = it->get_name();
217+
CHECK_RETURN(!component_name.empty());
218+
result+="'"+id2string(component_name)+"'";
206219
}
207220
result+=']';
208221
}
@@ -230,7 +243,7 @@ static std::string type2name(
230243
else if(type.id()==ID_incomplete_c_enum)
231244
result +="EN?";
232245
else if(type.id()==ID_c_bit_field)
233-
result+="BF"+type.get_string(ID_width);
246+
result+="BF"+pointer_offset_bits_as_string(type, ns);
234247
else if(type.id()==ID_vector)
235248
result+="VEC"+type.get_string(ID_size);
236249
else

0 commit comments

Comments
 (0)