@@ -175,7 +175,7 @@ bool simplify_exprt::simplify_mult(exprt &expr)
175175 // true if we have found a constant
176176 bool constant_found = false ;
177177
178- typet c_sizeof_type= nil_typet () ;
178+ optionalt< typet> c_sizeof_type;
179179
180180 // scan all the operands
181181 for (exprt::operandst::iterator it=operands.begin ();
@@ -201,9 +201,13 @@ bool simplify_exprt::simplify_mult(exprt &expr)
201201 if (it->is_constant () && it->type ()==expr.type ())
202202 {
203203 // 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 =
206207 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+ }
207211
208212 if (constant_found)
209213 {
@@ -229,13 +233,13 @@ bool simplify_exprt::simplify_mult(exprt &expr)
229233 it++; // move to the next operand
230234 }
231235
232- if (c_sizeof_type.is_not_nil ())
236+ if (c_sizeof_type.has_value ())
233237 {
234238 INVARIANT (
235239 constant_found,
236240 " c_sizeof_type is only set to a non-nil value "
237241 " 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);
239243 }
240244
241245 if (operands.size ()==1 )
0 commit comments