Skip to content

Conversation

@hnrklssn
Copy link
Member

We used to not emit bounds checks for things like __counted_by(4), but
we do now - likely fixed by #81585
These regression tests verify that behaviour.

rdar://151038254

hnrklssn added 3 commits May 23, 2025 12:36
Previously we would only add @_disfavoredOverload if the only type
changed was the return type, because in any other case it is unambiguous
which overload to call. However it is still ambiguous when storing the
function as a value rather than calling the function, unless explicit
type annotations are used.

To avoid breaking any existing code, this patch adds @_disfavoredOverload
to every overload generated by @_SwiftifyImport.

rdar://151206394
Previously we did not remove count parameters if any count parameters
were shared between count expressions, or if any count expression
contained operations. Buffer sizes were also just checked to be larger
than or equal than the given count.

We now extract the count from Spans/BufferPointers whenever possible,
and store that value in a variable at the start of the function. If
multiple parameters share the same count, a bounds check is emitted to
make sure that they have the same size. Subspans can be used if one span
is larger than necessary.

The message in the bounds check is changed so that it includes the
expected and actual value, to aid in debugging.

This patch also fixes some incorrect indentation, and adds the
Whitespace.swift test case to act as a regression test in case the
indentation changes, since the other test cases don't use significant
whitespace.

rdar://151488820
rdar://151511090
rdar://146333006
rdar://147715799
We used to not emit bounds checks for things like `__counted_by(4)`, but
we do now - likely fixed by
swiftlang#81585
These regression tests verify that behaviour.

rdar://151038254
@hnrklssn
Copy link
Member Author

actually, since #81585 is still open, let me just fold that in there instead

@hnrklssn hnrklssn closed this May 24, 2025
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.

1 participant