2222
2323bvt map_bv (const bv_endianness_mapt &map, const bvt &src)
2424{
25- assert (map.number_of_bits ()==src.size ());
26-
25+ PRECONDITION (map.number_of_bits () == src.size ());
2726 bvt result;
2827 result.resize (src.size (), const_literal (false ));
2928
3029 for (std::size_t i=0 ; i<src.size (); i++)
3130 {
32- size_t mapped_index= map.map_bit (i);
33- assert (mapped_index< src.size ());
31+ const size_t mapped_index = map.map_bit (i);
32+ CHECK_RETURN (mapped_index < src.size ());
3433 result[i]=src[mapped_index];
3534 }
3635
@@ -39,15 +38,14 @@ bvt map_bv(const bv_endianness_mapt &map, const bvt &src)
3938
4039bvt boolbvt::convert_byte_extract (const byte_extract_exprt &expr)
4140{
42- if (expr.operands ().size ()!=2 )
43- throw " byte_extract takes two operands" ;
41+ PRECONDITION (expr.operands ().size () == 2 );
4442
4543 // if we extract from an unbounded array, call the flattening code
4644 if (is_unbounded_array (expr.op ().type ()))
4745 {
4846 try
4947 {
50- exprt tmp = flatten_byte_extract (expr, ns);
48+ const exprt tmp = flatten_byte_extract (expr, ns);
5149 return convert_bv (tmp);
5250 }
5351 catch (const flatten_byte_extract_exceptiont &byte_extract_flatten_exception)
@@ -57,7 +55,7 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
5755 }
5856 }
5957
60- std::size_t width= boolbv_width (expr.type ());
58+ const std::size_t width = boolbv_width (expr.type ());
6159
6260 // special treatment for bit-fields and big-endian:
6361 // we need byte granularity
@@ -80,22 +78,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
8078
8179 const exprt &op=expr.op ();
8280 const exprt &offset=expr.offset ();
83-
84- bool little_endian;
85-
86- if (expr.id ()==ID_byte_extract_little_endian)
87- little_endian=true ;
88- else if (expr.id ()==ID_byte_extract_big_endian)
89- little_endian=false ;
90- else
91- {
92- little_endian=false ;
93- assert (false );
94- }
81+ const bool little_endian = expr.id () == ID_byte_extract_little_endian;
9582
9683 // first do op0
97-
98- bv_endianness_mapt op_map (op.type (), little_endian, ns, boolbv_width);
84+ const bv_endianness_mapt op_map (op.type (), little_endian, ns, boolbv_width);
9985 const bvt op_bv=map_bv (op_map, convert_bv (op));
10086
10187 // do result
0 commit comments