Commit Graph

11 Commits

Author SHA1 Message Date
Gábor Horváth
788d0f9f64 Merge pull request #79396 from swiftlang/gaborh/fix-lifetime-errors-in-macros
[cxx-interop] Work around lifetime errors in SwiftifyImport generated code
2025-02-15 15:29:12 +00:00
Doug Gregor
3c8ef82963 Enable usable of Span by default
Usage of Span was temporarily behind an experimental feature flag. Now
that SE-0447 has been accepted, remove the experimental feature flag and
allow Span usage everywhere.

Implements rdar://144819992.
2025-02-14 10:45:47 -08:00
Gabor Horvath
df27b79579 [cxx-interop] Work around lifetime errors in SwiftifyImport generated code
Unfortunately, this was not discovered earlier as swift-ide-test is not
invoking the SIL passes that produce this diagnostic. When creating
Swift spans from C++ spans we have no lifetime dependency information to
propagate as C++ spans are modeled as escapable types. Hence, this PR
introduces a helper function to bypass the lifetime checks triggered by
this discepancy. Hopefully, the new utility will go away as the lifetime
analysis matures on the Swift side and we get standardized way to deal
with unsafe lifetimes.
2025-02-14 16:40:43 +00:00
Gábor Horváth
7eada7dd86 Merge pull request #79012 from swiftlang/gaborh/disfavoredOverload
[cxx-interop] Avoid generating ambiguous wrapper functions
2025-01-29 19:28:42 +00:00
Gabor Horvath
a57aff04c9 [cxx-interop] Avoid generating ambiguous wrapper functions
When we generate a safe wrapper that only differs in the return type we
might introduce ambiguities as some callers might not have enough
information to disambiguate between the overloads. This PR makes sure
the newly generated declarations are marked as @_disfavoredOverload so
the compiler can keep calling the old functions without a source break
when the feature is turned on.

rdar://139074571
2025-01-29 15:19:30 +00:00
Gabor Horvath
dd3db51f60 [cxx-interop] Make borrowing specifiers more precise
We do not need to borrow from view objects passed by value but we need
to borrow from owners taken by const reference regardless of whether it
was annotated using lifetimebound or lifetime_capture_by.
2025-01-29 11:49:32 +00:00
Gábor Horváth
44fa6506c3 Merge pull request #78945 from swiftlang/gaborh/wrapper-method
[cxx-interop] Add safe wrapper test with a member function
2025-01-29 11:46:35 +00:00
Gabor Horvath
06e5ead8da [cxx-interop] Support borrowing from self in SwiftifyImport
Support adding safe wrappers for APIs returning std::span depending on
the this object. This also fixes an issue for APIs with 0 parameters.

rdar://139074571
2025-01-28 13:54:10 +00:00
Gabor Horvath
da3be5d99d [cxx-interop] Add safe wrapper test with a member function 2025-01-27 12:45:58 +00:00
Gabor Horvath
042b108e6f [cxx-interop] Make ClangImporter support lifetimebound annotated spans
Generate safe Swift Span wrappers using the new SwiftifyImport macro.

rdar://139074571
2025-01-22 15:07:02 +00:00
Gabor Horvath
4846c56795 [cxx-interop] Generate safe overloads for non-escapable spans
A previous PR already added support to the SwiftifyImport macro to
generate safe wrappers. This PR makes ClangImporter emit the macro to do
the transformation.
2025-01-08 11:19:35 +00:00