-
Notifications
You must be signed in to change notification settings - Fork 274
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
Clean member of #3901
Conversation
/// base class. | ||
/// \param pointer: The expression to access the field on. | ||
/// \param fieldref: A getfield/setfield instruction produced by the bytecode | ||
/// parser. |
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.
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) |
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.
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
).
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.
@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); |
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.
Is there a get_component_name
that could be used instead?
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.
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.
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.
either way is fine for me
7e95e1c
to
63b1946
Compare
/// 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) |
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.
@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
)?)
63b1946
to
de4b250
Compare
CI failure was due to me being over-eager with a dangling reference. Remaining issues addressed |
6eb4da3
to
56818d6
Compare
/// 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 |
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.
cpplint (rightfully) complains about an overly long line here.
ea42084
to
6396ca2
Compare
Gah I wish clang-format would reformat comments... Linting addressed) |
6396ca2
to
b863377
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: 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.
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: 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.
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.
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.
@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) |
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):
|
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.
But also, let's not spend any more time thinking about this
@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.