-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Add SIL function representation cxx_method; Support extending C++ types. #34993
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
[cxx-interop] Add SIL function representation cxx_method; Support extending C++ types. #34993
Conversation
f20dd85
to
e21aa57
Compare
@varungandhi-apple all resolved. Thanks for the review! |
e21aa57
to
cd9e0bc
Compare
@swift-ci please smoke test. |
1 similar comment
@swift-ci please smoke test. |
@swift-ci please test Windows. |
Mostly LGTM, deferring to other folks for specifics. |
cd9e0bc
to
686dcb2
Compare
@swift-ci please smoke test. |
1 similar comment
@swift-ci please smoke test. |
686dcb2
to
7b839bc
Compare
@swift-ci please smoke test. |
lib/IRGen/GenCall.cpp
Outdated
@@ -2187,7 +2191,12 @@ class SyncCallEmission final : public CallEmission { | |||
break; | |||
|
|||
case SILFunctionTypeRepresentation::Block: | |||
adjusted.add(getCallee().getBlockObject()); | |||
case SILFunctionTypeRepresentation::CXXMethod: | |||
if (getCallee().getRepresentation() == |
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.
Why are you handling the block and cxxmethod in same case if you need to do a different call for block vs cxx method? I think it would be better to have separate cases.
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.
Aha. Turns out there was actually a reason for this: we want the fall-through here for both cases. Without this weird if-inside-the-case pattern we don't externalizeArguments
for ::Block
.
616fb73
to
092375e
Compare
@swift-ci please smoke test. |
092375e
to
12c337d
Compare
@swift-ci please smoke test. |
12c337d
to
a6de933
Compare
@swift-ci please smoke test. |
a6de933
to
fcb1f7e
Compare
…ending C++ types. There are three major changes here: 1. The addition of "SILFunctionTypeRepresentation::CXXMethod". 2. C++ methods are imported with their members *last*. Then the arguments are switched when emitting the IR for an application of the function. 3. Clang decls are now marked as foreign witnesses. These are all steps towards being able to have C++ protocol conformance.
fcb1f7e
to
036361d
Compare
@swift-ci please smoke test. |
// as foreign. | ||
if (dyn_cast_or_null<clang::CXXMethodDecl>( | ||
witness.getDecl()->getClangDecl())) | ||
newDecl = newDecl.asForeign(); |
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.
Why are C++ methods different than Objective-C methods in this regard?
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.
Basically, if an Objective-C method is marked as foreign it will be imported using the Objective-C type and not the Swift type. For example, it might be imported as () -> NSString
instead of what we want which is: () -> String
.
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
There are three major changes here:
SILFunctionTypeRepresentation::CXXMethod
.These are all steps towards being able to have C++ protocol conformance.
A few other notes:
Resolves SR-12750.