Skip to content

allow contracts on function declarations #5946

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 1 commit into from
Mar 22, 2021
Merged

Conversation

kroening
Copy link
Member

This changes the grammar of the C frontend to allow contracts on function
declarations. This also removes the requirement that the contract clauses
appear in any particular order.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@kroening kroening force-pushed the contract_grammar branch 2 times, most recently from 51f2a9f to 5547367 Compare March 17, 2021 10:55
Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

This looks nice, but given that tests are failing there obviously are some problems left to be fixed. Nothing blatantly obvious while reviewing the source code, thus requires more debugging.

@feliperodri
Copy link
Collaborator

This looks nice, but given that tests are failing there obviously are some problems left to be fixed. Nothing blatantly obvious while reviewing the source code, thus requires more debugging.

All code contracts are failing, which is expected since the regression suite also need to be updated (i.e., move all contracts to function declarations).

@kroening
Copy link
Member Author

The bit that is missing is to change the scope to the scope used for the parameters when parsing the contract expressions.

There should not be a need to change any of the existing tests, the existing syntax continues to work.

@tautschnig tautschnig removed their assignment Mar 18, 2021
@kroening kroening force-pushed the contract_grammar branch 2 times, most recently from e1ccf25 to 4b80251 Compare March 19, 2021 14:12
@kroening kroening added C Front End Code Contracts Function and loop contracts labels Mar 19, 2021
@kroening kroening force-pushed the contract_grammar branch 3 times, most recently from 3473ce8 to 7b035e4 Compare March 21, 2021 20:03
@kroening kroening marked this pull request as ready for review March 21, 2021 20:43
@kroening kroening assigned tautschnig and unassigned kroening Mar 21, 2021
@martin-cs
Copy link
Collaborator

martin-cs commented Mar 21, 2021 via email

@codecov
Copy link

codecov bot commented Mar 21, 2021

Codecov Report

Merging #5946 (4a50ac1) into develop (867168c) will increase coverage by 0.77%.
The diff coverage is 92.94%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5946      +/-   ##
===========================================
+ Coverage    74.24%   75.01%   +0.77%     
===========================================
  Files         1431     1431              
  Lines       155290   155276      -14     
===========================================
+ Hits        115290   116483    +1193     
+ Misses       40000    38793    -1207     
Impacted Files Coverage Δ
src/ansi-c/c_typecheck_base.h 100.00% <ø> (ø)
src/ansi-c/c_typecheck_code.cpp 77.91% <ø> (+0.28%) ⬆️
src/ansi-c/expr2c.cpp 68.62% <33.33%> (-0.15%) ⬇️
src/ansi-c/ansi_c_convert_type.cpp 78.67% <100.00%> (+0.81%) ⬆️
src/ansi-c/ansi_c_convert_type.h 100.00% <100.00%> (ø)
src/ansi-c/ansi_c_declaration.cpp 72.89% <100.00%> (+0.78%) ⬆️
src/ansi-c/c_typecheck_base.cpp 78.23% <100.00%> (-0.87%) ⬇️
src/ansi-c/parser.y 77.72% <100.00%> (-0.05%) ⬇️
src/ansi-c/parser_static.inc 96.58% <100.00%> (+0.12%) ⬆️
src/symtab2gb/symtab2gb_parse_options.cpp 60.65% <100.00%> (+1.33%) ⬆️
... and 26 more

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 e166f4c...4a50ac1. Read the comment docs.

Copy link
Collaborator

@tautschnig tautschnig left a 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, but it would be nice to modify some of the existing tests in regression/contract to make use of the new feature. Ideally with all the options now newly available: mixing contracts on declarations and definitions, mixing up their order. Also, what should we expect to happen when both a declaration and a definition have a contract (cf. @martin-cs' comment) - this might mean adding a KNOWNBUG test.

@tautschnig tautschnig assigned kroening and unassigned tautschnig and feliperodri Mar 22, 2021
This changes the grammar of the C frontend to allow contracts on function
declarations.  This also removes the requirement that the contract clauses
appear in any particular order.
@kroening kroening merged commit 6b36ce6 into develop Mar 22, 2021
@kroening kroening deleted the contract_grammar branch March 22, 2021 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Front End Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants