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