Skip to content

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

Merged
merged 3 commits into from
Feb 13, 2019
Merged

Conversation

kroening
Copy link
Member

@kroening 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.

Copy link
Contributor

@allredj allredj left a 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

Copy link
Contributor

@allredj allredj left a 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);
Copy link
Collaborator

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())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change in wrong commit

Copy link
Member Author

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);
Copy link
Collaborator

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);
Copy link
Collaborator

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add set_condition?

remove_complex(it->guard);

if(it->has_condition())
remove_complex(it->guard);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add set_condition?

remove_vector(it->guard);

if(it->has_condition())
remove_vector(it->guard);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add set_condition?

rewrite_union(it->guard);

if(it->has_condition())
rewrite_union(it->guard);
Copy link
Collaborator

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add set_condition?

Copy link
Contributor

@smowton smowton left a 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

@kroening
Copy link
Member Author

@smowton @tautschnig I couldn't decide between non-const get_condition() or a set_condition(...). It probably makes sense to do the non-const one, in like with the other get_() methods.

@kroening kroening force-pushed the instructiont-guard branch 2 times, most recently from 03d1517 to 17ceafd Compare February 11, 2019 22:00
Copy link
Contributor

@allredj allredj left a 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.

Copy link
Contributor

@allredj allredj left a 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

@@ -287,6 +287,13 @@ class goto_programt
return guard;
}

/// Get the condition of gotos, assume, assert
exprt &get_condition()
Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll action this.

Copy link
Member Author

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.

@kroening kroening removed their assignment Feb 12, 2019
@kroening kroening force-pushed the instructiont-guard branch 2 times, most recently from c500aea to 09371f1 Compare February 12, 2019 09:27
Copy link
Contributor

@allredj allredj left a 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.

Copy link
Contributor

@allredj allredj left a 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

Daniel Kroening added 3 commits February 13, 2019 08:06
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.
Copy link
Contributor

@allredj allredj left a 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

@tautschnig tautschnig merged commit 606a83a into develop Feb 13, 2019
@tautschnig tautschnig deleted the instructiont-guard branch February 13, 2019 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants