@@ -85,8 +85,11 @@ bvt boolbvt::conversion_failed(const exprt &expr)
85
85
ignoring (expr);
86
86
87
87
// try to make it free bits
88
- std::size_t width=boolbv_width (expr.type ());
89
- return prop.new_variables (width);
88
+ // TODO we likely end up in this path when an earlier call to boolbv_width
89
+ // failed
90
+ const auto &width_opt = boolbv_width (expr.type ());
91
+ CHECK_RETURN (width_opt.has_value ());
92
+ return prop.new_variables (*width_opt);
90
93
}
91
94
92
95
// / Converts an expression into its gate-level representation and returns a
@@ -234,11 +237,12 @@ bvt boolbvt::convert_bitvector(const exprt &expr)
234
237
235
238
bvt boolbvt::convert_array_comprehension (const array_comprehension_exprt &expr)
236
239
{
237
- std::size_t width=boolbv_width (expr.type ());
238
-
239
- if (width==0 )
240
+ const auto &width_opt = boolbv_width (expr.type ());
241
+ if (!width_opt.has_value ())
240
242
return conversion_failed (expr);
241
243
244
+ const std::size_t width = *width_opt;
245
+
242
246
const exprt &array_size = expr.type ().size ();
243
247
244
248
const auto size = numeric_cast<mp_integer>(array_size);
@@ -276,7 +280,9 @@ bvt boolbvt::convert_array_comprehension(const array_comprehension_exprt &expr)
276
280
bvt boolbvt::convert_symbol (const exprt &expr)
277
281
{
278
282
const typet &type=expr.type ();
279
- std::size_t width=boolbv_width (type);
283
+ const auto &width_opt = boolbv_width (type);
284
+ CHECK_RETURN (width_opt.has_value ());
285
+ const std::size_t width = *width_opt;
280
286
281
287
const irep_idt &identifier = expr.get (ID_identifier);
282
288
CHECK_RETURN (!identifier.empty ());
@@ -304,7 +310,9 @@ bvt boolbvt::convert_function_application(
304
310
functions.record (expr);
305
311
306
312
// make it free bits
307
- return prop.new_variables (boolbv_width (expr.type ()));
313
+ const auto &width_opt = boolbv_width (expr.type ());
314
+ CHECK_RETURN (width_opt.has_value ());
315
+ return prop.new_variables (*width_opt);
308
316
}
309
317
310
318
@@ -515,12 +523,12 @@ bool boolbvt::is_unbounded_array(const typet &type) const
515
523
if (unbounded_array==unbounded_arrayt::U_ALL)
516
524
return true ;
517
525
518
- const std:: size_t size = boolbv_width (type);
519
- if (size == 0 )
526
+ const auto &size_opt = boolbv_width (type);
527
+ if (!size_opt. has_value () )
520
528
return true ;
521
529
522
530
if (unbounded_array==unbounded_arrayt::U_AUTO)
523
- if (size > MAX_FLATTENED_ARRAY_SIZE)
531
+ if (*size_opt > MAX_FLATTENED_ARRAY_SIZE)
524
532
return true ;
525
533
526
534
return false ;
@@ -564,7 +572,9 @@ boolbvt::offset_mapt boolbvt::build_offset_map(const struct_typet &src)
564
572
for (const auto &comp : components)
565
573
{
566
574
dest.push_back (offset);
567
- offset += boolbv_width (comp.type ());
575
+ const auto &comp_width_opt = boolbv_width (comp.type ());
576
+ CHECK_RETURN (comp_width_opt.has_value ());
577
+ offset += *comp_width_opt;
568
578
}
569
579
return dest;
570
580
}
0 commit comments