Skip to content

Commit 21d147d

Browse files
committed
Revert "CxxInterop: use workaround unconditionally"
This reverts commit 1036031.
1 parent 4cf63a9 commit 21d147d

8 files changed

+25
-28
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5797,16 +5797,16 @@ cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext) {
57975797
if (auto var = dyn_cast<VarDecl>(decl)) {
57985798
auto oldContext = var->getDeclContext();
57995799
auto oldTypeDecl = oldContext->getSelfNominalTypeDecl();
5800-
// If the base type is non-copyable, we cannot synthesize the accessor,
5801-
// because its implementation would use `UnsafePointer<BaseTy>`, and that
5802-
// triggers a bug when building SwiftCompilerSources. (rdar://128013193)
5803-
//
5800+
// If the base type is non-copyable, and non-copyable generics are disabled,
5801+
// we cannot synthesize the accessor, because its implementation would use
5802+
// `UnsafePointer<BaseTy>`.
58045803
// We cannot use `ty->isNoncopyable()` here because that would create a
58055804
// cyclic dependency between ModuleQualifiedLookupRequest and
58065805
// LookupConformanceInModuleRequest, so we check for the presence of
58075806
// move-only attribute that is implicitly added to non-copyable C++ types by
58085807
// ClangImporter.
5809-
if (oldTypeDecl->getAttrs().hasAttribute<MoveOnlyAttr>())
5808+
if (oldTypeDecl->getAttrs().hasAttribute<MoveOnlyAttr>() &&
5809+
!context.LangOpts.hasFeature(Feature::NoncopyableGenerics))
58105810
return nullptr;
58115811

58125812
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,10 +509,8 @@ namespace {
509509
return importFunctionPointerLikeType(*type, pointeeType);
510510
}
511511

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-
//
512+
// If non-copyable generics are disabled, we cannot specify
513+
// UnsafePointer<T> with a non-copyable type T.
516514
// We cannot use `ty->isNoncopyable()` here because that would create a
517515
// cyclic dependency between ModuleQualifiedLookupRequest and
518516
// LookupConformanceInModuleRequest, so we check for the presence of
@@ -521,7 +519,9 @@ namespace {
521519
if (pointeeType && pointeeType->getAnyNominal() &&
522520
pointeeType->getAnyNominal()
523521
->getAttrs()
524-
.hasAttribute<MoveOnlyAttr>()) {
522+
.hasAttribute<MoveOnlyAttr>() &&
523+
!Impl.SwiftContext.LangOpts.hasFeature(
524+
Feature::NoncopyableGenerics)) {
525525
auto opaquePointerDecl = Impl.SwiftContext.getOpaquePointerDecl();
526526
if (!opaquePointerDecl)
527527
return Type();

test/Interop/Cxx/class/move-only/inherited-field-access-irgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-swift-emit-irgen -I %S/Inputs -cxx-interoperability-mode=swift-6 %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
22
// RUN: %target-swift-emit-irgen -I %S/Inputs -cxx-interoperability-mode=upcoming-swift %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
33

4-
// REQUIRES: rdar128013193
5-
64
import MoveOnlyCxxValueType
75

86
func testGetX() -> CInt {

test/Interop/Cxx/class/move-only/inherited-field-access-silgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-swift-emit-sil -I %S/Inputs -cxx-interoperability-mode=swift-6 %s -validate-tbd-against-ir=none | %FileCheck %s
22
// RUN: %target-swift-emit-sil -I %S/Inputs -cxx-interoperability-mode=upcoming-swift %s -validate-tbd-against-ir=none | %FileCheck %s
33

4-
// REQUIRES: rdar128013193
5-
64
import MoveOnlyCxxValueType
75

86
func testGetX() -> CInt {

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)
2-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O -Xfrontend -sil-verify-none)
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)
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
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
23

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

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

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift)
2-
// -- FIXME: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -D HAS_RDAR_128013193)
2+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
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)
56

67
// REQUIRES: executable_test
78

@@ -28,7 +29,7 @@ MoveOnlyCxxValueType.test("Test derived move only type member access") {
2829
var k = c.method(-3)
2930
expectEqual(k, -6)
3031
expectEqual(c.method(1), 2)
31-
#if HAS_RDAR_128013193
32+
#if HAS_NONCOPYABLE_GENERICS
3233
k = c.x
3334
expectEqual(k, 2)
3435
c.x = 11
@@ -59,7 +60,7 @@ MoveOnlyCxxValueType.test("Test move only field access in holder") {
5960
expectEqual(c.x.x, 5)
6061
}
6162

62-
#if HAS_RDAR_128013193
63+
#if HAS_NONCOPYABLE_GENERICS
6364
MoveOnlyCxxValueType.test("Test move only field access in derived holder") {
6465
var c = NonCopyableHolderDerivedDerived(-11)
6566
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-
// -- FIXME: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -D HAS_RDAR_128013193)
4+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
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-
// -- FIXME: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O -D HAS_RDAR_128013193)
8+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
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_RDAR_128013193
95+
#if HAS_NONCOPYABLE_GENERICS
9696
MoveOnlyCxxOperators.test("NonCopyableHolderConstDerefDerivedDerived pointee borrow") {
9797
let holder = NonCopyableHolderConstDerefDerivedDerived(11)
9898
var k = borrowNC(holder.pointee)

0 commit comments

Comments
 (0)