From 1272cd3aace9aebbd1bc402ef3c8dff771520e0f Mon Sep 17 00:00:00 2001 From: Ewa Matejska Date: Thu, 17 Aug 2017 20:57:01 -0700 Subject: [PATCH 1/3] Making master call itself 4.1, updating the swift 3 compatiblity mode to be 3.3 (from 3.2), adding ability to pass swift-version 5. Importer work not done yet. --- CMakeLists.txt | 2 +- docs/Testing.md | 2 +- include/swift/AST/ASTContext.h | 6 ++++++ include/swift/Basic/LangOptions.h | 10 ++++++++++ include/swift/Basic/Version.h | 10 ++++++++-- lib/Basic/Version.cpp | 6 ++++-- lib/ClangImporter/ImportName.cpp | 2 ++ test/Driver/swift-version-default.swift | 4 ++-- test/Driver/swift-version.swift | 15 ++++++++++++--- .../language_version_explicit.swift | 4 ++-- test/Serialization/Recovery/crash-recovery.swift | 2 +- test/Serialization/Recovery/types-4-to-3.swift | 4 ++-- 12 files changed, 51 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0306ccb76c19..3a4bb3a033637 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,7 @@ set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY # SWIFT_VERSION is deliberately /not/ cached so that an existing build directory # can be reused when a new version of Swift comes out (assuming the user hasn't # manually set it as part of their own CMake configuration). -set(SWIFT_VERSION "4.0") +set(SWIFT_VERSION "4.1") set(SWIFT_VENDOR "" CACHE STRING "The vendor name of the Swift compiler") diff --git a/docs/Testing.md b/docs/Testing.md index 15af92e7a602b..b417eb4124b7d 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -419,7 +419,7 @@ FIXME: full list. * ``optimized_stdlib_``: an optimized stdlib plus cpu configuration. -* ``SWIFT_VERSION=``: restricts a test to Swift 3 or Swift 4. If you +* ``SWIFT_VERSION=``: restricts a test to Swift 3, Swift 4, Swift 5. If you need to use this, make sure to add a test for the other version as well unless you are specifically testing ``-swift-version``-related functionality. diff --git a/include/swift/AST/ASTContext.h b/include/swift/AST/ASTContext.h index 58b94d37cfe02..024f007dbe25c 100644 --- a/include/swift/AST/ASTContext.h +++ b/include/swift/AST/ASTContext.h @@ -865,6 +865,12 @@ class ASTContext { /// Whether our effective Swift version is in the Swift 3 family bool isSwiftVersion3() const { return LangOpts.isSwiftVersion3(); } + + /// Whether our effective Swift version is in the Swift 4 family + bool isSwiftVersion4() const { return LangOpts.isSwiftVersion4(); } + + /// Whether our effective Swift version is in the Swift 5 family + bool isSwiftVersion5() const { return LangOpts.isSwiftVersion5(); } private: friend Decl; diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index 36a81bf8f7f97..b097894e7ba55 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -310,6 +310,16 @@ namespace swift { bool isSwiftVersion3() const { return EffectiveLanguageVersion.isVersion3(); } + + /// Whether our effective Swift version is in the Swift 4 family + bool isSwiftVersion4() const { + return EffectiveLanguageVersion.isVersion4(); + } + + /// Whether our effective Swift version is in the Swift 5 family + bool isSwiftVersion5() const { + return EffectiveLanguageVersion.isVersion5(); + } /// Returns true if the given platform condition argument represents /// a supported target operating system. diff --git a/include/swift/Basic/Version.h b/include/swift/Basic/Version.h index 8bcaf02083625..4e0cc50d1e4a8 100644 --- a/include/swift/Basic/Version.h +++ b/include/swift/Basic/Version.h @@ -109,6 +109,12 @@ class Version { /// Whether this version is in the Swift 3 family bool isVersion3() const { return !empty() && Components[0] == 3; } + + /// Whether this version is in the Swift 4 family + bool isVersion4() const { return !empty() && Components[0] == 4; } + + /// Whether this version is in the Swift 5 family + bool isVersion5() const { return !empty() && Components[0] == 5; } /// Return this Version struct with minor and sub-minor components stripped Version asMajorVersion() const; @@ -137,8 +143,8 @@ class Version { // Whitelist of backward-compatibility versions that we permit passing as // -swift-version - static std::array getValidEffectiveVersions() { - return {{"3", "4"}}; + static std::array getValidEffectiveVersions() { + return {{"3", "4", "5"}}; }; }; diff --git a/lib/Basic/Version.cpp b/lib/Basic/Version.cpp index f99ce28659d70..e363a303a81b3 100644 --- a/lib/Basic/Version.cpp +++ b/lib/Basic/Version.cpp @@ -319,14 +319,16 @@ Optional Version::getEffectiveLanguageVersion() const { switch (Components[0]) { case 3: #ifdef SWIFT_VERSION_PATCHLEVEL - return Version{3, 2, SWIFT_VERSION_PATCHLEVEL}; + return Version{3, 3, SWIFT_VERSION_PATCHLEVEL}; #else - return Version{3, 2}; + return Version{3, 3}; #endif case 4: static_assert(SWIFT_VERSION_MAJOR == 4, "getCurrentLanguageVersion is no longer correct here"); return Version::getCurrentLanguageVersion(); + case 5: + return Version{5, 0}; default: return None; } diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp index 97a8dcfdf815a..b7a4adb14c186 100644 --- a/lib/ClangImporter/ImportName.cpp +++ b/lib/ClangImporter/ImportName.cpp @@ -65,7 +65,9 @@ importer::nameVersionFromOptions(const LangOptions &langOpts) { return ImportNameVersion::Swift2; case 3: return ImportNameVersion::Swift3; + // Fixme: Figure out the importing story for 5 instead of falling back to 4. case 4: + case 5: return ImportNameVersion::Swift4; } } diff --git a/test/Driver/swift-version-default.swift b/test/Driver/swift-version-default.swift index 4db2b19129c50..32fe7f663ec8b 100644 --- a/test/Driver/swift-version-default.swift +++ b/test/Driver/swift-version-default.swift @@ -24,9 +24,9 @@ htn #endif #if swift(>=4.1) -aoeu +aoeu // expected-error {{use of unresolved identifier}} #else -htn // expected-error {{use of unresolved identifier}} +htn #endif #if swift(>=5) diff --git a/test/Driver/swift-version.swift b/test/Driver/swift-version.swift index 129a2beb309d7..31ed2b48a7518 100644 --- a/test/Driver/swift-version.swift +++ b/test/Driver/swift-version.swift @@ -7,21 +7,25 @@ // RUN: not %target-swiftc_driver -swift-version 3.0 %s 2>&1 | %FileCheck --check-prefix FIXIT_3 %s // RUN: not %target-swiftc_driver -swift-version 3.3 %s 2>&1 | %FileCheck --check-prefix FIXIT_3 %s // RUN: not %target-swiftc_driver -swift-version 4.3 %s 2>&1 | %FileCheck --check-prefix FIXIT_4 %s +// RUN: not %target-swiftc_driver -swift-version 5.1 %s 2>&1 | %FileCheck --check-prefix FIXIT_5 %s // RUN: not %target-swiftc_driver -swift-version 3 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_3 %s // RUN: not %target-swiftc_driver -swift-version 4 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_4 %s +// RUN: not %target-swiftc_driver -swift-version 5 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_5 %s // BAD: invalid value -// BAD: note: valid arguments to '-swift-version' are '3', '4' +// BAD: note: valid arguments to '-swift-version' are '3', '4', '5' // FIXIT_3: use major version, as in '-swift-version 3' // FIXIT_4: use major version, as in '-swift-version 4' +// FIXIT_5: use major version, as in '-swift-version 5' #if swift(>=3) asdf // ERROR_3: [[@LINE-1]]:1: error: {{use of unresolved identifier}} // ERROR_4: [[@LINE-2]]:1: error: {{use of unresolved identifier}} +// ERROR_5: [[@LINE-3]]:1: error: {{use of unresolved identifier}} #else jkl #endif @@ -30,26 +34,31 @@ jkl asdf // ERROR_3: [[@LINE-1]]:1: error: {{use of unresolved identifier}} // ERROR_4: [[@LINE-2]]:1: error: {{use of unresolved identifier}} +// ERROR_5: [[@LINE-3]]:1: error: {{use of unresolved identifier}} #else jkl #endif #if swift(>=4) -asdf // ERROR_4: [[@LINE]]:1: error: {{use of unresolved identifier}} +asdf +// ERROR_4: [[@LINE-1]]:1: error: {{use of unresolved identifier}} +// ERROR_5: [[@LINE-2]]:1: error: {{use of unresolved identifier}} #else jkl // ERROR_3: [[@LINE]]:1: error: {{use of unresolved identifier}} #endif #if swift(>=4.1) asdf +// ERROR_4: [[@LINE-1]]:1: error: {{use of unresolved identifier}} +// ERROR_5: [[@LINE-2]]:1: error: {{use of unresolved identifier}} #else jkl // ERROR_3: [[@LINE-1]]:1: error: {{use of unresolved identifier}} -// ERROR_4: [[@LINE-2]]:1: error: {{use of unresolved identifier}} #endif #if swift(>=5) asdf +// ERROR_5: [[@LINE-1]]:1: error: {{use of unresolved identifier}} #else jkl // ERROR_3: [[@LINE-1]]:1: error: {{use of unresolved identifier}} diff --git a/test/Parse/ConditionalCompilation/language_version_explicit.swift b/test/Parse/ConditionalCompilation/language_version_explicit.swift index 81e0eaad35a27..5baef8ad9f3d4 100644 --- a/test/Parse/ConditionalCompilation/language_version_explicit.swift +++ b/test/Parse/ConditionalCompilation/language_version_explicit.swift @@ -22,9 +22,9 @@ #endif #if swift(>=4.0.1) + let z = 1 +#else // This shouldn't emit any diagnostics. asdf asdf asdf asdf -#else - let z = 1 #endif diff --git a/test/Serialization/Recovery/crash-recovery.swift b/test/Serialization/Recovery/crash-recovery.swift index 733375ad471fa..aecd4d26e3b3a 100644 --- a/test/Serialization/Recovery/crash-recovery.swift +++ b/test/Serialization/Recovery/crash-recovery.swift @@ -14,7 +14,7 @@ public class Sub: Base { // CHECK-CRASH: error: fatal error encountered while reading from module 'Lib'; please file a bug report with your project and the crash log // CHECK-CRASH-3-NOT: note -// CHECK-CRASH-4: note: compiling as Swift 4.0, with 'Lib' built as Swift 3.2 +// CHECK-CRASH-4: note: compiling as Swift 4.1, with 'Lib' built as Swift 3.3 // CHECK-CRASH-LABEL: *** DESERIALIZATION FAILURE (please include this section in any bug report) *** // CHECK-CRASH: could not find 'disappearingMethod()' in parent class // CHECK-CRASH: While loading members for 'Sub' in module 'Lib' diff --git a/test/Serialization/Recovery/types-4-to-3.swift b/test/Serialization/Recovery/types-4-to-3.swift index ca540c1b3812e..380c3d097977a 100644 --- a/test/Serialization/Recovery/types-4-to-3.swift +++ b/test/Serialization/Recovery/types-4-to-3.swift @@ -16,8 +16,8 @@ import Lib func requiresConformance(_: B_RequiresConformance) {} func requiresConformance(_: B_RequiresConformance) {} -class Sub: Base {} // expected-error {{cannot inherit from class 'Base' (compiled with Swift 4.0) because it has overridable members that could not be loaded in Swift 3.2}} -class Impl: Proto {} // expected-error {{type 'Impl' cannot conform to protocol 'Proto' (compiled with Swift 4.0) because it has requirements that could not be loaded in Swift 3.2}} +class Sub: Base {} // expected-error {{cannot inherit from class 'Base' (compiled with Swift 4.1) because it has overridable members that could not be loaded in Swift 3.3}} +class Impl: Proto {} // expected-error {{type 'Impl' cannot conform to protocol 'Proto' (compiled with Swift 4.1) because it has requirements that could not be loaded in Swift 3.3}} #else // TEST From 93786d8e264d095256169a6a2552970ea785036f Mon Sep 17 00:00:00 2001 From: Ewa Matejska Date: Fri, 18 Aug 2017 13:51:59 -0700 Subject: [PATCH 2/3] Removing isSwiftVersion4, isSwiftVersion5. We'll need to come up with a better way to conditionalize code based on language version. --- include/swift/AST/ASTContext.h | 6 ------ include/swift/Basic/LangOptions.h | 10 ---------- include/swift/Basic/Version.h | 6 ------ 3 files changed, 22 deletions(-) diff --git a/include/swift/AST/ASTContext.h b/include/swift/AST/ASTContext.h index 024f007dbe25c..58b94d37cfe02 100644 --- a/include/swift/AST/ASTContext.h +++ b/include/swift/AST/ASTContext.h @@ -865,12 +865,6 @@ class ASTContext { /// Whether our effective Swift version is in the Swift 3 family bool isSwiftVersion3() const { return LangOpts.isSwiftVersion3(); } - - /// Whether our effective Swift version is in the Swift 4 family - bool isSwiftVersion4() const { return LangOpts.isSwiftVersion4(); } - - /// Whether our effective Swift version is in the Swift 5 family - bool isSwiftVersion5() const { return LangOpts.isSwiftVersion5(); } private: friend Decl; diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index b097894e7ba55..36a81bf8f7f97 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -310,16 +310,6 @@ namespace swift { bool isSwiftVersion3() const { return EffectiveLanguageVersion.isVersion3(); } - - /// Whether our effective Swift version is in the Swift 4 family - bool isSwiftVersion4() const { - return EffectiveLanguageVersion.isVersion4(); - } - - /// Whether our effective Swift version is in the Swift 5 family - bool isSwiftVersion5() const { - return EffectiveLanguageVersion.isVersion5(); - } /// Returns true if the given platform condition argument represents /// a supported target operating system. diff --git a/include/swift/Basic/Version.h b/include/swift/Basic/Version.h index 4e0cc50d1e4a8..1519536896e81 100644 --- a/include/swift/Basic/Version.h +++ b/include/swift/Basic/Version.h @@ -109,12 +109,6 @@ class Version { /// Whether this version is in the Swift 3 family bool isVersion3() const { return !empty() && Components[0] == 3; } - - /// Whether this version is in the Swift 4 family - bool isVersion4() const { return !empty() && Components[0] == 4; } - - /// Whether this version is in the Swift 5 family - bool isVersion5() const { return !empty() && Components[0] == 5; } /// Return this Version struct with minor and sub-minor components stripped Version asMajorVersion() const; From fcc515b8f0333669a4e582fa5950758b9034d48f Mon Sep 17 00:00:00 2001 From: Ewa Matejska Date: Fri, 18 Aug 2017 15:41:06 -0700 Subject: [PATCH 3/3] Bump default version in buid script --- utils/build-script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build-script b/utils/build-script index 515728526e816..be142150a7ebd 100755 --- a/utils/build-script +++ b/utils/build-script @@ -2072,7 +2072,7 @@ iterations with -O", "--swift-user-visible-version", help="User-visible version of the embedded Swift compiler", type=arguments.type.swift_compiler_version, - default="4.0", + default="4.1", metavar="MAJOR.MINOR") parser.add_argument(