Skip to content

Clean member of #3901

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 4 commits into from
Jan 29, 2019
Merged

Clean member of #3901

merged 4 commits into from
Jan 29, 2019

Conversation

thk123
Copy link
Contributor

@thk123 thk123 commented Jan 23, 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/
  • [n/a] 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.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@romainbrenguier @tautschnig I wasn't able to get the resolve_inherited_componentt to work because it relies on the symbols for the base fields existing, but seemingly they do not at this stage. In the mean time, I applied the clean up comments you two requested on the code that I hoped would be fixed by this.

/// base class.
/// \param pointer: The expression to access the field on.
/// \param fieldref: A getfield/setfield instruction produced by the bytecode
/// parser.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: please indent

/// parser.
/// \param ns: Global namespace
/// \return A member expression accessing the field, through base class
/// components if necessary.
static member_exprt
to_member(const exprt &pointer, const exprt &fieldref, const namespacet &ns)
to_member(const exprt &pointer, const exprt &field_instruction, const namespacet &ns)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make the type of field_instruction more precise? Is it a member_designatort?
There seems to be some implicit assumption about the expression (for instance it has an ID_class).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smowton points out here field_instruction is a misleading name since it isn't an instruction - suggests calling it just field_reference, would you be happy with that @romainbrenguier (since you objected to fieldref)?)


const exprt typed_pointer =
typecast_exprt::conditional_cast(pointer, java_reference_type(class_type));

const irep_idt &component_name = fieldref.get(ID_component_name);
const irep_idt &component_name = field_instruction.get(ID_component_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a get_component_name that could be used instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for persisting with this, I see there is a fieldref_exprt. To do it properly would take a little time, would you like to get this PR in first as a partial improvement and then I'll follow up with using fieldref_exprt more comprehensively.

Copy link
Contributor

Choose a reason for hiding this comment

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

either way is fine for me

@thk123 thk123 mentioned this pull request Jan 24, 2019
4 tasks
/// parser.
/// \param ns: Global namespace
/// \return A member expression accessing the field, through base class
/// components if necessary.
static member_exprt
to_member(const exprt &pointer, const exprt &fieldref, const namespacet &ns)
to_member(const exprt &pointer, const exprt &field_instruction, const namespacet &ns)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smowton points out here field_instruction is a misleading name since it isn't an instruction - suggests calling it just field_reference, would you be happy with that @romainbrenguier (since you objected to fieldref)?)

@thk123
Copy link
Contributor Author

thk123 commented Jan 25, 2019

CI failure was due to me being over-eager with a dangling reference. Remaining issues addressed

@thk123 thk123 force-pushed the clean-member-of branch 2 times, most recently from 6eb4da3 to 56818d6 Compare January 25, 2019 12:19
/// Build a member exprt for accessing a specific field that may come from a
/// base class.
/// \param pointer: The expression to access the field on.
/// \param field_reference: A getfield/setfield instruction produced by the bytecode
Copy link
Collaborator

Choose a reason for hiding this comment

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

cpplint (rightfully) complains about an overly long line here.

@thk123
Copy link
Contributor Author

thk123 commented Jan 28, 2019

Gah I wish clang-format would reformat comments... Linting addressed)

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: 6396ca2).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98861766
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.

🚫
This PR failed Diffblue compatibility checks (cbmc commit: b863377).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98863209
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

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

Personally I'd say the old version was better -- keep the docs of course, but leave the loop the way it was; better to use a loop with a single exit point in the middle than to repeat ns.follow three times per loop just to force the break point to be at the top.

@thk123
Copy link
Contributor Author

thk123 commented Jan 29, 2019

@smowton I don't agree, for me the new loop reads more naturally ("while we can't find the component, iterate into the parent"). Do you think there are going to be real performance concerns here or are you happy to be outvoted (@romainbrenguier also prefers this version to the old one)

@smowton
Copy link
Contributor

smowton commented Jan 29, 2019

Performance unlikely to be an issue, it's usually bad to be repeating the same work though since at some point somebody will make some change to 2 of the 3 and miss the 3rd or something like that. Assignment in the condition is the usual way out of this sort of loop-and-a-half pattern in C, though here it's a bit verbose (hence previously being spread over a few lines):

while((const auto &accessed_type = type_of(accessed_object)).get_component(component_name).is_nil())

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.

But also, let's not spend any more time thinking about this

@thk123 thk123 merged commit 764bb42 into diffblue:develop Jan 29, 2019
@thk123 thk123 deleted the clean-member-of branch January 29, 2019 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants