@@ -127,6 +127,8 @@ xmlt xml(const exprt &expr, const namespacet &ns)
127
127
128
128
if (expr.id () == ID_constant)
129
129
{
130
+ const auto &constant_expr = to_constant_expr (expr);
131
+
130
132
if (
131
133
type.id () == ID_unsignedbv || type.id () == ID_signedbv ||
132
134
type.id () == ID_c_bit_field)
@@ -135,7 +137,8 @@ xmlt xml(const exprt &expr, const namespacet &ns)
135
137
136
138
result.name = " integer" ;
137
139
result.set_attribute (
138
- " binary" , integer2binary (numeric_cast_v<mp_integer>(expr), width));
140
+ " binary" ,
141
+ integer2binary (numeric_cast_v<mp_integer>(constant_expr), width));
139
142
result.set_attribute (" width" , width);
140
143
141
144
const typet &underlying_type = type.id () == ID_c_bit_field
@@ -158,66 +161,65 @@ xmlt xml(const exprt &expr, const namespacet &ns)
158
161
result.set_attribute (" c_type" , sig + " long long int" );
159
162
160
163
mp_integer i;
161
- if (!to_integer (to_constant_expr ( expr) , i))
164
+ if (!to_integer (expr, i))
162
165
result.data = integer2string (i);
163
166
}
164
167
else if (type.id () == ID_c_enum)
165
168
{
166
169
result.name = " integer" ;
167
- result.set_attribute (" binary" , expr .get_string (ID_value));
170
+ result.set_attribute (" binary" , constant_expr .get_string (ID_value));
168
171
result.set_attribute (
169
172
" width" , to_bitvector_type (to_c_enum_type (type).subtype ()).get_width ());
170
173
result.set_attribute (" c_type" , " enum" );
171
174
172
175
mp_integer i;
173
- if (!to_integer (to_constant_expr (expr) , i))
176
+ if (!to_integer (constant_expr , i))
174
177
result.data = integer2string (i);
175
178
}
176
179
else if (type.id () == ID_c_enum_tag)
177
180
{
178
181
constant_exprt tmp (
179
- to_constant_expr (expr).get_value (),
180
- ns.follow_tag (to_c_enum_tag_type (type)));
182
+ constant_expr.get_value (), ns.follow_tag (to_c_enum_tag_type (type)));
181
183
return xml (tmp, ns);
182
184
}
183
185
else if (type.id () == ID_bv)
184
186
{
185
187
result.name = " bitvector" ;
186
- result.set_attribute (" binary" , expr .get_string (ID_value));
188
+ result.set_attribute (" binary" , constant_expr .get_string (ID_value));
187
189
}
188
190
else if (type.id () == ID_fixedbv)
189
191
{
190
192
result.name = " fixed" ;
191
193
result.set_attribute (" width" , to_bitvector_type (type).get_width ());
192
- result.set_attribute (" binary" , expr .get_string (ID_value));
193
- result.data = fixedbvt (to_constant_expr (expr) ).to_ansi_c_string ();
194
+ result.set_attribute (" binary" , constant_expr .get_string (ID_value));
195
+ result.data = fixedbvt (constant_expr ).to_ansi_c_string ();
194
196
}
195
197
else if (type.id () == ID_floatbv)
196
198
{
197
199
result.name = " float" ;
198
200
result.set_attribute (" width" , to_bitvector_type (type).get_width ());
199
- result.set_attribute (" binary" , expr .get_string (ID_value));
200
- result.data = ieee_floatt (to_constant_expr (expr) ).to_ansi_c_string ();
201
+ result.set_attribute (" binary" , constant_expr .get_string (ID_value));
202
+ result.data = ieee_floatt (constant_expr ).to_ansi_c_string ();
201
203
}
202
204
else if (type.id () == ID_pointer)
203
205
{
204
206
result.name = " pointer" ;
205
- result.set_attribute (" binary" , expr .get_string (ID_value));
206
- if (expr .get (ID_value) == ID_NULL)
207
+ result.set_attribute (" binary" , constant_expr .get_string (ID_value));
208
+ if (constant_expr .get (ID_value) == ID_NULL)
207
209
result.data = " NULL" ;
208
210
}
209
211
else if (type.id () == ID_bool)
210
212
{
211
213
result.name = " boolean" ;
212
- result.set_attribute (" binary" , expr .is_true () ? " 1" : " 0" );
213
- result.data = expr .is_true () ? " TRUE" : " FALSE" ;
214
+ result.set_attribute (" binary" , constant_expr .is_true () ? " 1" : " 0" );
215
+ result.data = constant_expr .is_true () ? " TRUE" : " FALSE" ;
214
216
}
215
217
else if (type.id () == ID_c_bool)
216
218
{
217
219
result.name = " integer" ;
218
220
result.set_attribute (" c_type" , " _Bool" );
219
- result.set_attribute (" binary" , expr .get_string (ID_value));
220
- const mp_integer b = numeric_cast_v<mp_integer>(expr );
221
+ result.set_attribute (" binary" , constant_expr .get_string (ID_value));
222
+ const mp_integer b = numeric_cast_v<mp_integer>(constant_expr );
221
223
result.data = integer2string (b);
222
224
}
223
225
else
0 commit comments