-
Notifications
You must be signed in to change notification settings - Fork 277
fix accesses to exprt::opX() in solvers/ #5025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 56cf656).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/123385109
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking for one breaking change, otherwise suggested optional improvements
src/solvers/flattening/arrays.cpp
Outdated
DATA_INVARIANT( | ||
a.operands().size()==1, | ||
"typecast must have one operand"); | ||
const auto &typecast_op = to_typecast_expr(a); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect typecast_op
to be to_typecast_expr(a).op()
. Just typecast_expr
?
a.op0().type().id()==ID_array, | ||
("unexpected array type cast from "+ | ||
a.op0().type().id_string()).c_str()); | ||
typecast_op.type().id() == ID_array, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you really did want typecast(...).op()
above, this is a change of behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed -- fixed
src/solvers/smt2/smt2_conv.cpp
Outdated
expr.op0().type().id()==ID_floatbv))) | ||
else if( | ||
!use_FPA_theory && expr.operands().size() >= 1 && | ||
(expr.id() == ID_floatbv_plus || expr.id() == ID_floatbv_minus || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest clang-format-off, the old style was much easier to read
arg.op0().op0().operands().size() == 2 && | ||
arg.op0().op0().op0().id() == ID_string_constant) | ||
arg.operands().size() == 1 && | ||
to_unary_expr(arg).op().operands().size() == 1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea what this is expecting? The chain of op0
s without checking what unary operation it's looking at seems suspicious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's an equality whose lhs is an address_of string_constant -- @romainbrenguier ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could have been an address_of
although I can't be sure now. This is most likely dead code, as this is for C programs, for which the solver is not tested currently, and wouldn't work without some clean-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0b62e99).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/123438774
Codecov Report
@@ Coverage Diff @@
## develop #5025 +/- ##
===========================================
+ Coverage 67.33% 67.33% +<.01%
===========================================
Files 1155 1155
Lines 94669 94684 +15
===========================================
+ Hits 63744 63755 +11
- Misses 30925 30929 +4
Continue to review full report at Codecov.
|
#else | ||
literalt literal=bv_utils.rel(bv0, expr.id(), bv1, rep); | ||
#else | ||
literalt literal = bv_utils.rel(bv0, expr.id(), bv1, rep); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this part of the code should be removed instead of reformatted
arg.op0().op0().operands().size() == 2 && | ||
arg.op0().op0().op0().id() == ID_string_constant) | ||
arg.operands().size() == 1 && | ||
to_unary_expr(arg).op().operands().size() == 1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could have been an address_of
although I can't be sure now. This is most likely dead code, as this is for C programs, for which the solver is not tested currently, and wouldn't work without some clean-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a number of locations where lhs()
and rhs()
can be used to make the code clearer and to remove the number of calls to op0()
and op1()
making them easier to locate and eliminate.
DATA_INVARIANT( | ||
a.operands().size()==1, | ||
"typecast must have one operand"); | ||
const auto &typecast_op = to_typecast_expr(a).op(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a definite improvement.
@@ -201,7 +201,7 @@ bvt boolbvt::convert_bitvector(const exprt &expr) | |||
if(expr.operands().size()!=1) | |||
return conversion_failed(expr); | |||
|
|||
std::size_t op_width=boolbv_width(expr.op0().type()); | |||
std::size_t op_width = boolbv_width(to_unary_expr(expr).op().type()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that width is a unary_exprt...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there's anything wrong here?
@@ -41,7 +41,7 @@ bvt boolbvt::convert_add_sub(const exprt &expr) | |||
!operands.empty(), | |||
"operator " + expr.id_string() + " takes at least one operand"); | |||
|
|||
const exprt &op0=expr.op0(); | |||
const exprt &op0 = to_multi_ary_expr(expr).op0(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still has an op0
but probably unavoidable.
|
||
if(operands.size()!=3) | ||
throw "operator "+expr.id_string()+" takes three operands"; | ||
|
||
const exprt &lhs = expr.op0(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For completeness and to make it easier to find remaining uses, these could be lhs()
, rhs()
and rounding_mode()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/solvers/floatbv/float_bv.cpp
Outdated
{ | ||
const auto &float_expr = to_ieee_float_op_expr(expr); | ||
return div( | ||
float_expr.op0(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
src/solvers/prop/bdd_expr.cpp
Outdated
bddt op0 = from_expr_rec(bin_expr.op0()); | ||
bddt op1 = from_expr_rec(bin_expr.op1()); | ||
bddt op0 = from_expr_rec(to_binary_expr(bin_expr).op0()); | ||
bddt op1 = from_expr_rec(to_binary_expr(bin_expr).op1()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lhs()
and rhs()
return; | ||
} | ||
const auto &implies_expr = to_implies_expr(expr); | ||
literalt l0 = convert(implies_expr.op0()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lhs()
and rhs()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above -- will do a PR for a binary_infix_exprt
.
This is follow up from #5025. A clear desire is visible to use .lhs() and .rhs() on binary expressions, say minus_exprt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0d4e7b7).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/124103489
0d4e7b7
to
47099cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 47099cd).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/128738923
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 7342799).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/131366463
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: c29fcd8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/131640304
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0a3c6a5).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/132766120
@@ -201,7 +201,7 @@ bvt boolbvt::convert_bitvector(const exprt &expr) | |||
if(expr.operands().size()!=1) | |||
return conversion_failed(expr); | |||
|
|||
std::size_t op_width=boolbv_width(expr.op0().type()); | |||
std::size_t op_width = boolbv_width(to_unary_expr(expr).op().type()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there's anything wrong here?
DATA_INVARIANT(expr.operands().size() == 1, "isnan expects one operand"); | ||
const bvt &bv=convert_bv(operands[0]); | ||
const auto &op = to_unary_expr(expr).op(); | ||
const bvt &bv = convert_bv(op); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the original code had operands
declared somewhere. In the code review it's hard to see where that is, but can you please make sure its declaration is removed as it shouldn't be of any use anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, removed
bv_utilst::representationt rep= | ||
expr.op0().type().id()==ID_signedbv?bv_utilst::representationt::SIGNED: | ||
bv_utilst::representationt::UNSIGNED; | ||
bv_utilst::representationt rep = operands[0].type().id() == ID_signedbv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the use of operands[0]
is an improvement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced by binary_exprt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 8a6f9aa).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/135115290
This improves type safety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: dbf0058).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/135506038
This improves type safety.