Skip to content

[cxx-interop] Synthesize conformances to UnsafeCxxInputIterator #60001

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
Jul 20, 2022

Conversation

egorzhdan
Copy link
Contributor

This teaches ClangImporter to synthesize conformances of C++ iterator types to UnsafeCxxInputIterator protocol from the Cxx module.

We consider a C++ type to be an iterator if it defines a subtype (usually a typedef or a using decl) called iterator_category that inherits from std::input_iterator_tag.

rdar://96235368

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jul 11, 2022
@egorzhdan egorzhdan requested review from hyp, Huddie and zoecarver July 11, 2022 15:21
@egorzhdan
Copy link
Contributor Author

I will need to add more tests.

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@zoecarver zoecarver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so awesome!! Thanks Egor.

@egorzhdan egorzhdan force-pushed the egorzhdan/synthesize-iterator-conformance branch 2 times, most recently from a0a02ab to 6d7f03f Compare July 15, 2022 11:41
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/synthesize-iterator-conformance branch 2 times, most recently from bebaf33 to 727606e Compare July 18, 2022 11:20
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/synthesize-iterator-conformance branch from 727606e to f73b027 Compare July 18, 2022 16:51
@egorzhdan egorzhdan marked this pull request as ready for review July 18, 2022 16:51
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

return;

// Check if present: `func ==`
// FIXME: this only detects `operator==` declared as a member.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will address this in a separate patch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you define bool operator==(const A& lhs, const A& rhs) out of the class definition, the lookup won't find this decl (which is OK, we just need to handle it differently here)

@egorzhdan egorzhdan force-pushed the egorzhdan/synthesize-iterator-conformance branch from f73b027 to 0c3edb8 Compare July 19, 2022 19:52
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

This teaches ClangImporter to synthesize conformances of C++ iterator types to `UnsafeCxxInputIterator` protocol from the `Cxx` module.

We consider a C++ type to be an iterator if it defines a subtype (usually a typedef or a using decl) called `iterator_category` that inherits from `std::input_iterator_tag`.

rdar://96235368
@egorzhdan egorzhdan force-pushed the egorzhdan/synthesize-iterator-conformance branch from 0c3edb8 to d85d2e9 Compare July 20, 2022 10:45
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit e1e00ed into main Jul 20, 2022
@egorzhdan egorzhdan deleted the egorzhdan/synthesize-iterator-conformance branch July 20, 2022 14:34
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