Commit Graph

11 Commits

Author SHA1 Message Date
Egor Zhdan
b16816b4ee [cxx-interop] Disable test with an older runtime
848fad00 introduced support for printing foreign reference types. It changes both the compiler and the runtime, and having the runtime change applied is required for the test to pass. Let's not try to run it with an old runtime.

This change also splits up a test for printing of value types from a test for printing of foreign reference types, since we don't have any runtime restrictions for value types.

rdar://153205860
(cherry picked from commit 62d56067c8)
2025-06-23 18:16:24 +01:00
Gabor Horvath
2f46d55b85 [cxx-interop] Support importing static factories as initializers
This PR adds a feature to import static factory functions returning
foreign reference types to be imported as initializers using the
SWIFT_NAME annotation.
2025-03-03 11:25:05 +00:00
John Hui
ec506f824b [cxx-interop] Fix swift::Type to clang::QualType conversion to correctly handle foreign reference types
For types imported from C++, the original clang::TypeDecl is saved in
the swift::Type and reused for conversions back to clang::QualType.
However, the conversion did not account for foreign reference types,
which should be mapped to a pointer to the C++ record type, rather than
the record type itself.

This bug first appeared as a function template instantiation failure
due to a sanity check performed by SwiftDeclConverter::foreignReferenceTypePassedByRef()
but may also affect other round-tripping type conversions.
The added test case demonstrates the template instantiation scenario,
where templates were being used to overcome Swift/C++ interop's current
lack of support for class inheritance.

rdar://134979343
2024-10-07 14:40:38 -07:00
fahadnayyar
ea4328384d [cxx-interop] Add SWIFT_RETURNS_RETAINED and SWIFT_RETURNS_UNRETAINED annotations to specify ownership of FRT returned by a C++ method or function
rdar://135306908
2024-09-05 11:44:31 -07:00
Akira Hatanaka
335cec0e8d [cxx-interop][IRGen] Do not pass a foreign reference type to objc_retainAutoreleasedReturnValue (#73630)
If a foreign reference type has a custom retain function, emit a call to
it instead of emitting a call to objc_retainAutoreleasedReturnValue.

rdar://117353222
2024-05-17 09:04:02 -07:00
Alex Lorenz
f7ce9aa37f [cxx-interop] Synthesized derived-to-base field getter should copy out a retainable FRT value
This matches the semantics of accessing the same field from the base class
2023-10-16 14:41:44 -07:00
Alex Lorenz
415045024c [cxx-interop] Use a synthesized C++ method when accessing a base field or subscript from a derived class synthesized method
The use of a synthesized C++ method allows us to avoid making a copy of self when accessing the base field or subscript from Swift
2023-10-16 14:34:37 -07:00
Alex Lorenz
82f8d5d1e8 [cxx-interop] add additional tests for calling base methods on FRT 2023-09-29 14:18:02 -07:00
zoecarver
c5aaa6098d [cxx-interop] Start fixing issue with layout of FRTs that contain base classes or un-importable memebers. 2022-10-17 10:18:25 -07:00
zoecarver
4021082a55 [wip][cxx-interop] Support for custom reference counting operations. 2022-07-21 10:25:57 -04:00
zoecarver
fc3b3a1d71 [cxx-interop] Implement foreign reference types.
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
2021-12-08 15:35:18 +00:00