Skip to content

Commit 61d60eb

Browse files
authored
Merge pull request #83483 from Xazax-hun/turn-off-addressable
[cxx-interop] Move back addressability behind a flag
2 parents 670f69e + a97d330 commit 61d60eb

File tree

7 files changed

+27
-5
lines changed

7 files changed

+27
-5
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ EXPERIMENTAL_FEATURE(CoroutineAccessorsUnwindOnCallerError, false)
500500

501501
EXPERIMENTAL_FEATURE(AddressableParameters, true)
502502
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(AddressableTypes, true)
503+
EXPERIMENTAL_FEATURE(AddressableInterop, true)
503504

504505
/// Allow custom availability domains to be defined and referenced.
505506
EXPERIMENTAL_FEATURE(CustomAvailability, true)

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ static bool usesFeatureAddressableTypes(Decl *d) {
270270
return false;
271271
}
272272

273+
UNINTERESTING_FEATURE(AddressableInterop)
273274
UNINTERESTING_FEATURE(IsolatedAny2)
274275
UNINTERESTING_FEATURE(GlobalActorIsolatedTypesUsability)
275276
UNINTERESTING_FEATURE(ObjCImplementation)

lib/ClangImporter/ImportDecl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4045,7 +4045,9 @@ namespace {
40454045
func->setSelfIndex(selfIdx.value());
40464046
// FIXME: Make this work when SIL Opaque Values are enabled.
40474047
// Currently, addressable parameters and opaque values are at odds.
4048-
if (!dc->getDeclaredInterfaceType()->hasReferenceSemantics() &&
4048+
if (Impl.SwiftContext.LangOpts.hasFeature(
4049+
Feature::AddressableInterop) &&
4050+
!dc->getDeclaredInterfaceType()->hasReferenceSemantics() &&
40494051
!importedName.importAsMember() &&
40504052
!Impl.SwiftContext.SILOpts.EnableSILOpaqueValues)
40514053
func->getAttrs().add(new (Impl.SwiftContext)

lib/ClangImporter/ImportType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,8 @@ static ParamDecl *getParameterInfo(ClangImporter::Implementation *impl,
27252725
// subobject of the referenced storage. In those cases we need to prevent the
27262726
// Swift compiler to pass in a temporary copy to prevent dangling.
27272727
auto paramContext = param->getDeclContext();
2728-
if (!param->getType().isNull() && param->getType()->isLValueReferenceType() &&
2728+
if (impl->SwiftContext.LangOpts.hasFeature(Feature::AddressableInterop) &&
2729+
!param->getType().isNull() && param->getType()->isLValueReferenceType() &&
27292730
!swiftParamTy->isForeignReferenceType() &&
27302731
!(isa<clang::FunctionDecl>(paramContext) &&
27312732
cast<clang::FunctionDecl>(paramContext)->isOverloadedOperator()) &&

test/ClangImporter/cxx_interop_ir.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %target-swiftxx-frontend -module-name cxx_ir -I %S/Inputs/custom-modules -emit-ir -o - -primary-file %s -Xcc -fignore-exceptions | %FileCheck %s
1+
// RUN: %target-swiftxx-frontend -module-name cxx_ir -I %S/Inputs/custom-modules -emit-ir -o - -primary-file %s -Xcc -fignore-exceptions -enable-experimental-feature AddressableInterop | %FileCheck %s
2+
3+
// REQUIRES: swift_feature_AddressableInterop
24

35
import CXXInterop
46

test/Interop/Cxx/class/nonescapable-lifetimebound.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// RUN: rm -rf %t
22
// RUN: split-file %s %t
3-
// RUN: %target-swift-frontend -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t/Inputs -emit-sil %t/test.swift -enable-experimental-feature LifetimeDependence -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1 | %FileCheck %s
4-
// RUN: %target-swift-frontend -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t/Inputs -emit-sil %t/test.swift -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1 | %FileCheck %s
3+
// RUN: %target-swift-frontend -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t/Inputs -emit-sil %t/test.swift -enable-experimental-feature AddressableInterop -enable-experimental-feature LifetimeDependence -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1 | %FileCheck %s
4+
// RUN: %target-swift-frontend -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t/Inputs -emit-sil %t/test.swift -enable-experimental-feature AddressableInterop -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1 | %FileCheck %s
55

66
// REQUIRES: swift_feature_LifetimeDependence
7+
// REQUIRES: swift_feature_AddressableInterop
78

89
//--- Inputs/module.modulemap
910
module Test {

test/Interop/Cxx/stdlib/use-std-function.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77

88
// REQUIRES: executable_test
99

10+
// libstdc++11 declares a templated constructor of std::function with an rvalue-reference parameter,
11+
// which aren't yet supported in Swift. Therefore initializing a std::function from Swift closures
12+
// will not work on the platforms that are shipped with this version of libstdc++ (rdar://125816354).
13+
// XFAIL: LinuxDistribution=ubuntu-24.04
14+
// XFAIL: LinuxDistribution=ubuntu-22.04
15+
// XFAIL: LinuxDistribution=rhel-9.3
16+
// XFAIL: LinuxDistribution=rhel-9.4
17+
// XFAIL: LinuxDistribution=rhel-9.5
18+
// XFAIL: LinuxDistribution=rhel-9.6
19+
// XFAIL: LinuxDistribution=fedora-39
20+
// XFAIL: LinuxDistribution=fedora-41
21+
// XFAIL: LinuxDistribution=debian-12
22+
// XFAIL: LinuxDistribution=amzn-2023
23+
1024
import StdlibUnittest
1125
import StdFunction
1226
import CxxStdlib

0 commit comments

Comments
 (0)