Skip to content

Commit 986e093

Browse files
authored
[ClangImporter] Remove support for Swift 3 mode (#17722)
Not as exciting as some of the other components, but still!
1 parent c997080 commit 986e093

File tree

5 files changed

+8
-66
lines changed

5 files changed

+8
-66
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ shouldSuppressGenericParamsImport(const LangOptions &langOpts,
19621962
return module->getTopLevelModuleName() == "Foundation";
19631963
};
19641964

1965-
if (langOpts.isSwiftVersion3() || isFromFoundationModule(decl)) {
1965+
if (isFromFoundationModule(decl)) {
19661966
// In Swift 3 we used a hardcoded list of declarations, and made all of
19671967
// their subclasses drop their generic parameters when imported.
19681968
while (decl) {
@@ -7558,41 +7558,6 @@ void ClangImporter::Implementation::importAttributes(
75587558
PlatformAgnostic, /*Implicit=*/false);
75597559

75607560
MappedDecl->getAttrs().add(AvAttr);
7561-
7562-
// For enum cases introduced in the 2017 SDKs, add
7563-
// @_downgrade_exhaustivity_check in Swift 3.
7564-
if (C.LangOpts.isSwiftVersion3() && isa<EnumElementDecl>(MappedDecl)) {
7565-
bool downgradeExhaustivity = false;
7566-
switch (*platformK) {
7567-
case PlatformKind::OSX:
7568-
case PlatformKind::OSXApplicationExtension:
7569-
downgradeExhaustivity = (introduced.getMajor() == 10 &&
7570-
introduced.getMinor() &&
7571-
*introduced.getMinor() == 13);
7572-
break;
7573-
7574-
case PlatformKind::iOS:
7575-
case PlatformKind::iOSApplicationExtension:
7576-
case PlatformKind::tvOS:
7577-
case PlatformKind::tvOSApplicationExtension:
7578-
downgradeExhaustivity = (introduced.getMajor() == 11);
7579-
break;
7580-
7581-
case PlatformKind::watchOS:
7582-
case PlatformKind::watchOSApplicationExtension:
7583-
downgradeExhaustivity = (introduced.getMajor() == 4);
7584-
break;
7585-
7586-
case PlatformKind::none:
7587-
break;
7588-
}
7589-
7590-
if (downgradeExhaustivity) {
7591-
auto attr =
7592-
new (C) DowngradeExhaustivityCheckAttr(/*isImplicit=*/true);
7593-
MappedDecl->getAttrs().add(attr);
7594-
}
7595-
}
75967561
}
75977562
}
75987563

@@ -7723,8 +7688,7 @@ ClangImporter::Implementation::importDeclImpl(const clang::NamedDecl *ClangDecl,
77237688
}
77247689
}
77257690
if (auto method = dyn_cast<clang::ObjCMethodDecl>(ClangDecl)) {
7726-
if (!SwiftContext.LangOpts.isSwiftVersion3() &&
7727-
method->isDesignatedInitializerForTheInterface()) {
7691+
if (method->isDesignatedInitializerForTheInterface()) {
77287692
const clang::ObjCInterfaceDecl *theClass = method->getClassInterface();
77297693
assert(theClass && "cannot be a protocol method here");
77307694
// Only allow this to affect declarations in the same top-level module

lib/ClangImporter/ImportType.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -884,10 +884,7 @@ namespace {
884884
}
885885
importedTypeArg = subresult.AbstractType;
886886
} else if (typeParam->getSuperclass() &&
887-
(Impl.SwiftContext.isSwiftVersion3() ||
888-
typeParam->getConformingProtocols().empty())) {
889-
// In Swift 3 mode, discard the protocol bounds if there is
890-
// a superclass bound.
887+
typeParam->getConformingProtocols().empty()) {
891888
importedTypeArg = typeParam->getSuperclass();
892889
} else {
893890
SmallVector<Type, 4> memberTypes;
@@ -1039,10 +1036,7 @@ namespace {
10391036
}
10401037
}
10411038

1042-
// Swift 3 compatibility -- don't import subclass existentials
1043-
if (!type->qual_empty() &&
1044-
(importedType->isAnyObject() ||
1045-
!Impl.SwiftContext.isSwiftVersion3())) {
1039+
if (!type->qual_empty()) {
10461040
SmallVector<Type, 4> members;
10471041
if (!importedType->isAnyObject())
10481042
members.push_back(importedType);
@@ -1555,23 +1549,7 @@ ImportedType ClangImporter::Implementation::importFunctionReturnType(
15551549
bool allowNSUIntegerAsInt) {
15561550

15571551
// Hardcode handling of certain result types for builtins.
1558-
auto builtinID = clangDecl->getBuiltinID();
1559-
switch (builtinID) {
1560-
case clang::Builtin::NotBuiltin:
1561-
break;
1562-
case clang::Builtin::BIstrxfrm:
1563-
case clang::Builtin::BIstrcspn:
1564-
case clang::Builtin::BIstrspn:
1565-
case clang::Builtin::BIstrlen:
1566-
case clang::Builtin::BIstrlcpy:
1567-
case clang::Builtin::BIstrlcat:
1568-
// This is a list of all built-ins with a result type of 'size_t' that
1569-
// existed in Swift 3. We didn't have special handling for builtins at
1570-
// that time, and so these had a result type of UInt.
1571-
if (SwiftContext.isSwiftVersion3())
1572-
break;
1573-
LLVM_FALLTHROUGH;
1574-
default:
1552+
if (auto builtinID = clangDecl->getBuiltinID()) {
15751553
switch (getClangASTContext().BuiltinInfo.getTypeString(builtinID)[0]) {
15761554
case 'z': // size_t
15771555
case 'Y': // ptrdiff_t

test/ClangImporter/availability_open_enums.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules -swift-version 4 -enable-nonfrozen-enum-exhaustivity-diagnostics %s
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules -enable-nonfrozen-enum-exhaustivity-diagnostics %s
22

33
// REQUIRES: objc_interop
44

test/ClangImporter/clang_builtins.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not %target-swift-frontend -swift-version 4 -typecheck %s 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-%target-runtime %s
1+
// RUN: not %target-swift-frontend -typecheck %s 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-%target-runtime %s
22

33
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
44
import Darwin

test/ClangImporter/subclass_existentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -o - -primary-file %s -swift-version 4 -I %S/Inputs/custom-modules/
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -o - -primary-file %s -I %S/Inputs/custom-modules/
22

33
// REQUIRES: objc_interop
44

0 commit comments

Comments
 (0)