@@ -48,14 +48,10 @@ literalt arrayst::record_array_equality(
48
48
const exprt &op0=equality.op0 ();
49
49
const exprt &op1=equality.op1 ();
50
50
51
- // check types
52
- if (op0.type () != op1.type ())
53
- {
54
- log.error () << equality.pretty () << messaget::eom;
55
- DATA_INVARIANT (
56
- false ,
57
- " record_array_equality got equality without matching types" );
58
- }
51
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
52
+ op0.type () == op1.type (),
53
+ " record_array_equality got equality without matching types" ,
54
+ irep_pretty_diagnosticst{equality});
59
55
60
56
DATA_INVARIANT (
61
57
op0.type ().id () == ID_array,
@@ -116,12 +112,10 @@ void arrayst::collect_arrays(const exprt &a)
116
112
{
117
113
const with_exprt &with_expr=to_with_expr (a);
118
114
119
- // check types
120
- if (array_type != with_expr.old ().type ())
121
- {
122
- log.error () << a.pretty () << messaget::eom;
123
- DATA_INVARIANT (false , " collect_arrays got 'with' without matching types" );
124
- }
115
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
116
+ array_type == with_expr.old ().type (),
117
+ " collect_arrays got 'with' without matching types" ,
118
+ irep_pretty_diagnosticst{a});
125
119
126
120
arrays.make_union (a, with_expr.old ());
127
121
collect_arrays (with_expr.old ());
@@ -137,14 +131,10 @@ void arrayst::collect_arrays(const exprt &a)
137
131
{
138
132
const update_exprt &update_expr=to_update_expr (a);
139
133
140
- // check types
141
- if (array_type != update_expr.old ().type ())
142
- {
143
- log.error () << a.pretty () << messaget::eom;
144
- DATA_INVARIANT (
145
- false ,
146
- " collect_arrays got 'update' without matching types" );
147
- }
134
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
135
+ array_type == update_expr.old ().type (),
136
+ " collect_arrays got 'update' without matching types" ,
137
+ irep_pretty_diagnosticst{a});
148
138
149
139
arrays.make_union (a, update_expr.old ());
150
140
collect_arrays (update_expr.old ());
@@ -159,19 +149,15 @@ void arrayst::collect_arrays(const exprt &a)
159
149
{
160
150
const if_exprt &if_expr=to_if_expr (a);
161
151
162
- // check types
163
- if (array_type != if_expr.true_case ().type ())
164
- {
165
- log.error () << a.pretty () << messaget::eom;
166
- DATA_INVARIANT (false , " collect_arrays got if without matching types" );
167
- }
152
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
153
+ array_type == if_expr.true_case ().type (),
154
+ " collect_arrays got if without matching types" ,
155
+ irep_pretty_diagnosticst{a});
168
156
169
- // check types
170
- if (array_type != if_expr.false_case ().type ())
171
- {
172
- log.error () << a.pretty () << messaget::eom;
173
- DATA_INVARIANT (false , " collect_arrays got if without matching types" );
174
- }
157
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
158
+ array_type == if_expr.false_case ().type (),
159
+ " collect_arrays got if without matching types" ,
160
+ irep_pretty_diagnosticst{a});
175
161
176
162
arrays.make_union (a, if_expr.true_case ());
177
163
arrays.make_union (a, if_expr.false_case ());
@@ -521,13 +507,10 @@ void arrayst::add_array_constraints_with(
521
507
522
508
index_exprt index_expr (expr, index, expr.type ().subtype ());
523
509
524
- if (index_expr.type ()!=value.type ())
525
- {
526
- log.error () << expr.pretty () << messaget::eom;
527
- DATA_INVARIANT (
528
- false ,
529
- " with-expression operand should match array element type" );
530
- }
510
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
511
+ index_expr.type () == value.type (),
512
+ " with-expression operand should match array element type" ,
513
+ irep_pretty_diagnosticst{expr});
531
514
532
515
lazy_constraintt lazy (
533
516
lazy_typet::ARRAY_WITH, equal_exprt (index_expr, value));
@@ -597,13 +580,10 @@ void arrayst::add_array_constraints_update(
597
580
{
598
581
index_exprt index_expr(expr, index, expr.type().subtype());
599
582
600
- if(index_expr.type()!=value.type())
601
- {
602
- prop.message.log.error() << expr.pretty() << messaget::eom;
603
- DATA_INVARIANT(
604
- false,
605
- "update operand should match array element type");
606
- }
583
+ DATA_INVARIANT_WITH_DIAGNOSTICS(
584
+ index_expr.type()==value.type(),
585
+ "update operand should match array element type",
586
+ irep_pretty_diagnosticst{expr});
607
587
608
588
set_to_true(equal_exprt(index_expr, value));
609
589
}
0 commit comments