-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] convert CXXForeignReferenceTypeInitializers into SuppressCXXForeignReferenceTypeInitializers to be an opt-out flag #80659
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
…ssCXXForeignReferenceTypeInitializers to be an opt-out flag
…gnostics in case of inferred c++ foreign reference types)
@swift-ci please smoke test |
NOTE: I am addressing rdar://145098078 as well in this patch. We still need to address rdar://148952864 which is a minor bug. Now we also see diagnostics for C++ APIs returning a type which was derived from a |
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 see that this is already merged. Could you address the reviews in a follow-up?
Also, I strongly discourage PRs that are changing two unrelated features at the same time. The changes to importing the FRT ctors and the changes to the diagnostics could have been two independent PRs, I don't see any dependencies between them.
Edit: my concerns are now resolved.
@@ -2538,6 +2538,9 @@ llvm::SmallVector<clang::CXXMethodDecl *, 4> | |||
SwiftDeclSynthesizer::synthesizeStaticFactoryForCXXForeignRef( | |||
const clang::CXXRecordDecl *cxxRecordDecl) { | |||
|
|||
if (cxxRecordDecl->isAbstract()) |
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.
Do we have a test covering this branch? I am ok with the change but would be nice to have it actually tested.
@@ -1,7 +1,7 @@ | |||
// RUN: %target-swift-ide-test -print-module -module-to-print=POD -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s | |||
|
|||
// CHECK: class Empty { | |||
// CHECK-NOT: init | |||
// CHECK: init |
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: I think it is not the right indentation.
@@ -119,6 +119,7 @@ struct NonCopyable { | |||
// CHECK-NEXT: } | |||
// CHECK-NEXT: } | |||
// CHECK: class MyImmortal { | |||
// CHECK-NEXT: init |
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: indent the same as the function below.
@@ -3609,7 +3609,18 @@ namespace { | |||
isa<clang::FunctionDecl>(decl) | |||
? cast<clang::FunctionDecl>(decl)->getReturnType() | |||
: cast<clang::ObjCMethodDecl>(decl)->getReturnType(); | |||
if (isForeignReferenceTypeWithoutImmortalAttrs(retType)) { | |||
clang::QualType pointeeType = retType; |
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.
This was the only use of isForeignReferenceTypeWithoutImmortalAttrs
. I think we could have fixed that function. Now I think it is unused so let's remove it.
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.
We talked offline. The seemingly unrelated and untested changes were all responses to existing tests failing so everything should have at least indirect test coverage. Moreover, every change in this PR is actually motivated. The UI does not let me approve the PR, but I consider this approved on my end. The nits can be fixed in a follow-up.
Turning the feature "ctor of C++ foreign reference types is callable as Swift Initializers" on by default.
rdar://148285972