-
Notifications
You must be signed in to change notification settings - Fork 277
Verify member expressions [blocks: #4023] #4021
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
Verify member expressions [blocks: #4023] #4021
Conversation
1b24efd
to
35b677b
Compare
35b677b
to
cb4b80e
Compare
src/util/std_expr.h
Outdated
@@ -3933,7 +3948,6 @@ inline void validate_expr(const member_exprt &value) | |||
validate_operands(value, 1, "Extract member must have one operand"); | |||
} | |||
|
|||
|
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: unrelated change?
Please no |
cb4b80e
to
5dd83b1
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: 5dd83b1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99665060
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.
5dd83b1
to
db9e4f3
Compare
No can do, lots of stuff fails if we have both So which do you prefer:
Advantage of 1: clean |
Aha, this can be done once limited-type-renaming is in -- by coincidence, in Java types that require renaming (only VLA data allocations) are mutually exclusive with those that use decorated tags, and therefore lose information on type following. Therefore this now works if we first get #3966 and #4126. Given this narrow tightrope re: type renaming vs. decorated tags, I'll also make a PR to assert that renaming doesn't discard information. |
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: 7fb60d7).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100218684
I expected this would be good now, but it isn't because there are cases where users of |
void member_exprt::validate( | ||
const exprt &expr, | ||
const namespacet &ns, | ||
const validation_modet vm) |
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.
Avoid abbreviations
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.
Every other validate
method is doing the same thing, so I'll leave this as-is for now (change them en masse if we want to)
{ | ||
check(expr, vm); | ||
|
||
const auto &member_expr = to_member_expr(expr); |
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.
❓ why not take a member_exprt
as argument instead, and let the caller call to_member_expr
if needed?
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.
Appears to be normal for validate
methods, again change en masse or not at all
src/util/std_expr.cpp
Outdated
can_cast_type<struct_union_typet>(compound_type), | ||
"member must address a struct, union or compatible type"); | ||
|
||
const auto &component = to_struct_union_type(compound_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.
❓ can't we use a try_cast_dynamic_type
instead of can_cast_type
+ to_struct_union_type
?
@@ -3897,6 +3897,21 @@ class member_exprt:public unary_exprt | |||
{ | |||
return op0(); | |||
} | |||
|
|||
static void check( |
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.
The two functions you introduce should be documented
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 Still to be done?
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 really any value in documenting one-liner that says "assert(ops.count == 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.
I'm not so sure, I was just confused by you giving a thumbs-up but then seemingly no such change was included.
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 documented validate
, which is much more substantial
@smowton This needs a rebase and addressing @romainbrenguier's comments, then it's ready to go in. |
7fb60d7
to
cfc1c60
Compare
This checks that the component they refer to really exists, and the expression and component's types match (are base_type_eq).
cfc1c60
to
44756ee
Compare
@tautschnig done; @romainbrenguier addressed comments; have also tested current test-gen against develop+this PR and found tests passing. |
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: 44756ee).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/103522773
Status will be re-evaluated on next push.
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 compatibility was already broken by an earlier merge.
…ype-consistency Test for member type consistency [depends-on: #4021]
Depends on #3966
This checks that the component they refer to really exists, and the expression and component's types match.