-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Allow import-as-member for types in namespaces #82496
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
Conversation
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
: lookup(SerializedSwiftName(nameComponent), | ||
std::make_pair(ContextKind::TranslationUnit, StringRef())); | ||
bool entryFound = false; | ||
for (auto entry : entries) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use llvm::find_if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to refactor that locally, but that means we have to do the casting multiple times, both within the find_if
and outside of it. I personally prefer a simple loop here, but I can change it if you feel strongly.
@swift-ci please smoke test macOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG! A minor suggestion to improve the tests but it is completely optional.
NamespacesTestSuite.test("Struct in a deep namespace") { | ||
let s = MyNS.MyDeepNS.DeepNestedStruct() | ||
expectEqual(456, s.method()) | ||
expectEqual(456, s.methodConstRef()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If each method added a distinct number to the value we could be 100% sure we end up calling the right method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, let's do that.
This adds support for `swift_name` attribute being used with C++ types that are declared within namespaces, e.g. ``` __attribute__((swift_name("MyNamespace.MyType.my_method()"))) ``` Previously import-as-member would only accept a top-level unqualified type name. rdar://138934888
392cdd9
to
e95f6a3
Compare
@swift-ci please smoke test |
@swift-ci please test Windows |
This adds support for
swift_name
attribute being used with C++ types that are declared within namespaces, e.g.Previously import-as-member would only accept a top-level unqualified type name.
This relies on swiftlang/llvm-project#10899.
rdar://138934888