Commit Graph

30 Commits

Author SHA1 Message Date
John Hui
796075ab88 [cxx-interop] Fix spurious ambiguous member lookup (#78132)
Nested calls to importBaseMemberDecl() subvert its cache and compromise its idempotence, causing the semantic checker to spuriously report ambiguous member lookups when multiple ClangRecordMemberLookup requests are made (e.g., because of an unrelated missing member lookup).

One such scenario is documented as a test case: test/Interop/Cxx/class/inheritance/inherited-lookup-typechecker.swift fails without this patch because of the expected error from the missing member. Meanwhile, test/Interop/Cxx/class/inheritance/inherited-lookup-executable.swift works because it does not attempt to access a missing member.

This patch fixes the issue by only calling importBaseMemberDecl() in the most derived class (where the ClangRecordMemberLookup originated, i.e., not in recursive requests).

As a consequence of my patch, synthesized member accessors in the derived class directly invoke the member from the base class where the member is inherited from, rather than incurring an indirection at each level of inheritance. As such, the synthesized symbol names are different (and shorter). I've taken this opportunity to update the relevant tests to // CHECK for more of the mangled symbol, rather than only the synthesized symbol prefix, for more precise testing and slightly better readability.

rdar://141069984
2024-12-17 11:40:18 -08:00
Egor Zhdan
71d02efcec [cxx-interop] Fix a test for move-only types
rdar://128424443
2024-06-14 20:23:33 +01:00
Andrew Trick
51e272f251 Disable test/Interop/Cxx/class/move-only/inherited-field-access-silgen.swift
This test does not produce consistent SIL across various test
configurations. We have a discrepancy on whether an argument is
@in_guaranteed vs. @guaranteed.

Tracked in rdar://128424443.
2024-05-20 16:01:30 -07:00
Kavon Farvardin
090f48f6f3 CxxInterop: resolve GH#70246
https://github.com/apple/swift/issues/70246
2024-05-14 17:45:44 -07:00
Kavon Farvardin
5ae2f6bd25 CxxInterop: use Unsafe*Pointer for move-only 2024-05-14 17:44:22 -07:00
Kavon Farvardin
21d147d3d0 Revert "CxxInterop: use workaround unconditionally"
This reverts commit 1036031d06.
2024-05-14 16:43:05 -07:00
Kavon Farvardin
1036031d06 CxxInterop: use workaround unconditionally
We haven't yet solved the underlying issue in rdar://128013193 and the
workaround to make it conditionally use the better importing strategy of
Unsafe{Mutable}Pointer no longer will apply, since NoncopyableGenerics
is here.
2024-05-13 13:08:25 -07:00
Kavon Farvardin
7a83af6925 Revert "CxxInterop: remove checks for NoncopyableGenerics"
This reverts commit b04be89dce.
2024-05-13 10:46:30 -07:00
Kavon Farvardin
b04be89dce CxxInterop: remove checks for NoncopyableGenerics
It will always evaluate to true now; it's not experimental. This change
effectively reverts the following:
 - 6140ba1079
 - 78eee32467
2024-05-08 10:49:12 -07:00
Kavon Farvardin
0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00
Egor Zhdan
b330376a43 [cxx-interop] Pull changes from swift-6 compat mode into swift-5.9
This gives projects using C++ interop compat mode 5.9 access to the new features such as virtual methods and move-only types.

rdar://126485814
2024-04-24 11:53:31 +01:00
Egor Zhdan
6140ba1079 [cxx-interop] Do not try to use UnsafePointer<T> for non-copyable T when adding base member accessors 2024-04-23 18:47:55 +01:00
Egor Zhdan
78eee32467 [cxx-interop] Import NonCopyable* as OpaquePointer if noncopyable generics are disabled
C++ pointer type `T*` is generally imported as `Unsafe(Mutable)Pointer<T>`. However, if `T` is non-copyable in Swift (e.g. it has a deleted C++ copy constructor), using `UnsafePointer<T>` type requires noncopyable generics to be enabled.

This was causing assertion failures when building SwiftCompilerSources in https://github.com/apple/swift/pull/72912.
2024-04-23 18:47:55 +01:00
Karoy Lorentey
9725b892cc [test] More test updates 2024-03-18 13:27:46 -07:00
Kavon Farvardin
2951162527 Test: disable move-only-cxx-value-type.swift
The test was relying on UnsafeMutablePointer (UMP) not having a Copyable
 requirement. Those Copyable requirements are more prominent when using
the new infrastructure for noncopyable types. Since UMP is planned to
have `~Copyable` on its generic parameter quite soon, this shouldn't
remain broken for too long.
2024-03-14 23:10:44 -07:00
Doug Gregor
59d1846b59 De-XFAIL a test that now works with noncopyable generics 2024-03-07 15:32:13 -08:00
Egor Zhdan
78b9de1391 [cxx-interop] Run tests with swift-6 compat mode 2024-02-23 16:24:14 +00:00
Alex Lorenz
6312fc05cc [interop] adopt a swift-6 interoperability mode for new features in the next release 2024-02-21 09:27:45 -08:00
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Kavon Farvardin
08b71e0136 NCGenerics: rebuild stdlib from its interface
When a NoncopyableGenericsMismatch happens between the compiler and
stdlib, allow the compiler to rebuild the stdlib from its interface
instead of exiting with an error.
2024-02-15 18:08:54 -08:00
Kavon Farvardin
5f977ca763 NCGenerics: force module mismatches 2024-01-31 14:00:08 -08:00
Allan Shortlidge
bb38de355b Add REQUIRES: asserts to NoncopyableGenerics tests. 2024-01-11 15:31:40 -08:00
Alex Lorenz
623d3d2032 [cxx-interop] review fixes for non-copyable patch, ensure we only enable this in upcoming Swift 2023-12-05 14:16:30 -08:00
Alex Lorenz
ec931c82c4 [cxx-interop] non-copyable test windows workaround and no SIL verify for NC generic test 2023-12-05 13:42:13 -08:00
Alex Lorenz
3a340c78f0 [cxx-interop] move-only: do not test consume with unsafeAddress accessors - they do not yet work 2023-12-03 18:11:07 -08:00
Alex Lorenz
6a47011b18 [cxx-interop] add IRGen test for field base accessors for non-copyable fields 2023-11-29 09:10:51 -08:00
Alex Lorenz
bacc58e0f7 [cxx-interop] provide correct referential access to non-copyable base fields from a derived value type 2023-11-28 20:10:07 -08:00
Alex Lorenz
51d0e84933 [cxx-interop] add a test to cover accessing non-copyable field 2023-11-28 14:07:44 -08:00
Alex Lorenz
fd6a5a20ef [cxx-interop] test accessing fields of a move-only C++ type 2023-11-28 12:26:48 -08:00
Alex Lorenz
3cdb4b1151 [cxx-interop] add some initial move only tests 2023-11-16 10:08:29 -08:00