-
Notifications
You must be signed in to change notification settings - Fork 273
avoid accesses to instructiont::guard #4144
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
kroening
commented
Feb 9, 2019
- Each commit message has a non-empty body, explaining why the change was made.
- Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
- n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
- Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
- n/a My commit message includes data points confirming performance improvements (if claimed).
- My PR is restricted to a single feature or bugfix.
- n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.
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: 5779e2a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100335530
5779e2a
to
f8538c2
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: f8538c2).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100338270
adjust_float_expressions(it->guard, ns); | ||
|
||
if(it->has_condition()) | ||
adjust_float_expressions(it->guard, ns); |
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.
Add set_condition
?
last_instruction->guard.is_true()) | ||
if( | ||
last_instruction->is_goto() && | ||
last_instruction->get_condition().is_true()) |
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.
Change in wrong commit
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.
fixed
replace_location(it->code, target->source_location); | ||
|
||
if(it->has_condition()) | ||
replace_location(it->guard, target->source_location); |
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.
Add set_condition
?
rename_symbol(iit->guard); | ||
|
||
if(iit->has_condition()) | ||
rename_symbol(iit->guard); |
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.
Add set_condition
?
object_type_updates(iit->guard); | ||
|
||
if(iit->has_condition()) | ||
object_type_updates(iit->guard); |
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.
Add set_condition
?
src/goto-programs/remove_complex.cpp
Outdated
remove_complex(it->guard); | ||
|
||
if(it->has_condition()) | ||
remove_complex(it->guard); |
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.
Add set_condition
?
src/goto-programs/remove_vector.cpp
Outdated
remove_vector(it->guard); | ||
|
||
if(it->has_condition()) | ||
remove_vector(it->guard); |
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.
Add set_condition
?
src/goto-programs/rewrite_union.cpp
Outdated
rewrite_union(it->guard); | ||
|
||
if(it->has_condition()) | ||
rewrite_union(it->guard); |
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.
Add set_condition
?
@@ -301,7 +301,8 @@ void goto_program_dereferencet::dereference_instruction( | |||
#endif | |||
goto_programt::instructiont &i=*target; | |||
|
|||
dereference_expr(i.guard, checks_only, value_set_dereferencet::modet::READ); | |||
if(i.has_condition()) | |||
dereference_expr(i.guard, checks_only, value_set_dereferencet::modet::READ); |
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.
Add set_condition
?
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 good except as per @tautschnig you should probably add some non-const accessor for the guard
@smowton @tautschnig I couldn't decide between non-const |
03d1517
to
17ceafd
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.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: f34ad06).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100527912
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
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: 17ceafd).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100530206
src/goto-programs/goto_program.h
Outdated
@@ -287,6 +287,13 @@ class goto_programt | |||
return guard; | |||
} | |||
|
|||
/// Get the condition of gotos, assume, assert | |||
exprt &get_condition() |
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 believe we do have a lot of places where we have a const and a non-const variant with the same name, but I also think that in those cases we neither have a get_
nor a set_
prefix? What I would have used is void set_condition(exprt cond) { PRECONDITION(has_condition()); guard = std::move(cond); }
, which of course requires a somewhat bigger change in that all users need to do exprt modified_condition = get_condition(); do_something(modified_condition); set_condition(std::move(modified_condition));
But certainly nothing that I intend to block on, my approval remains in place.
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; I couldn't decide. To write to stuff thats returned by get_X
seems to be very common in Java, but much less common in C++.
The key reason why I went for non-const get is that we have a lot of instances where we apply a transform to the guard. That would then become
exprt tmp = instr.get_condition(); TRANSFORM(tmp); instr.set_condition(tmp);
That could possibly be changed into
instr.set_condition(TRANSFORM(instr.get_condition());
if we turn all those TRANSFORM into functional style.
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'll action this.
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.
Another option would be to offer instructiont::transform()
, which would take a lambda that modifies the expressions.
17ceafd
to
bfb5287
Compare
c500aea
to
09371f1
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.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: bfb5287).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100579413
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
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: 09371f1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100582757
This will eventually enable use to protect instructiont::guard.
This will eventually enable use to protect instructiont::guard.
This will eventually allow us to protect the guard data member.
09371f1
to
d1c2749
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: d1c2749).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100736589