Skip to content

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

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Feb 1, 2019

Depends on #3966

This checks that the component they refer to really exists, and the expression and component's types match.

@smowton smowton force-pushed the smowton/feature/verify-member-expressions branch from 1b24efd to 35b677b Compare February 1, 2019 16:13
@smowton smowton force-pushed the smowton/feature/verify-member-expressions branch from 35b677b to cb4b80e Compare February 1, 2019 16:41
@@ -3933,7 +3948,6 @@ inline void validate_expr(const member_exprt &value)
validate_operands(value, 1, "Extract member must have one operand");
}


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: unrelated change?

@tautschnig tautschnig changed the title Verify member expressions Verify member expressions [blocks: #4023] Feb 1, 2019
@kroening
Copy link
Member

kroening commented Feb 1, 2019

Please no base_type_eq?

@smowton smowton force-pushed the smowton/feature/verify-member-expressions branch from cb4b80e to 5dd83b1 Compare February 4, 2019 15:41
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: 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.

@smowton smowton force-pushed the smowton/feature/verify-member-expressions branch from 5dd83b1 to db9e4f3 Compare February 7, 2019 17:54
@smowton
Copy link
Contributor Author

smowton commented Feb 7, 2019

No can do, lots of stuff fails if we have both == and --validate-ssa-equation, I think because of type renaming. With base_type_eq everything passes but generics will be ignored, because the follow operation skips them.

So which do you prefer:

  1. Eliminate base_type_eq (find and fix all the follows)
  2. Augment base_type_eq a bit to verify that when both types are tags, their decorations match (i.e. like my pointer-decoration PR)

Advantage of 1: clean
Advantage of 2: can do immediately and get some soundness checking in the meantime.

@smowton
Copy link
Contributor Author

smowton commented Feb 8, 2019

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.

@smowton smowton changed the title Verify member expressions [blocks: #4023] Verify member expressions [blocks: #4023, depends-on: #3966, #4126] Feb 8, 2019
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: 7fb60d7).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100218684

@smowton smowton changed the title Verify member expressions [blocks: #4023, depends-on: #3966, #4126] Verify member expressions [blocks: #4023, depends-on: #3966] Feb 8, 2019
@smowton smowton changed the title Verify member expressions [blocks: #4023, depends-on: #3966] Verify member expressions [blocks: #4023, depends-on: #4056] Feb 12, 2019
@smowton
Copy link
Contributor Author

smowton commented Feb 12, 2019

I expected this would be good now, but it isn't because there are cases where users of base_type_eq conflate qualified and unqualified generic types, especially symex-dereference. Therefore this needs to wait for #4056.

@smowton smowton mentioned this pull request Feb 13, 2019
3 tasks
void member_exprt::validate(
const exprt &expr,
const namespacet &ns,
const validation_modet vm)
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid abbreviations

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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

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)
Copy link
Contributor

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(
Copy link
Contributor

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

Copy link
Collaborator

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?

Copy link
Contributor Author

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)"?

Copy link
Collaborator

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.

Copy link
Contributor Author

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

@tautschnig
Copy link
Collaborator

@smowton This needs a rebase and addressing @romainbrenguier's comments, then it's ready to go in.

@tautschnig tautschnig changed the title Verify member expressions [blocks: #4023, depends-on: #4056] Verify member expressions [blocks: #4023] Mar 7, 2019
@tautschnig tautschnig assigned smowton and unassigned kroening Mar 7, 2019
@smowton smowton force-pushed the smowton/feature/verify-member-expressions branch from 7fb60d7 to cfc1c60 Compare March 7, 2019 10:40
This checks that the component they refer to really exists, and the expression and component's types match (are base_type_eq).
@smowton smowton force-pushed the smowton/feature/verify-member-expressions branch from cfc1c60 to 44756ee Compare March 7, 2019 10:52
@smowton
Copy link
Contributor Author

smowton commented Mar 7, 2019

@tautschnig done; @romainbrenguier addressed comments; have also tested current test-gen against develop+this PR and found tests passing.

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

@tautschnig tautschnig merged commit a57d53c into diffblue:develop Mar 7, 2019
tautschnig added a commit that referenced this pull request Mar 7, 2019
…ype-consistency

Test for member type consistency [depends-on: #4021]
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.

6 participants