@@ -131,14 +131,13 @@ xmlt xml(const exprt &expr, const namespacet &ns)
131
131
132
132
if (
133
133
type.id () == ID_unsignedbv || type.id () == ID_signedbv ||
134
- type.id () == ID_c_bit_field)
134
+ type.id () == ID_c_bit_field || type. id () == ID_c_bool )
135
135
{
136
+ mp_integer i = numeric_cast_v<mp_integer>(constant_expr);
136
137
std::size_t width = to_bitvector_type (type).get_width ();
137
138
138
139
result.name = " integer" ;
139
- result.set_attribute (
140
- " binary" ,
141
- integer2binary (numeric_cast_v<mp_integer>(constant_expr), width));
140
+ result.set_attribute (" binary" , integer2binary (i, width));
142
141
result.set_attribute (" width" , width);
143
142
144
143
const typet &underlying_type = type.id () == ID_c_bit_field
@@ -149,7 +148,9 @@ xmlt xml(const exprt &expr, const namespacet &ns)
149
148
150
149
std::string sig = is_signed ? " " : " unsigned " ;
151
150
152
- if (width == config.ansi_c .char_width )
151
+ if (type.id () == ID_c_bool)
152
+ result.set_attribute (" c_type" , " _Bool" );
153
+ else if (width == config.ansi_c .char_width )
153
154
result.set_attribute (" c_type" , sig + " char" );
154
155
else if (width == config.ansi_c .int_width )
155
156
result.set_attribute (" c_type" , sig + " int" );
@@ -160,9 +161,7 @@ xmlt xml(const exprt &expr, const namespacet &ns)
160
161
else if (width == config.ansi_c .long_long_int_width )
161
162
result.set_attribute (" c_type" , sig + " long long int" );
162
163
163
- mp_integer i;
164
- if (!to_integer (expr, i))
165
- result.data = integer2string (i);
164
+ result.data = integer2string (i);
166
165
}
167
166
else if (type.id () == ID_c_enum)
168
167
{
@@ -214,14 +213,6 @@ xmlt xml(const exprt &expr, const namespacet &ns)
214
213
result.set_attribute (" binary" , constant_expr.is_true () ? " 1" : " 0" );
215
214
result.data = constant_expr.is_true () ? " TRUE" : " FALSE" ;
216
215
}
217
- else if (type.id () == ID_c_bool)
218
- {
219
- result.name = " integer" ;
220
- result.set_attribute (" c_type" , " _Bool" );
221
- result.set_attribute (" binary" , constant_expr.get_string (ID_value));
222
- const mp_integer b = numeric_cast_v<mp_integer>(constant_expr);
223
- result.data = integer2string (b);
224
- }
225
216
else
226
217
{
227
218
result.name = " unknown" ;
0 commit comments