-
Notifications
You must be signed in to change notification settings - Fork 274
Improves support for assigns clauses #5538
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
Improves support for assigns clauses #5538
Conversation
0e6ca07
to
d61dd49
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5538 +/- ##
===========================================
+ Coverage 74.24% 75.01% +0.77%
===========================================
Files 1431 1431
Lines 155290 155609 +319
===========================================
+ Hits 115290 116732 +1442
+ Misses 40000 38877 -1123
Continue to review full report at Codecov.
|
@NlightNFotis The code coverage is still showing the same spurious decrease as other PRs. I think one of the changes to the build scripts has broken it. Please can you have a look? |
@feliperodri Thank you for this work. Would it be possible to break it into a number of smaller commits to make it easier to review? As I understand it, this includes:
If these could be split up a bit, that would be great. |
This is not a full review. Just some initial observations. My apologies if I have jumped the gun by looking whilst it is still in draft status -
Good luck with finding the cause of the failing tests. |
9b56c97
to
f64eba0
Compare
af4fd3a
to
a7b3dab
Compare
4310b55
to
a7a7f72
Compare
@martin-cs @thomasspriggs I resolved all regression test issues and split up into a few commits, could you review it? Also, @thomasspriggs I revised the code for name abbreviations, misused of |
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.
Comments for most of the commits (with some blockers). I am yet to properly review the largest of the commits, "Adds arrays and structs support for assigns clauses" - will do so after a first range of fixes has been applied.
@feliperodri thanks for this and for separating the changes as requested. I am happy to take another look but maybe it's best if I wait until you've had a chance to look at / action @tautschnig 's changes. |
a7a7f72
to
f504152
Compare
@tautschnig thank you for all insightful comments. Could you take another review round? |
@martin-cs I agree. As soon as @tautschnig finish reviewing all changes, I can ping you for a final round. |
@tautschnig @kroening I completely removed the changes in this PR related to updating the grammar to support contracts on function declarations. I'll take a look at Daniel's proposal. |
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 have not read all of the changes to code_contracts.cpp
, but have provided some suggestions for improvement. Most likely that bit of code needs a complete overhaul anyway. All other parts are ok except for nit picks.
9cef787
to
3e529c0
Compare
@martin-cs and @thomasspriggs can I get one more review on this PR? |
3e529c0
to
bf636db
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.
Reasonable so far.
I only have some questions and some minor requests.
@@ -0,0 +1,12 @@ | |||
void assign_out_under(int a[], int len) __CPROVER_assigns(a[8]) | |||
{ | |||
a[7] = 5; |
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 this effectively the same test as assigns_enforce_arrays_05
or do I think so?
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.
It's quite similar. In this case we cant to see if we report failure correctly when the specification doesn't have a range, but a single cell (i.e., a[8]
instead of a[2, 5]
).
^VERIFICATION FAILED$ | ||
-- | ||
-- | ||
Checks whether verification fails when a function with an array assigns target |
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 any warning printed for this case?
If yes, does it make sense to pattern match for 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.
We currently do not have any warnings related to this issue. Should I create a GitHub issue to add this in future PRs?
bf636db
to
6eaed34
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.
Sorry, some small comments and otherwise it's good to go for me.
a29f208
to
3102111
Compare
@NlightNFotis could you take another look? |
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.
Looks good to me, thanks for the implementation of the comment suggestions.
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.
Unless I'm mistaken the changes here lead to a conflict in the parser w.r.t. to the comma operator. If I'm mistaken please explain.
src/ansi-c/parser.y
Outdated
| integer | ||
; | ||
|
||
array_range: |
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.
Not a blocker, but a comment from me: I'm quite worried about the proliferation of nonstandard extensions. We're getting into a situation where we have to support gcc extensions, clang extensions, visual studio extensions on top of our own modifications to the language...
This could've been done without any parser changes at the relatively small cost of a less cute syntax, e.g. __CPROVER_array_range(array, lower, upper)
or something like that. Looks bad, but less problematic syntactically.
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.
For now, I'll keep using this annotation, but that's a valid concern. Thus, I created the issue #5966 to discuss whether we should continue to use this annotation for array ranges or only adopt annotations that do not require changes to the 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.
Based on the discussion on #5966 I reverted all the parser changes (to support array ranges) from this PR. We should have a syntax similar to ACSL, but that should be added on a separate PR. I kept the code on the assigns clause size for this future support.
3102111
to
27cfe08
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.
Removing my block because the specific issue I was complaining about was addressed. Larger point about syntax extensions remains, but doesn't need to be addressed at this very moment.
27cfe08
to
61110ac
Compare
Assigns clauses should handle multiple targets. Previously, it only supported identifiers (e.g., variable `x`) and dereferenced pointers (e.g., *myPtr). So, we expand its support to also handle members of a struct (e.g. `myStruct.someMember` or `myStructPtr->otherMember`) and array ranges (e.g. `myArr[5, lastIdx]`). Signed-off-by: Felipe R. Monteiro <[email protected]>
Signed-off-by: Felipe R. Monteiro <[email protected]>
Code contracts now supports assigns clause with structs and array ranges. It also supports contracts specified across multiple source files. So, we added regression tests to cover these capabilites. Signed-off-by: Felipe R. Monteiro <[email protected]>
Signed-off-by: Felipe R. Monteiro <[email protected]>
61110ac
to
85dd63b
Compare
Assigns clauses are now able to handle structs and arrays.
Signed-off-by: Felipe R. Monteiro [email protected]