Skip to content

CONTRACTS: Support object slices in assigns clauses #6814

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

Conversation

remi-delmas-3000
Copy link
Collaborator

Adds support the following targets in assigns clauses:

  • __CPROVER_object_from(ptr): allows to assign all remaining bytes of the object, starting at the given address.
  • __CPROVER_object_slice(ptr, size): allows to assign size bytes of the object starting at the given address.

Both targets are translated to __CPROVER_havoc_slice for contract replacement.

  • 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).
  • [N/A] 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.

@codecov
Copy link

codecov bot commented Apr 18, 2022

Codecov Report

Merging #6814 (384dd30) into develop (bf66073) will increase coverage by 0.00%.
The diff coverage is 80.00%.

❗ Current head 384dd30 differs from pull request most recent head 0bb6993. Consider uploading reports for the commit 0bb6993 to get more accurate results

@@           Coverage Diff            @@
##           develop    #6814   +/-   ##
========================================
  Coverage    77.00%   77.01%           
========================================
  Files         1594     1594           
  Lines       184345   184413   +68     
========================================
+ Hits        141957   142020   +63     
- Misses       42388    42393    +5     
Impacted Files Coverage Δ
...nstrument/contracts/havoc_assigns_clause_targets.h 100.00% <ø> (ø)
src/ansi-c/c_typecheck_code.cpp 77.85% <60.86%> (-2.07%) ⬇️
...trument/contracts/havoc_assigns_clause_targets.cpp 97.53% <100.00%> (+0.34%) ⬆️
...o-instrument/contracts/instrument_spec_assigns.cpp 97.50% <100.00%> (+0.35%) ⬆️
...oto-instrument/contracts/instrument_spec_assigns.h 94.73% <100.00%> (ø)
src/goto-instrument/contracts/utils.h 100.00% <100.00%> (ø)
src/crangler/c_wrangler.cpp 58.57% <0.00%> (-0.76%) ⬇️
src/goto-instrument/contracts/contracts.cpp 93.89% <0.00%> (-0.60%) ⬇️
src/ansi-c/ansi_c_entry_point.cpp 89.02% <0.00%> (-0.39%) ⬇️
... and 4 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 1d608d2...0bb6993. Read the comment docs.

@jimgrundy jimgrundy added aws Bugs or features of importance to AWS CBMC users aws-high labels Apr 20, 2022
@feliperodri feliperodri added the Code Contracts Function and loop contracts label Apr 20, 2022
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.

Please fold the second commit into the first one to ensure bisectability.

Comment on lines 922 to 936
if(has_subexpr(target, ID_side_effect))
{
error().source_location = target.source_location();
error() << "side-effects not allowed in assigns clause targets" << eom;
throw 0;
}
if(has_subexpr(target, ID_if))
{
error().source_location = target.source_location();
error() << "ternary expressions not allowed in assigns "
"clause targets"
<< eom;
throw 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This repeats multiple times and might be worth factoring out into a static function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

factored it using a local lambda

Copy link
Collaborator

@feliperodri feliperodri left a comment

Choose a reason for hiding this comment

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

LGTM.

@feliperodri feliperodri changed the title Contracts: support object slices in assigns clauses CONTRACTS: support object slices in assigns clauses Apr 22, 2022
@remi-delmas-3000 remi-delmas-3000 force-pushed the contracts-object-slice branch 2 times, most recently from 05710dd to 2a53c59 Compare April 22, 2022 17:43
Introduces __CPROVER_object_from and __CPROVER_object_slice
target expression in assigns clauses. Both get compiled
to __CPROVER_havoc_slice for contract replacement.
@feliperodri feliperodri changed the title CONTRACTS: support object slices in assigns clauses CONTRACTS: Support object slices in assigns clauses Apr 22, 2022
@feliperodri feliperodri merged commit 098898c into diffblue:develop Apr 25, 2022
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 aws-high Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants