Skip to content

6.0: [ConsumeAddrChecker] Diagnose consumes of borrows. #74373

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

Conversation

nate-chandler
Copy link
Contributor

Explanation: Fix a class of overconsumes caused by compiling invalid code.

The ConsumeOperatorCopyableAddressesChecker is responsible for checking the validity of uses of the consume operator applied to copyable values in addresses (such as vars, inout parameters, and address-only values).

Previously, it did not check whether the address being consumed could be consumed in the first place. For example, guaranteed address-only parameters may not be consumed. These consumes should have been diagnosed but were not. The result was compiling invalid code that resulted in overconsumes.

Here, this is fixed by first checking whether the base from which the address being consumed is derived can be destroyed.
Scope: Affects ownership annotated code.
Issue: rdar://127518559&125817827
Original PR: #74360
Risk: Low.
Testing: Added and updated tests.
Reviewer: Andrew Trick ( @atrick )

When checking a `mark_unresolved_move_addr` instruction, first check
whether it is legal to consume the source.

rdar://127518559&125817827
@nate-chandler nate-chandler requested a review from a team as a code owner June 13, 2024 00:32
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler merged commit 0e9396b into swiftlang:release/6.0 Jun 13, 2024
5 checks passed
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar127518559 branch June 13, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants