Skip to content

Commit 9987bcf

Browse files
committed
[ClangImporter] Remove support for Swift 3 mode
Not as exciting as some of the other components, but still!
1 parent 542d442 commit 9987bcf

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
@@ -1965,7 +1965,7 @@ shouldSuppressGenericParamsImport(const LangOptions &langOpts,
19651965
return module->getTopLevelModuleName() == "Foundation";
19661966
};
19671967

1968-
if (langOpts.isSwiftVersion3() || isFromFoundationModule(decl)) {
1968+
if (isFromFoundationModule(decl)) {
19691969
// In Swift 3 we used a hardcoded list of declarations, and made all of
19701970
// their subclasses drop their generic parameters when imported.
19711971
while (decl) {
@@ -7552,41 +7552,6 @@ void ClangImporter::Implementation::importAttributes(
75527552
PlatformAgnostic, /*Implicit=*/false);
75537553

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

@@ -7717,8 +7682,7 @@ ClangImporter::Implementation::importDeclImpl(const clang::NamedDecl *ClangDecl,
77177682
}
77187683
}
77197684
if (auto method = dyn_cast<clang::ObjCMethodDecl>(ClangDecl)) {
7720-
if (!SwiftContext.LangOpts.isSwiftVersion3() &&
7721-
method->isDesignatedInitializerForTheInterface()) {
7685+
if (method->isDesignatedInitializerForTheInterface()) {
77227686
const clang::ObjCInterfaceDecl *theClass = method->getClassInterface();
77237687
assert(theClass && "cannot be a protocol method here");
77247688
// 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)