@@ -60,10 +60,10 @@ void goto_convertt::remove_assignment(
60
60
statement==ID_assign_bitxor ||
61
61
statement==ID_assign_bitor)
62
62
{
63
- INVARIANT (
63
+ INVARIANT_WITH_DIAGNOSTICS (
64
64
expr.operands ().size () == 2 ,
65
- expr. find_source_location (). as_string () + " : " + id2string (statement) +
66
- " takes two arguments " );
65
+ id2string (statement) + " expects two arguments " ,
66
+ expr. find_source_location () );
67
67
68
68
irep_idt new_id;
69
69
@@ -138,16 +138,16 @@ void goto_convertt::remove_pre(
138
138
bool result_is_used,
139
139
const irep_idt &mode)
140
140
{
141
- DATA_INVARIANT (
141
+ INVARIANT_WITH_DIAGNOSTICS (
142
142
expr.operands ().size () == 1 ,
143
- expr. find_source_location (). as_string () +
144
- " : preincrement/predecrement must have one operand " );
143
+ " preincrement/predecrement must have one operand " ,
144
+ expr. find_source_location () );
145
145
146
146
const irep_idt statement=expr.get_statement ();
147
147
148
148
DATA_INVARIANT (
149
149
statement == ID_preincrement || statement == ID_predecrement,
150
- " expected preincrement or predecrement" );
150
+ " expects preincrement or predecrement" );
151
151
152
152
exprt rhs;
153
153
rhs.add_source_location ()=expr.source_location ();
@@ -227,16 +227,16 @@ void goto_convertt::remove_post(
227
227
228
228
// we have ...(op++)...
229
229
230
- DATA_INVARIANT (
230
+ INVARIANT_WITH_DIAGNOSTICS (
231
231
expr.operands ().size () == 1 ,
232
- expr. find_source_location (). as_string () +
233
- " : postincrement/postdecrement must have one operand " );
232
+ " postincrement/postdecrement must have one operand " ,
233
+ expr. find_source_location () );
234
234
235
235
const irep_idt statement=expr.get_statement ();
236
236
237
237
DATA_INVARIANT (
238
238
statement == ID_postincrement || statement == ID_postdecrement,
239
- " expected postincrement or postdecrement" );
239
+ " expects postincrement or postdecrement" );
240
240
241
241
exprt rhs;
242
242
rhs.add_source_location ()=expr.source_location ();
@@ -326,12 +326,13 @@ void goto_convertt::remove_function_call(
326
326
const irep_idt &mode,
327
327
bool result_is_used)
328
328
{
329
+ INVARIANT_WITH_DIAGNOSTICS (
330
+ expr.operands ().size () == 2 ,
331
+ " function_call expects two operands" ,
332
+ expr.find_source_location ());
333
+
329
334
if (!result_is_used)
330
335
{
331
- DATA_INVARIANT (
332
- expr.operands ().size () == 2 ,
333
- expr.find_source_location ().as_string () +
334
- " : function_call expects two operands" );
335
336
code_function_callt call (nil_exprt (), expr.op0 (), expr.op1 ().operands ());
336
337
call.add_source_location ()=expr.source_location ();
337
338
convert_function_call (call, dest, mode);
@@ -341,14 +342,10 @@ void goto_convertt::remove_function_call(
341
342
342
343
// get name of function, if available
343
344
344
- DATA_INVARIANT (
345
+ INVARIANT_WITH_DIAGNOSTICS (
345
346
expr.id () == ID_side_effect && expr.get (ID_statement) == ID_function_call,
346
- expr.find_source_location ().as_string () + " : expected function call" );
347
-
348
- DATA_INVARIANT (
349
- !expr.operands ().empty (),
350
- expr.find_source_location ().as_string () +
351
- " : function_call expects at least one operand" );
347
+ " expects function call" ,
348
+ expr.find_source_location ());
352
349
353
350
std::string new_base_name = " return_value" ;
354
351
irep_idt new_symbol_mode = mode;
@@ -430,7 +427,7 @@ void goto_convertt::remove_cpp_delete(
430
427
side_effect_exprt &expr,
431
428
goto_programt &dest)
432
429
{
433
- DATA_INVARIANT (expr.operands ().size () == 1 , " cpp_delete expected 1 operand" );
430
+ DATA_INVARIANT (expr.operands ().size () == 1 , " cpp_delete expects one operand" );
434
431
435
432
codet tmp (expr.get_statement ());
436
433
tmp.add_source_location ()=expr.source_location ();
@@ -483,10 +480,10 @@ void goto_convertt::remove_temporary_object(
483
480
goto_programt &dest)
484
481
{
485
482
const irep_idt &mode = expr.get (ID_mode);
486
- DATA_INVARIANT (
483
+ INVARIANT_WITH_DIAGNOSTICS (
487
484
expr.operands ().size () <= 1 ,
488
- expr. find_source_location (). as_string () +
489
- " : temporary_object takes 0 or 1 operands " );
485
+ " temporary_object takes zero or one operands " ,
486
+ expr. find_source_location () );
490
487
491
488
symbolt &new_symbol = new_tmp_symbol (
492
489
expr.type (), " obj" , dest, expr.find_source_location (), mode);
@@ -500,10 +497,10 @@ void goto_convertt::remove_temporary_object(
500
497
501
498
if (expr.find (ID_initializer).is_not_nil ())
502
499
{
503
- INVARIANT (
500
+ INVARIANT_WITH_DIAGNOSTICS (
504
501
expr.operands ().empty (),
505
- expr. find_source_location (). as_string () +
506
- " : temporary_object takes 0 operands " );
502
+ " temporary_object takes zero operands " ,
503
+ expr. find_source_location () );
507
504
exprt initializer=static_cast <const exprt &>(expr.find (ID_initializer));
508
505
replace_new_object (new_symbol.symbol_expr (), initializer);
509
506
@@ -524,15 +521,15 @@ void goto_convertt::remove_statement_expression(
524
521
// The expression is copied into a temporary before the
525
522
// scope is destroyed.
526
523
527
- DATA_INVARIANT (
524
+ INVARIANT_WITH_DIAGNOSTICS (
528
525
expr.operands ().size () == 1 ,
529
- expr. find_source_location (). as_string () +
530
- " : statement_expression takes 1 operand " );
526
+ " statement_expression takes one operand " ,
527
+ expr. find_source_location () );
531
528
532
- DATA_INVARIANT (
529
+ INVARIANT_WITH_DIAGNOSTICS (
533
530
expr.op0 ().id () == ID_code,
534
- expr. find_source_location (). as_string () +
535
- " : statement_expression takes code as operand " );
531
+ " statement_expression takes code as operand " ,
532
+ expr. find_source_location () );
536
533
537
534
codet &code=to_code (expr.op0 ());
538
535
@@ -543,15 +540,15 @@ void goto_convertt::remove_statement_expression(
543
540
return ;
544
541
}
545
542
546
- DATA_INVARIANT (
543
+ INVARIANT_WITH_DIAGNOSTICS (
547
544
code.get_statement () == ID_block,
548
- code. find_source_location (). as_string () +
549
- " : statement_expression takes block as operand " );
545
+ " statement_expression takes block as operand " ,
546
+ code. find_source_location () );
550
547
551
- DATA_INVARIANT (
548
+ INVARIANT_WITH_DIAGNOSTICS (
552
549
!code.operands ().empty (),
553
- expr. find_source_location (). as_string () +
554
- " : statement_expression takes non-empty block as operand " );
550
+ " statement_expression takes non-empty block as operand " ,
551
+ expr. find_source_location () );
555
552
556
553
// get last statement from block, following labels
557
554
codet &last=to_code_block (code).find_last_statement ();
0 commit comments