@@ -208,13 +208,7 @@ literalt prop_conv_solvert::convert(const exprt &expr)
208
208
209
209
literalt prop_conv_solvert::convert_bool (const exprt &expr)
210
210
{
211
- if (expr.type ().id ()!=ID_bool)
212
- {
213
- std::string msg=" prop_convt::convert_bool got "
214
- " non-boolean expression: " ;
215
- msg+=expr.pretty ();
216
- throw msg;
217
- }
211
+ PRECONDITION (expr.type ().id () == ID_bool);
218
212
219
213
const exprt::operandst &op=expr.operands ();
220
214
@@ -280,8 +274,9 @@ literalt prop_conv_solvert::convert_bool(const exprt &expr)
280
274
else if (expr.id ()==ID_or || expr.id ()==ID_and || expr.id ()==ID_xor ||
281
275
expr.id ()==ID_nor || expr.id ()==ID_nand)
282
276
{
283
- if (op.empty ())
284
- throw " operator `" +expr.id_string ()+" ' takes at least one operand" ;
277
+ INVARIANT (
278
+ !op.empty (),
279
+ " operator `" + expr.id_string () + " ' takes at least one operand" );
285
280
286
281
bvt bv;
287
282
@@ -304,16 +299,12 @@ literalt prop_conv_solvert::convert_bool(const exprt &expr)
304
299
}
305
300
else if (expr.id ()==ID_not)
306
301
{
307
- if (op.size ()!=1 )
308
- throw " not takes one operand" ;
309
-
302
+ INVARIANT (op.size () == 1 , " not takes one operand" );
310
303
return !convert (op.front ());
311
304
}
312
305
else if (expr.id ()==ID_equal || expr.id ()==ID_notequal)
313
306
{
314
- if (op.size ()!=2 )
315
- throw " equality takes two operands" ;
316
-
307
+ INVARIANT (op.size () == 2 , " equality takes two operands" );
317
308
bool equal=(expr.id ()==ID_equal);
318
309
319
310
if (op[0 ].type ().id ()==ID_bool &&
@@ -387,13 +378,7 @@ bool prop_conv_solvert::set_equality_to_true(const equal_exprt &expr)
387
378
388
379
void prop_conv_solvert::set_to (const exprt &expr, bool value)
389
380
{
390
- if (expr.type ().id ()!=ID_bool)
391
- {
392
- std::string msg=" prop_convt::set_to got "
393
- " non-boolean expression: " ;
394
- msg+=expr.pretty ();
395
- throw msg;
396
- }
381
+ PRECONDITION (expr.type ().id () == ID_bool);
397
382
398
383
bool boolean=true ;
399
384
0 commit comments