You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Swiftify] Update availability for CxxSpan<->Span, ignore lifetimebound
on parameters with reference type
Because swift-ide-test doesn't care about typechecking,
std-span-interface.swift passed despite containing 2 separate errors.
This updates the test file to properly exercise the entire compilation
pipeline for the macro expansions, by running swift-frontend
-emit-module and calling each macro expansion.
The first issue was that CxxSpan initializers taking [Mutable]Span still
had their availability set to Swift 6.2+, even after back-deploying
caused [Mutable]Span to have availability back to Swift 5.0. Since
_SwiftifyImport expansions copy the availbility of Span, this resulted
in the macro expansions calling unavailable initializers.
Interestingly enough, this manifested itself in the form of a tripped
assert in SIL verification, because although we do now typecheck the
expansions from _SwiftifyImport, the compilation can still keep going
after `shouldEmitFunctionBody` returns false: the macro expansion
declaration is still there, but is now missing its definition, despite
not being external.
The second issue was when parameters with C++ reference types were
annotated with `[[clang::lifetimebound]]`. C++ reference parameters are
imported as `inout`, but lifetimebound results in the macro expansion
having a lifetime dependence on the parameter. For parameters with a
type that is `Escapable`, this is done using `@lifetime(borrow foo)`.
However, you can't borrow an inout paramter. For parameters with a type
that is `~Escapable` it's done using `@lifetime(copy foo)`, which works
with inout. When the parameter is `inout Escapable` however, neither
annotation works. Because of this we now ignore lifetimebound on
parameters with an `Escapable` type when they are imported as inout.
rdar://151493400
rdar://151678415
0 commit comments