@@ -88,9 +88,10 @@ bvt boolbvt::convert_floatbv_op(const exprt &expr)
88
88
bvt rounding_mode_as_bv = convert_bv (rounding_mode);
89
89
90
90
const typet &resolved_type = ns.follow (expr.type ());
91
- DATA_INVARIANT (
91
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
92
92
lhs.type () == resolved_type && rhs.type () == resolved_type,
93
- " float op with mixed types:\n " + expr.pretty ());
93
+ " both operands of a floating point operator must have the same type" ,
94
+ irep_pretty_diagnosticst{expr});
94
95
95
96
float_utilst float_utils (prop);
96
97
@@ -111,7 +112,7 @@ bvt boolbvt::convert_floatbv_op(const exprt &expr)
111
112
else if (expr.id ()==ID_floatbv_rem)
112
113
return float_utils.rem (lhs_as_bv, rhs_as_bv);
113
114
else
114
- throw " unexpected operator " +expr. id_string () ;
115
+ UNREACHABLE ;
115
116
}
116
117
else if (resolved_type.id () == ID_vector || resolved_type.id () == ID_complex)
117
118
{
@@ -124,8 +125,10 @@ bvt boolbvt::convert_floatbv_op(const exprt &expr)
124
125
std::size_t width = boolbv_width (resolved_type);
125
126
std::size_t sub_width=boolbv_width (subtype);
126
127
127
- if (sub_width==0 || width%sub_width!=0 )
128
- throw " convert_floatbv_op: unexpected vector operand width" ;
128
+ DATA_INVARIANT (
129
+ sub_width > 0 && width % sub_width == 0 ,
130
+ " width of a vector subtype must be positive and evenly divide the "
131
+ " width of the vector" );
129
132
130
133
std::size_t size=width/sub_width;
131
134
bvt result_bv;
@@ -151,10 +154,14 @@ bvt boolbvt::convert_floatbv_op(const exprt &expr)
151
154
else if (expr.id ()==ID_floatbv_div)
152
155
sub_result_bv = float_utils.div (lhs_sub_bv, rhs_sub_bv);
153
156
else
154
- assert (false );
155
-
156
- assert (sub_result_bv.size () == sub_width);
157
- assert (i * sub_width + sub_width - 1 < result_bv.size ());
157
+ UNREACHABLE;
158
+
159
+ INVARIANT (
160
+ sub_result_bv.size () == sub_width,
161
+ " we constructed a new vector of the right size" );
162
+ INVARIANT (
163
+ i * sub_width + sub_width - 1 < result_bv.size (),
164
+ " the sub-bitvector fits into the result bitvector" );
158
165
std::copy (
159
166
sub_result_bv.begin (),
160
167
sub_result_bv.end (),
0 commit comments