Skip to content

Commit ce2a97a

Browse files
Remove use of deprecated non-const accessors
The non-const version shouldn't be used anymore when we don't actually need to modify the operands.
1 parent c5bed88 commit ce2a97a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/util/simplify_expr.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,7 +1902,7 @@ bool simplify_exprt::simplify_byte_extract(byte_extract_exprt &expr)
19021902
expr.op().id() == ID_byte_update_big_endian) ||
19031903
(expr.id() == ID_byte_extract_little_endian &&
19041904
expr.op().id() == ID_byte_update_little_endian)) &&
1905-
expr.offset() == to_byte_update_expr(expr.op()).offset())
1905+
expr.offset() == to_byte_update_expr(as_const(expr).op()).offset())
19061906
{
19071907
const auto &op_byte_update = to_byte_update_expr(expr.op());
19081908

@@ -2057,20 +2057,22 @@ bool simplify_exprt::simplify_byte_extract(byte_extract_exprt &expr)
20572057

20582058
bool simplify_exprt::simplify_byte_update(byte_update_exprt &expr)
20592059
{
2060+
const byte_update_exprt &expr_const = as_const(expr);
20602061
// byte_update(byte_update(root, offset, value), offset, value2) =>
20612062
// byte_update(root, offset, value2)
20622063
if(
2063-
expr.id() == expr.op().id() &&
2064-
expr.offset() == to_byte_update_expr(expr.op()).offset() &&
2065-
expr.value().type() == to_byte_update_expr(expr.op()).value().type())
2064+
expr_const.id() == expr_const.op().id() &&
2065+
expr_const.offset() == to_byte_update_expr(expr_const.op()).offset() &&
2066+
expr_const.value().type() ==
2067+
to_byte_update_expr(expr_const.op()).value().type())
20662068
{
2067-
expr.set_op()=expr.op().op0();
2069+
expr.set_op() = expr_const.op().op0();
20682070
return false;
20692071
}
20702072

2071-
const exprt &root=expr.op();
2072-
const exprt &offset=expr.offset();
2073-
const exprt &value=expr.value();
2073+
const exprt &root = expr_const.op();
2074+
const exprt &offset = expr_const.offset();
2075+
const exprt &value = expr_const.value();
20742076
const auto val_size = pointer_offset_bits(value.type(), ns);
20752077
const auto root_size = pointer_offset_bits(root.type(), ns);
20762078

@@ -2235,7 +2237,7 @@ bool simplify_exprt::simplify_byte_update(byte_update_exprt &expr)
22352237
}
22362238

22372239
if(result_expr.is_nil())
2238-
result_expr=expr.op();
2240+
result_expr = as_const(expr).op();
22392241

22402242
exprt member_name(ID_member_name);
22412243
member_name.set(ID_component_name, component.get_name());

0 commit comments

Comments
 (0)