swift
d7bd76e9 - [Swiftify] Add return pointer support (#78571)

Commit
259 days ago
[Swiftify] Add return pointer support (#78571) * Import __counted_by for function return values Instead of simply passing a parameter index to _SwiftifyInfo, the _SwiftifyExpr enum is introduced. It currently has two cases: - .param(index: Int), corresponding to the previous parameter index - .return, corresponding to the function's return value. ClangImporter is also updated to pass this new information along to _SwiftifyImport, allowing overloads with buffer pointer return types to be generated. The swiftified return values currently return Span when the return value is marked as nonescaping, despite this not being sound. This is a bug that will be fixed in the next commit, as the issue is greater than just for return values. * Fix Span variant selection There was an assumption that all converted pointers were either converted to Span-family pointers, or UnsafeBufferPointer-family pointers. This was not consistently handled, resulting in violating the `assert(nonescaping)` assert when the two were mixed. This patch removes the Variant struct, and instead each swiftified pointer separately tracks whether it should map to Span or UnsafeBufferPointer. This also fixes return pointers being incorrectly mapped to Span when marked as nonescaping.
Author
Parents
Loading