Skip to content

Commit e33001a

Browse files
authored
Merge pull request #71750 from hyp/eng/interop-6
[interop] adopt a swift-6 interoperability mode for new features in t…
2 parents 165b3e8 + 6312fc0 commit e33001a

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,8 +2190,7 @@ namespace {
21902190
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = result;
21912191

21922192
if (recordHasMoveOnlySemantics(decl)) {
2193-
if (Impl.isCxxInteropCompatVersionAtLeast(
2194-
version::getUpcomingCxxInteropCompatVersion())) {
2193+
if (Impl.isCxxInteropCompatVersionAtLeast(6)) {
21952194
if (decl->isInStdNamespace() && decl->getName() == "promise") {
21962195
// Do not import std::promise.
21972196
return nullptr;
@@ -2658,8 +2657,7 @@ namespace {
26582657
if (!decl->isBeingDefined() && !decl->isDependentContext() &&
26592658
areRecordFieldsComplete(decl)) {
26602659
if (decl->hasInheritedConstructor() &&
2661-
Impl.isCxxInteropCompatVersionAtLeast(
2662-
version::getUpcomingCxxInteropCompatVersion())) {
2660+
Impl.isCxxInteropCompatVersionAtLeast(6)) {
26632661
for (auto member : decl->decls()) {
26642662
if (auto usingDecl = dyn_cast<clang::UsingDecl>(member)) {
26652663
for (auto usingShadowDecl : usingDecl->shadows()) {
@@ -2830,8 +2828,7 @@ namespace {
28302828
void
28312829
addExplicitProtocolConformances(NominalTypeDecl *decl,
28322830
const clang::CXXRecordDecl *clangDecl) {
2833-
if (Impl.isCxxInteropCompatVersionAtLeast(
2834-
version::getUpcomingCxxInteropCompatVersion())) {
2831+
if (Impl.isCxxInteropCompatVersionAtLeast(6)) {
28352832
// Propagate conforms_to attribute from public base classes.
28362833
for (auto base : clangDecl->bases()) {
28372834
if (base.getAccessSpecifier() != clang::AccessSpecifier::AS_public)
@@ -3755,8 +3752,7 @@ namespace {
37553752
}
37563753

37573754
if (decl->isVirtual() && isa_and_nonnull<ValueDecl>(method)) {
3758-
if (Impl.isCxxInteropCompatVersionAtLeast(
3759-
version::getUpcomingCxxInteropCompatVersion())) {
3755+
if (Impl.isCxxInteropCompatVersionAtLeast(6)) {
37603756
if (auto dc = method->getDeclContext();
37613757
!decl->isPure() &&
37623758
isa_and_nonnull<NominalTypeDecl>(dc->getAsDecl())) {
@@ -4044,8 +4040,7 @@ namespace {
40444040
// 2. C++ methods from privately inherited base classes
40454041
if (!isa<clang::TypeDecl>(decl->getTargetDecl()) &&
40464042
!(isa<clang::CXXMethodDecl>(decl->getTargetDecl()) &&
4047-
Impl.isCxxInteropCompatVersionAtLeast(
4048-
version::getUpcomingCxxInteropCompatVersion())))
4043+
Impl.isCxxInteropCompatVersionAtLeast(6)))
40494044
return nullptr;
40504045
// Constructors (e.g. `using BaseClass::BaseClass`) are handled in
40514046
// VisitCXXRecordDecl, since we need them to determine whether a struct

lib/ClangImporter/ImportType.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,8 +2587,7 @@ static ParamDecl *getParameterInfo(ClangImporter::Implementation *impl,
25872587
// (https://github.com/apple/swift/issues/70124)
25882588
if (param->hasDefaultArg() && !isInOut &&
25892589
!isa<clang::CXXConstructorDecl>(param->getDeclContext()) &&
2590-
impl->isCxxInteropCompatVersionAtLeast(
2591-
version::getUpcomingCxxInteropCompatVersion()) &&
2590+
impl->isCxxInteropCompatVersionAtLeast(6) &&
25922591
impl->isDefaultArgSafeToImport(param)) {
25932592
SwiftDeclSynthesizer synthesizer(*impl);
25942593
if (CallExpr *defaultArgExpr = synthesizer.makeDefaultArgument(

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ validateCxxInteropCompatibilityMode(StringRef mode) {
499499
if (mode == "upcoming-swift")
500500
return {CxxCompatMode::enabled,
501501
version::Version({version::getUpcomingCxxInteropCompatVersion()})};
502+
if (mode == "swift-6")
503+
return {CxxCompatMode::enabled, version::Version({6})};
502504
// Swift-5.9 corresponds to the Swift 5 language mode when
503505
// Swift 5 is the default language version.
504506
if (mode == "swift-5.9")
@@ -513,7 +515,8 @@ static void diagnoseCxxInteropCompatMode(Arg *verArg, ArgList &Args,
513515
verArg->getAsString(Args), verArg->getValue());
514516

515517
// Note valid C++ interoperability modes.
516-
auto validVers = {llvm::StringRef("off"), llvm::StringRef("default")};
518+
auto validVers = {llvm::StringRef("off"), llvm::StringRef("default"),
519+
llvm::StringRef("swift-6"), llvm::StringRef("swift-5.9")};
517520
auto versStr = "'" + llvm::join(validVers, "', '") + "'";
518521
diags.diagnose(SourceLoc(), diag::valid_cxx_interop_modes, versStr);
519522
}

test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift

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

34
import VirtualMethods
45

test/Interop/Cxx/class/inheritance/virtual-methods-typechecker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=upcoming-swift
2+
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=swift-6
23

34
import VirtualMethods
45

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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 -O)
2+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6 -O)
33

44
// XFAIL: noncopyable_generics
55

0 commit comments

Comments
 (0)