Cherry-pick "[Swiftify] Support __sized_by on byte-sized pointee types" to release/6.2 #82145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for producing safe overloads for pointers annotated with __sized_by when the pointer is imported as Unsafe[Mutable]Pointer. Previously __sized_by was only supported for Unsafe[Mutable]RawPointer and OpaquePointer. ClangImporter is modified to check the pointee type for __sized_by, and only apply this if the pointee type has a size of 1 byte. If the pointee type is larger, __counted_by is the preferred annotation.
This fixes errors that would otherwise be produced when using __sized_by in a way not supported by _SwiftifyImport, even though that use case was supported by clang. In cases that still aren't supported, we no longer produce an overload.
rdar://150966684
rdar://150966021
[Swiftify] Support __sized_by on byte-sized pointee types #81752
Low
Added regression tests, will continue with manual qualification
@delcypher
@Xazax-hun