@@ -175,7 +175,7 @@ bool simplify_exprt::simplify_mult(exprt &expr)
175
175
// true if we have found a constant
176
176
bool constant_found = false ;
177
177
178
- typet c_sizeof_type= nil_typet () ;
178
+ optionalt< typet> c_sizeof_type;
179
179
180
180
// scan all the operands
181
181
for (exprt::operandst::iterator it=operands.begin ();
@@ -201,9 +201,13 @@ bool simplify_exprt::simplify_mult(exprt &expr)
201
201
if (it->is_constant () && it->type ()==expr.type ())
202
202
{
203
203
// preserve the sizeof type annotation
204
- if (c_sizeof_type.is_nil ())
205
- c_sizeof_type=
204
+ if (!c_sizeof_type.has_value ())
205
+ {
206
+ const typet &sizeof_type =
206
207
static_cast <const typet &>(it->find (ID_C_c_sizeof_type));
208
+ if (sizeof_type.is_not_nil ())
209
+ c_sizeof_type = sizeof_type;
210
+ }
207
211
208
212
if (constant_found)
209
213
{
@@ -229,13 +233,13 @@ bool simplify_exprt::simplify_mult(exprt &expr)
229
233
it++; // move to the next operand
230
234
}
231
235
232
- if (c_sizeof_type.is_not_nil ())
236
+ if (c_sizeof_type.has_value ())
233
237
{
234
238
INVARIANT (
235
239
constant_found,
236
240
" c_sizeof_type is only set to a non-nil value "
237
241
" if a constant has been found" );
238
- constant->set (ID_C_c_sizeof_type, c_sizeof_type);
242
+ constant->set (ID_C_c_sizeof_type, * c_sizeof_type);
239
243
}
240
244
241
245
if (operands.size ()==1 )
0 commit comments