Skip to content

[cxx-interop][serialization] resolve x-refs to instantiated/synthesiz… #74541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Jun 19, 2024

…ed C++ iterator conformance operators

These x-refs might not be resolvable using regular lookup from the 'std' module as they could be instantiated/synthesized by the clang importer. Augment the lookup logic in that case to try clang importer lookup logic that is used during the conformance to the C++ iterator protocol.

I first tried to embed additional information during serialization to denote synthesized/instantiated operators, but that actually doesn't cover all operators: #74524 .

Fixes Cmake adopter build that breaks in merge modules using Android NDK and std::unordered_map implicitly generated conformances:

C:\Users\alex\AppData\Local\Temp\FirestoreDataConverter-6e2827.swiftmodule:1:1: error: reference to top-level declaration '==' broken by a context change; the declaration kind of '=='  changed since building '...', it was in 'CxxStdlib' and now a candidate is found only in 'Swift'
1 | CxxStdlib.==
  | |- error: reference to top-level declaration '==' broken by a context change; the declaration kind of '=='  changed since building 'FirebaseFirestore', it was in 'CxxStdlib' and now a candidate is found only in 'Swift'
  | |- note: the declaration was expected to be found in module 'CxxStdlib' at 'S:\b\arm64\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\CxxStdlib.swiftmodule\aarch64-unknown-linux-android.swiftmodule'
  | |- note: or expected to be found in the underlying module 'std' defined at 'S:\android-ndk26\android-ndk-r26c\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\c++\v1\module.modulemap'
  | |- note: the declaration was actually found in module 'Swift' at 'S:\b\arm64\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Swift.swiftmodule\aarch64-unknown-linux-android.private.swiftinterface'
  | |- note: a candidate was filtered out because of a type mismatch; expected: '(std.__ndk1.__hash_map_const_iterator<__hash_const_iterator<UnsafeMutablePointer<__hash_node<__hash_value_type<basic_string<CChar, char_traits<CChar>, allocator<CChar>>, FieldValue>, UnsafeMutablePointer<Void>>>>>, std.__ndk1.__hash_map_const_iterator<__hash_const_iterator<UnsafeMutablePointer<__hash_node<__hash_value_type<basic_string<CChar, char_traits<CChar>, allocator<CChar>>, FieldValue>, UnsafeMutablePointer<Void>>>>>) -> Bool', found: '(Builtin.NativeObject, Builtin.NativeObject) -> Bool'

@hyp
Copy link
Contributor Author

hyp commented Jun 19, 2024

@swift-ci please test

@hyp hyp added the c++ interop Feature: Interoperability with C++ label Jun 20, 2024
…ed C++ iterator conformance operators

These x-refs might not be resolvable using regular lookup from the 'std' module as they could be instantiated/synthesized
by the clang importer. Augment the lookup logic in that case to try clang importer lookup logic that is used during
the conformance to the C++ iterator protocol.
@hyp hyp force-pushed the eng/lookup-imported-member-operator-cxx branch from 9666139 to 983fb80 Compare June 20, 2024 21:51
@hyp
Copy link
Contributor Author

hyp commented Jun 20, 2024

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Jun 20, 2024

@swift-ci please test source compatibility

@hyp hyp enabled auto-merge June 21, 2024 16:25
@hyp hyp disabled auto-merge June 21, 2024 16:25
@hyp
Copy link
Contributor Author

hyp commented Jun 21, 2024

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Jun 25, 2024

@swift-ci please smoke test

@hyp hyp merged commit 0c7621d into swiftlang:main Jun 25, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants