-
Notifications
You must be signed in to change notification settings - Fork 274
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
Adds support for struct members in history variables #6277
Conversation
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.
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 ¶meter = to_old_expr(expr).expression(); | |||
|
|||
// TODO: generalize below | |||
if(parameter.id() == ID_dereference) | |||
if(parameter.id() == ID_dereference || parameter.id() == ID_member) |
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 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?
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 added more tests to cover these cases. ID_member
seems enough.
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 did a quick search, and it looks like ID_ptrmember
indeed corresponds to ->
:
cbmc/src/cpp/cpp_typecheck_expr.cpp
Line 454 in 1ab5de1
{ ID_ptrmember, "->" }, |
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.
@SaswatPadhi This is for cpp
not ansi-c
.
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.
@feliperodri Are you sure this doesn't apply to ANSI-C as well? From the ANSI-C parser:
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 Report
@@ Coverage Diff @@
## develop #6277 +/- ##
========================================
Coverage 75.90% 75.90%
========================================
Files 1492 1492
Lines 162711 162712 +1
========================================
+ Hits 123508 123509 +1
Misses 39203 39203
Continue to review full report at Codecov.
|
Signed-off-by: Felipe R. Monteiro <[email protected]>
606fb8d
to
19947e9
Compare
@SaswatPadhi Could you take another look? |
@@ -395,22 +395,22 @@ void code_contractst::replace_old_parameter( | |||
const auto ¶meter = to_old_expr(expr).expression(); | |||
|
|||
// TODO: generalize below |
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.
May be remove this comment now, since this matches the assigns clause constraints? Or actually, may be mention: TODO: Look into ID_ptrmember
?
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.
Remove it.
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 don't think the ID_ptrmember
issue was fully resolved. I think we should have resolved this fully before merging.
Signed-off-by: Felipe R. Monteiro <[email protected]>
19947e9
to
21622a9
Compare
Signed-off-by: Felipe R. Monteiro [email protected]