Commit Graph

8 Commits

Author SHA1 Message Date
Gabor Horvath
7bdd496f61 Address review comments. 2025-03-19 12:56:56 +00:00
Egor Zhdan
ef47dd6655 [cxx-interop] Re-enable a test for reference counted types
This also re-enables a test that was disabled since 2022.

rdar://97532642
2024-05-07 20:20:45 +01:00
Egor Zhdan
bd6da5dc64 [cxx-interop][IRGen] Do not try to retain/release a null pointer
This teaches IRGen to only emit a lifetime operation (retain or release) for a C++ foreign reference type if the pointer is not `nullptr`.

Previously the compiler would in some cases emit a release call for `nullptr`, which breaks the assumption that the argument to a custom release function is `_Nonnull`. For instance:
```
var globalOptional: MyRefType? = nil
func foo() { globalOptional = MyRefType.create() }
```
When emitting IR for the assignment operation to `globalOptional`, the compiler would emit code to first retrieve the existing value of `globalOptional` and release it. If the value is `nil`, it does not need to be released.

rdar://97532642
2024-05-07 20:20:45 +01:00
Alex Lorenz
c215abdd8c [cxx-interop][linux] modularize the bits part of libstdc++
Fixes https://github.com/apple/swift/issues/64457
2023-07-27 10:20:28 -07:00
zoecarver
96cd6188ef [cxx-interop] Fix crash when lowering self arg in foriegn reference type method call. 2022-10-26 18:22:50 -07:00
zoecarver
625760a3a8 [cxx-interop] Fix foreign reference types with reference counting that live in a namespace.
Before this patch we tried to do lookup in the _ObjC module for the retain/release functions. Now we use the clang module that the reference type lives in.
2022-09-01 10:48:36 -07:00
zoecarver
13b0a5bc37 [nfc] Clang format changes. 2022-07-21 17:34:36 -04:00
zoecarver
4021082a55 [wip][cxx-interop] Support for custom reference counting operations. 2022-07-21 10:25:57 -04:00