Skip to content

Commit 478cc5c

Browse files
committed
Byte operators: improve comments and variable names to better reflect logic
1 parent cee3d49 commit 478cc5c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/solvers/lowering/byte_operators.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ exprt lower_byte_extract(const byte_extract_exprt &src, const namespacet &ns)
10721072
src.id() == ID_byte_extract_big_endian);
10731073
const bool little_endian = src.id() == ID_byte_extract_little_endian;
10741074

1075-
// determine an upper bound of the number of bytes we might need
1075+
// determine an upper bound of the last byte we might need
10761076
auto upper_bound_opt = size_of_expr(src.type(), ns);
10771077
if(upper_bound_opt.has_value())
10781078
{
@@ -1106,6 +1106,7 @@ exprt lower_byte_extract(const byte_extract_exprt &src, const namespacet &ns)
11061106
if(element_bits.has_value() && *element_bits >= 1 && *element_bits % 8 == 0)
11071107
{
11081108
auto num_elements = numeric_cast<std::size_t>(array_type.size());
1109+
// XXX: This can't be right -- unpacked is a byte array, whereas array_type may have larger elements
11091110
if(!num_elements.has_value() && unpacked.op().id() == ID_array)
11101111
num_elements = unpacked.op().operands().size();
11111112

@@ -1286,11 +1287,10 @@ exprt lower_byte_extract(const byte_extract_exprt &src, const namespacet &ns)
12861287
size_bits = op0_bits;
12871288
}
12881289

1289-
mp_integer num_elements =
1290-
(*size_bits) / 8 + (((*size_bits) % 8 == 0) ? 0 : 1);
1290+
mp_integer num_bytes = (*size_bits) / 8 + (((*size_bits) % 8 == 0) ? 0 : 1);
12911291

12921292
// get 'width'-many bytes, and concatenate
1293-
const std::size_t width_bytes = numeric_cast_v<std::size_t>(num_elements);
1293+
const std::size_t width_bytes = numeric_cast_v<std::size_t>(num_bytes);
12941294
exprt::operandst op;
12951295
op.reserve(width_bytes);
12961296

0 commit comments

Comments
 (0)