Skip to content

Commit d10a31d

Browse files
committed
CxxInterop: use workaround unconditionally
We haven't yet solved the underlying issue in rdar://128013193 and the workaround to make it conditionally use the better importing strategy of Unsafe{Mutable}Pointer no longer will apply, since NoncopyableGenerics is here. (cherry picked from commit be46fe4)
1 parent 8369262 commit d10a31d

File tree

6 files changed

+24
-25
lines changed

6 files changed

+24
-25
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5778,16 +5778,16 @@ cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext) {
57785778
if (auto var = dyn_cast<VarDecl>(decl)) {
57795779
auto oldContext = var->getDeclContext();
57805780
auto oldTypeDecl = oldContext->getSelfNominalTypeDecl();
5781-
// If the base type is non-copyable, and non-copyable generics are disabled,
5782-
// we cannot synthesize the accessor, because its implementation would use
5783-
// `UnsafePointer<BaseTy>`.
5781+
// If the base type is non-copyable, we cannot synthesize the accessor,
5782+
// because its implementation would use `UnsafePointer<BaseTy>`, and that
5783+
// triggers a bug when building SwiftCompilerSources. (rdar://128013193)
5784+
//
57845785
// We cannot use `ty->isNoncopyable()` here because that would create a
57855786
// cyclic dependency between ModuleQualifiedLookupRequest and
57865787
// LookupConformanceInModuleRequest, so we check for the presence of
57875788
// move-only attribute that is implicitly added to non-copyable C++ types by
57885789
// ClangImporter.
5789-
if (oldTypeDecl->getAttrs().hasAttribute<MoveOnlyAttr>() &&
5790-
!context.LangOpts.hasFeature(Feature::NoncopyableGenerics))
5790+
if (oldTypeDecl->getAttrs().hasAttribute<MoveOnlyAttr>())
57915791
return nullptr;
57925792

57935793
auto rawMemory = allocateMemoryForDecl<VarDecl>(var->getASTContext(),

lib/ClangImporter/ImportType.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,10 @@ namespace {
509509
return importFunctionPointerLikeType(*type, pointeeType);
510510
}
511511

512-
// If non-copyable generics are disabled, we cannot specify
513-
// UnsafePointer<T> with a non-copyable type T.
512+
// We cannot specify UnsafePointer<T> with a non-copyable type T just yet,
513+
// because it triggers a bug when building SwiftCompilerSources.
514+
// (rdar://128013193)
515+
//
514516
// We cannot use `ty->isNoncopyable()` here because that would create a
515517
// cyclic dependency between ModuleQualifiedLookupRequest and
516518
// LookupConformanceInModuleRequest, so we check for the presence of
@@ -519,9 +521,7 @@ namespace {
519521
if (pointeeType && pointeeType->getAnyNominal() &&
520522
pointeeType->getAnyNominal()
521523
->getAttrs()
522-
.hasAttribute<MoveOnlyAttr>() &&
523-
!Impl.SwiftContext.LangOpts.hasFeature(
524-
Feature::NoncopyableGenerics)) {
524+
.hasAttribute<MoveOnlyAttr>()) {
525525
auto opaquePointerDecl = Impl.SwiftContext.getOpaquePointerDecl();
526526
if (!opaquePointerDecl)
527527
return Type();

test/Interop/Cxx/class/move-only/move-only-cxx-value-type-generics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics)
2-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics -O -Xfrontend -sil-verify-none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift)
2+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O -Xfrontend -sil-verify-none)
33
//
44
// REQUIRES: executable_test
55
// REQUIRES: GH_ISSUE_70246
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %target-swift-ide-test -print-module -module-to-print=MoveOnlyCxxValueType -I %S/Inputs -cxx-interoperability-mode=upcoming-swift -source-filename=x | %FileCheck %s --check-prefix=CHECK-NO-NCG
2-
// RUN: %target-swift-ide-test -print-module -module-to-print=MoveOnlyCxxValueType -I %S/Inputs -cxx-interoperability-mode=upcoming-swift -source-filename=x -enable-experimental-feature NoncopyableGenerics | %FileCheck %s --check-prefix=CHECK-NCG
1+
// RUN: %target-swift-ide-test -print-module -module-to-print=MoveOnlyCxxValueType -I %S/Inputs -cxx-interoperability-mode=upcoming-swift -source-filename=x | %FileCheck %s --check-prefix=CHECK
32

4-
// CHECK-NO-NCG: func getNonCopyablePtr() -> OpaquePointer
5-
// CHECK-NO-NCG: func getNonCopyableDerivedPtr() -> OpaquePointer
3+
// CHECK: func getNonCopyablePtr() -> OpaquePointer
4+
// CHECK: func getNonCopyableDerivedPtr() -> OpaquePointer
65

7-
// CHECK-NCG: func getNonCopyablePtr() -> UnsafeMutablePointer<NonCopyable>
8-
// CHECK-NCG: func getNonCopyableDerivedPtr() -> UnsafeMutablePointer<NonCopyableDerived>
6+
// FIXME: would prefer to have this (rdar://128013193)
7+
// func getNonCopyablePtr() -> UnsafeMutablePointer<NonCopyable>
8+
// func getNonCopyableDerivedPtr() -> UnsafeMutablePointer<NonCopyableDerived>

test/Interop/Cxx/class/move-only/move-only-cxx-value-type.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift)
2-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
2+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -D HAS_RDAR_128013193)
33
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-5.9 -O)
44
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6 -O)
5-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6 -O -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
65

76
// REQUIRES: executable_test
87

@@ -29,7 +28,7 @@ MoveOnlyCxxValueType.test("Test derived move only type member access") {
2928
var k = c.method(-3)
3029
expectEqual(k, -6)
3130
expectEqual(c.method(1), 2)
32-
#if HAS_NONCOPYABLE_GENERICS
31+
#if HAS_RDAR_128013193
3332
k = c.x
3433
expectEqual(k, 2)
3534
c.x = 11
@@ -60,7 +59,7 @@ MoveOnlyCxxValueType.test("Test move only field access in holder") {
6059
expectEqual(c.x.x, 5)
6160
}
6261

63-
#if HAS_NONCOPYABLE_GENERICS
62+
#if HAS_RDAR_128013193
6463
MoveOnlyCxxValueType.test("Test move only field access in derived holder") {
6564
var c = NonCopyableHolderDerivedDerived(-11)
6665
var k = borrowNC(c.x)

test/Interop/Cxx/operators/move-only/move-only-synthesized-properties.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-5.9)
22
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6)
33
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift)
4-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
4+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -D HAS_RDAR_128013193)
55
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-5.9 -O)
66
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6 -O)
77
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O)
8-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
8+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O -D HAS_RDAR_128013193)
99
//
1010
// REQUIRES: executable_test
1111

@@ -92,7 +92,7 @@ MoveOnlyCxxOperators.test("testNonCopyableHolderValueMutDeref pointee value") {
9292
expectEqual(k.x, k2.x)
9393
}
9494

95-
#if HAS_NONCOPYABLE_GENERICS
95+
#if HAS_RDAR_128013193
9696
MoveOnlyCxxOperators.test("NonCopyableHolderConstDerefDerivedDerived pointee borrow") {
9797
let holder = NonCopyableHolderConstDerefDerivedDerived(11)
9898
var k = borrowNC(holder.pointee)

0 commit comments

Comments
 (0)