11
11
#include < util/c_types.h>
12
12
#include < util/config.h>
13
13
#include < util/arith_tools.h>
14
+ #include < util/invariant.h>
14
15
#include < util/prefix.h>
15
16
#include < util/std_expr.h>
16
17
#include < util/pointer_offset_size.h>
@@ -135,26 +136,26 @@ bool bv_pointerst::convert_address_of_rec(
135
136
{
136
137
// this should be gone
137
138
bv=convert_pointer_type (array);
138
- assert (bv.size ()==bits);
139
+ POSTCONDITION (bv.size ()==bits);
139
140
}
140
141
else if (array_type.id ()==ID_array ||
141
142
array_type.id ()==ID_incomplete_array ||
142
143
array_type.id ()==ID_string_constant)
143
144
{
144
145
if (convert_address_of_rec (array, bv))
145
146
return true ;
146
- assert (bv.size ()==bits);
147
+ POSTCONDITION (bv.size ()==bits);
147
148
}
148
149
else
149
- assert ( false ) ;
150
+ UNREACHABLE ;
150
151
151
152
// get size
152
153
mp_integer size=
153
154
pointer_offset_size (array_type.subtype (), ns);
154
- assert (size>0 );
155
+ DATA_INVARIANT (size>0 , " array subtype expected to have non-zero size " );
155
156
156
157
offset_arithmetic (bv, size, index );
157
- assert (bv.size ()==bits);
158
+ POSTCONDITION (bv.size ()==bits);
158
159
return false ;
159
160
}
160
161
else if (expr.id ()==ID_member)
@@ -172,7 +173,7 @@ bool bv_pointerst::convert_address_of_rec(
172
173
mp_integer offset=member_offset (
173
174
to_struct_type (struct_op_type),
174
175
member_expr.get_component_name (), ns);
175
- assert (offset>=0 );
176
+ DATA_INVARIANT (offset>=0 , " member offset expected to be positive " );
176
177
177
178
// add offset
178
179
offset_arithmetic (bv, offset);
@@ -295,7 +296,7 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr)
295
296
return bv;
296
297
}
297
298
298
- assert (bv.size ()==bits);
299
+ POSTCONDITION (bv.size ()==bits);
299
300
return bv;
300
301
}
301
302
else if (expr.id ()==ID_constant)
@@ -333,13 +334,13 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr)
333
334
{
334
335
count++;
335
336
bv=convert_bv (*it);
336
- assert (bv.size ()==bits);
337
+ POSTCONDITION (bv.size ()==bits);
337
338
338
339
typet pointer_sub_type=it->type ().subtype ();
339
340
if (pointer_sub_type.id ()==ID_empty)
340
341
pointer_sub_type=char_type ();
341
342
size=pointer_offset_size (pointer_sub_type, ns);
342
- assert (size>0 );
343
+ POSTCONDITION (size>0 );
343
344
}
344
345
}
345
346
@@ -413,7 +414,7 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr)
413
414
414
415
mp_integer element_size=
415
416
pointer_offset_size (expr.op0 ().type ().subtype (), ns);
416
- assert (element_size>0 );
417
+ DATA_INVARIANT (element_size>0 , " object size expected to be non-zero " );
417
418
418
419
offset_arithmetic (bv, element_size, neg_op1);
419
420
@@ -470,7 +471,7 @@ bvt bv_pointerst::convert_bitvector(const exprt &expr)
470
471
471
472
mp_integer element_size=
472
473
pointer_offset_size (expr.op0 ().type ().subtype (), ns);
473
- assert (element_size>0 );
474
+ DATA_INVARIANT (element_size>0 , " object size expected to be non-zero " );
474
475
475
476
if (element_size!=1 )
476
477
{
@@ -570,7 +571,7 @@ exprt bv_pointerst::bv_get_rec(
570
571
571
572
for (std::size_t i=0 ; i<bits; i++)
572
573
{
573
- char ch;
574
+ char ch= 0 ;
574
575
std::size_t bit_nr=i+offset;
575
576
576
577
if (unknown[bit_nr])
@@ -720,8 +721,8 @@ void bv_pointerst::do_postponed(
720
721
bvt saved_bv=postponed.op ;
721
722
saved_bv.erase (saved_bv.begin (), saved_bv.begin ()+offset_bits);
722
723
723
- assert (bv.size ()==saved_bv.size ());
724
- assert (postponed.bv .size ()==1 );
724
+ POSTCONDITION (bv.size ()==saved_bv.size ());
725
+ PRECONDITION (postponed.bv .size ()==1 );
725
726
726
727
literalt l1=bv_utils.equal (bv, saved_bv);
727
728
literalt l2=postponed.bv .front ();
@@ -773,8 +774,8 @@ void bv_pointerst::do_postponed(
773
774
bvt saved_bv=postponed.op ;
774
775
saved_bv.erase (saved_bv.begin (), saved_bv.begin ()+offset_bits);
775
776
776
- assert (bv.size ()==saved_bv.size ());
777
- assert (postponed.bv .size ()>=1 );
777
+ POSTCONDITION (bv.size ()==saved_bv.size ());
778
+ PRECONDITION (postponed.bv .size ()>=1 );
778
779
779
780
literalt l1=bv_utils.equal (bv, saved_bv);
780
781
@@ -785,7 +786,7 @@ void bv_pointerst::do_postponed(
785
786
}
786
787
}
787
788
else
788
- assert ( false ) ;
789
+ UNREACHABLE ;
789
790
}
790
791
791
792
void bv_pointerst::post_process ()
0 commit comments