Skip to content

Adds support for struct members in history variables #6277

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 2 commits into from
Aug 7, 2021

Conversation

feliperodri
Copy link
Collaborator

Signed-off-by: Felipe R. Monteiro [email protected]

  • 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.
  • 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).
  • 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.

@feliperodri feliperodri added bugfix aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts labels Aug 6, 2021
@feliperodri feliperodri self-assigned this Aug 6, 2021
Copy link
Contributor

@SaswatPadhi SaswatPadhi left a comment

Choose a reason for hiding this comment

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

Nice! Thanks 😃

The changes look good, but I have a couple of questions regarding the scope

@@ -395,22 +395,20 @@ void code_contractst::replace_old_parameter(
const auto &parameter = to_old_expr(expr).expression();

// TODO: generalize below
if(parameter.id() == ID_dereference)
if(parameter.id() == ID_dereference || parameter.id() == ID_member)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think in the assigns clause code I also saw ID_ptrmember. I thought that a.b has ID_member and a->b has ID_ptrmember, but the regression tests you added seem to work with just ID_member check, so I might be wrong.
But do we need an ID_ptrmember case here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added more tests to cover these cases. ID_member seems enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did a quick search, and it looks like ID_ptrmember indeed corresponds to ->:

{ ID_ptrmember, "->" },

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@SaswatPadhi This is for cpp not ansi-c.

Copy link
Contributor

@SaswatPadhi SaswatPadhi Aug 7, 2021

Choose a reason for hiding this comment

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

@feliperodri Are you sure this doesn't apply to ANSI-C as well? From the ANSI-C parser:

cbmc/src/ansi-c/parser.y

Lines 565 to 569 in 5592d7e

| postfix_expression TOK_ARROW member_name
{ $$=$2;
set($$, ID_ptrmember);
mto($$, $1);
parser_stack($$).set(ID_component_name, parser_stack($3).get(ID_C_base_name));

@codecov
Copy link

codecov bot commented Aug 6, 2021

Codecov Report

Merging #6277 (19947e9) into develop (9aff751) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 19947e9 differs from pull request most recent head 21622a9. Consider uploading reports for the commit 21622a9 to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #6277   +/-   ##
========================================
  Coverage    75.90%   75.90%           
========================================
  Files         1492     1492           
  Lines       162711   162712    +1     
========================================
+ Hits        123508   123509    +1     
  Misses       39203    39203           
Impacted Files Coverage Δ
src/goto-instrument/contracts/contracts.cpp 92.59% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 25ed175...21622a9. Read the comment docs.

@feliperodri feliperodri force-pushed the struct-members-history branch from 606fb8d to 19947e9 Compare August 7, 2021 04:30
@feliperodri feliperodri requested a review from SaswatPadhi August 7, 2021 04:31
@feliperodri
Copy link
Collaborator Author

@SaswatPadhi Could you take another look?

@@ -395,22 +395,22 @@ void code_contractst::replace_old_parameter(
const auto &parameter = to_old_expr(expr).expression();

// TODO: generalize below
Copy link
Contributor

Choose a reason for hiding this comment

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

May be remove this comment now, since this matches the assigns clause constraints? Or actually, may be mention: TODO: Look into ID_ptrmember?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove it.

Copy link
Contributor

@SaswatPadhi SaswatPadhi Aug 7, 2021

Choose a reason for hiding this comment

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

I don't think the ID_ptrmember issue was fully resolved. I think we should have resolved this fully before merging.

@feliperodri feliperodri force-pushed the struct-members-history branch from 19947e9 to 21622a9 Compare August 7, 2021 20:38
@feliperodri feliperodri merged commit 61fd24d into diffblue:develop Aug 7, 2021
@feliperodri feliperodri deleted the struct-members-history branch August 7, 2021 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users bugfix Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants