Skip to content

Commit

Permalink
Set little_endian in the same way that boolbv_byte_extract already does
Browse files Browse the repository at this point in the history
Ensure that a valid id is set via PRECONDITION checks.
  • Loading branch information
tautschnig committed Jul 8, 2018
1 parent d393d1c commit 34404f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/solvers/flattening/boolbv_byte_extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)

const exprt &op=expr.op();
const exprt &offset=expr.offset();
PRECONDITION(
expr.id() == ID_byte_extract_little_endian ||
expr.id() == ID_byte_extract_big_endian);
const bool little_endian = expr.id() == ID_byte_extract_little_endian;

// first do op0
Expand Down
12 changes: 4 additions & 8 deletions src/solvers/flattening/boolbv_byte_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ bvt boolbvt::convert_byte_update(const byte_update_exprt &expr)
const exprt &offset_expr=expr.offset();
const exprt &value=expr.value();

bool little_endian;

if(expr.id()==ID_byte_update_little_endian)
little_endian=true;
else if(expr.id()==ID_byte_update_big_endian)
little_endian=false;
else
UNREACHABLE;
PRECONDITION(
expr.id() == ID_byte_update_little_endian ||
expr.id() == ID_byte_update_big_endian);
const bool little_endian = expr.id() == ID_byte_update_little_endian;

bvt bv=convert_bv(op);

Expand Down
12 changes: 4 additions & 8 deletions src/solvers/flattening/flatten_byte_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,10 @@ exprt flatten_byte_extract(

assert(src.operands().size()==2);

bool little_endian;

if(src.id()==ID_byte_extract_little_endian)
little_endian=true;
else if(src.id()==ID_byte_extract_big_endian)
little_endian=false;
else
UNREACHABLE;
PRECONDITION(
src.id() == ID_byte_extract_little_endian ||
src.id() == ID_byte_extract_big_endian);
const bool little_endian = src.id() == ID_byte_extract_little_endian;

// determine an upper bound of the number of bytes we might need
exprt upper_bound=size_of_expr(src.type(), ns);
Expand Down

0 comments on commit 34404f0

Please sign in to comment.