From 1bd3b915f4079091fdc2d083aef9c9c95b93573b Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Tue, 19 Sep 2023 16:03:30 +0200 Subject: [PATCH] Swift: upgrade to 5.9 --- .../decl/ModuleDecl/ModuleDecl.expected | 4 +- .../ModuleDecl_getAnImportedModule.expected | 2 + .../MethodLookupExpr_getMember.expected | 4 +- .../MethodLookupExpr_getType.expected | 2 +- .../MethodLookupExpr/method_lookups.swift | 2 +- .../test/library-tests/ast/PrintAst.expected | 74 +++++++++---------- .../controlflow/graph/Cfg.expected | 5 +- .../expr/methodlookup/PrintAst.expected | 1 - .../expr/methodlookup/methodlookup.swift | 2 +- swift/third_party/load.bzl | 12 +-- .../patches/remove-result-of.patch | 30 -------- 11 files changed, 50 insertions(+), 88 deletions(-) delete mode 100644 swift/third_party/swift-llvm-support/patches/remove-result-of.patch diff --git a/swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl.expected b/swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl.expected index dbbc1c70157e..37ee373dc835 100644 --- a/swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl.expected +++ b/swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl.expected @@ -1,3 +1,3 @@ -| file://:0:0:0:0 | Foo | getModule: | file://:0:0:0:0 | Foo | getNumberOfMembers: | 0 | getInterfaceType: | module | getName: | Foo | getNumberOfInheritedTypes: | 0 | isBuiltinModule: | no | isSystemModule: | no | getNumberOfImportedModules: | 4 | getNumberOfExportedModules: | 1 | +| file://:0:0:0:0 | Foo | getModule: | file://:0:0:0:0 | Foo | getNumberOfMembers: | 0 | getInterfaceType: | module | getName: | Foo | getNumberOfInheritedTypes: | 0 | isBuiltinModule: | no | isSystemModule: | no | getNumberOfImportedModules: | 5 | getNumberOfExportedModules: | 1 | | file://:0:0:0:0 | __ObjC | getModule: | file://:0:0:0:0 | __ObjC | getNumberOfMembers: | 0 | getInterfaceType: | module<__ObjC> | getName: | __ObjC | getNumberOfInheritedTypes: | 0 | isBuiltinModule: | no | isSystemModule: | no | getNumberOfImportedModules: | 1 | getNumberOfExportedModules: | 0 | -| file://:0:0:0:0 | default_module_name | getModule: | file://:0:0:0:0 | default_module_name | getNumberOfMembers: | 0 | getInterfaceType: | module | getName: | default_module_name | getNumberOfInheritedTypes: | 0 | isBuiltinModule: | no | isSystemModule: | no | getNumberOfImportedModules: | 4 | getNumberOfExportedModules: | 0 | +| file://:0:0:0:0 | default_module_name | getModule: | file://:0:0:0:0 | default_module_name | getNumberOfMembers: | 0 | getInterfaceType: | module | getName: | default_module_name | getNumberOfInheritedTypes: | 0 | isBuiltinModule: | no | isSystemModule: | no | getNumberOfImportedModules: | 5 | getNumberOfExportedModules: | 0 | diff --git a/swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl_getAnImportedModule.expected b/swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl_getAnImportedModule.expected index c711cd8b9132..57f89e195bce 100644 --- a/swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl_getAnImportedModule.expected +++ b/swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl_getAnImportedModule.expected @@ -2,8 +2,10 @@ | file://:0:0:0:0 | Foo | file://:0:0:0:0 | SwiftOnoneSupport | | file://:0:0:0:0 | Foo | file://:0:0:0:0 | _Concurrency | | file://:0:0:0:0 | Foo | file://:0:0:0:0 | _StringProcessing | +| file://:0:0:0:0 | Foo | file://:0:0:0:0 | _SwiftConcurrencyShims | | file://:0:0:0:0 | __ObjC | file://:0:0:0:0 | Swift | | file://:0:0:0:0 | default_module_name | file://:0:0:0:0 | Swift | | file://:0:0:0:0 | default_module_name | file://:0:0:0:0 | SwiftOnoneSupport | | file://:0:0:0:0 | default_module_name | file://:0:0:0:0 | _Concurrency | | file://:0:0:0:0 | default_module_name | file://:0:0:0:0 | _StringProcessing | +| file://:0:0:0:0 | default_module_name | file://:0:0:0:0 | _SwiftConcurrencyShims | diff --git a/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/MethodLookupExpr_getMember.expected b/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/MethodLookupExpr_getMember.expected index 0b599fe3fe32..a272e0da941f 100644 --- a/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/MethodLookupExpr_getMember.expected +++ b/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/MethodLookupExpr_getMember.expected @@ -16,9 +16,9 @@ | method_lookups.swift:44:11:44:13 | .foo(_:_:) | method_lookups.swift:12:3:12:35 | foo(_:_:) | | method_lookups.swift:47:1:47:1 | Task.init(priority:operation:) | file://:0:0:0:0 | Task.init(priority:operation:) | | method_lookups.swift:48:9:48:11 | .foo(_:_:) | method_lookups.swift:22:3:22:35 | foo(_:_:) | -| method_lookups.swift:49:9:49:11 | .bar() | method_lookups.swift:23:3:23:21 | bar() | +| method_lookups.swift:49:9:49:11 | .bar() | method_lookups.swift:23:15:23:33 | bar() | | method_lookups.swift:50:9:50:9 | Z.init() | method_lookups.swift:26:3:28:3 | Z.init() | | method_lookups.swift:50:9:50:13 | .baz(_:) | method_lookups.swift:24:3:24:21 | baz(_:) | -| method_lookups.swift:52:11:52:13 | .bar() | method_lookups.swift:23:3:23:21 | bar() | +| method_lookups.swift:52:11:52:13 | .bar() | method_lookups.swift:23:15:23:33 | bar() | | method_lookups.swift:53:18:53:18 | Z.init() | method_lookups.swift:26:3:28:3 | Z.init() | | method_lookups.swift:53:23:53:23 | .baz(_:) | method_lookups.swift:24:3:24:21 | baz(_:) | diff --git a/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/MethodLookupExpr_getType.expected b/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/MethodLookupExpr_getType.expected index 689812463da9..61f37a4b9a9e 100644 --- a/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/MethodLookupExpr_getType.expected +++ b/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/MethodLookupExpr_getType.expected @@ -20,7 +20,7 @@ | method_lookups.swift:44:11:44:13 | .foo(_:_:) | (Int, Int) -> () | | method_lookups.swift:47:1:47:1 | Task.init(priority:operation:) | (TaskPriority?, __owned @escaping @Sendable () async -> ()) -> Task<(), Never> | | method_lookups.swift:48:9:48:11 | .foo(_:_:) | @MainActor (Int, Int) -> () | -| method_lookups.swift:49:9:49:11 | .bar() | @MainActor () -> () | +| method_lookups.swift:49:9:49:11 | .bar() | () -> () | | method_lookups.swift:50:9:50:9 | Z.init() | @MainActor () -> Z | | method_lookups.swift:50:9:50:13 | .baz(_:) | @MainActor (Int) -> () | | method_lookups.swift:52:11:52:13 | .bar() | () -> () | diff --git a/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/method_lookups.swift b/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/method_lookups.swift index 5290eaae94d4..49c5673fbedb 100644 --- a/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/method_lookups.swift +++ b/swift/ql/test/extractor-tests/generated/expr/MethodLookupExpr/method_lookups.swift @@ -20,7 +20,7 @@ actor Y { @MainActor class Z { static func foo(_: Int, _:Int) {} - class func bar() {} + nonisolated class func bar() {} func baz(_: Int) {} init() { diff --git a/swift/ql/test/library-tests/ast/PrintAst.expected b/swift/ql/test/library-tests/ast/PrintAst.expected index c6dd456422d0..033b8d00b4b3 100644 --- a/swift/ql/test/library-tests/ast/PrintAst.expected +++ b/swift/ql/test/library-tests/ast/PrintAst.expected @@ -3237,44 +3237,42 @@ cfg.swift: # 524| getParam(0): [ParamDecl] continuation # 524| Type = AsyncStream.Continuation # 523| getBody(): [BraceStmt] { ... } -# 525| getElement(0): [BraceStmt] { ... } -# 525| getElement(0): [CallExpr] call to detached(priority:operation:) -# 525| getFunction(): [MethodLookupExpr] .detached(priority:operation:) -# 525| getBase(): [TypeExpr] Task<(), Never>.Type -# 525| getTypeRepr(): [TypeRepr] Task<(), Never> -# 525| getMethodRef(): [DeclRefExpr] detached(priority:operation:) -# 525| getArgument(0): [Argument] priority: default priority -# 525| getExpr(): [DefaultArgumentExpr] default priority -# 525| getArgument(1): [Argument] operation: { ... } -# 525| getExpr(): [ExplicitClosureExpr] { ... } -# 525| getBody(): [BraceStmt] { ... } -# 526| getElement(0): [ForEachStmt] for ... in ... { ... } -# 526| getPattern(): [NamedPattern] i -# 526| getSequence(): [CallExpr] call to makeIterator() -# 526| getFunction(): [MethodLookupExpr] .makeIterator() -# 526| getBase(): [BinaryExpr] ... ....(_:_:) ... -# 526| getFunction(): [MethodLookupExpr] ....(_:_:) -# 526| getBase(): [TypeExpr] Int.Type -# 526| getTypeRepr(): [TypeRepr] Int -# 526| getMethodRef(): [DeclRefExpr] ...(_:_:) -# 526| getArgument(0): [Argument] : 1 -# 526| getExpr(): [IntegerLiteralExpr] 1 -# 526| getArgument(1): [Argument] : 100 -# 526| getExpr(): [IntegerLiteralExpr] 100 -#-----| getMethodRef(): [DeclRefExpr] makeIterator() -# 526| getBody(): [BraceStmt] { ... } -# 527| getElement(0): [CallExpr] call to yield(_:) -# 527| getFunction(): [MethodLookupExpr] .yield(_:) -# 527| getBase(): [DeclRefExpr] continuation -# 527| getMethodRef(): [DeclRefExpr] yield(_:) -# 527| getArgument(0): [Argument] : i -# 527| getExpr(): [DeclRefExpr] i -# 529| getElement(1): [CallExpr] call to finish() -# 529| getFunction(): [MethodLookupExpr] .finish() -# 529| getBase(): [DeclRefExpr] continuation -# 529| getMethodRef(): [DeclRefExpr] finish() -# 527| getCapture(0): [CapturedDecl] continuation -# 525| getElement(1): [ReturnStmt] return +# 525| getElement(0): [CallExpr] call to detached(priority:operation:) +# 525| getFunction(): [MethodLookupExpr] .detached(priority:operation:) +# 525| getBase(): [TypeExpr] Task<(), Never>.Type +# 525| getTypeRepr(): [TypeRepr] Task<(), Never> +# 525| getMethodRef(): [DeclRefExpr] detached(priority:operation:) +# 525| getArgument(0): [Argument] priority: default priority +# 525| getExpr(): [DefaultArgumentExpr] default priority +# 525| getArgument(1): [Argument] operation: { ... } +# 525| getExpr(): [ExplicitClosureExpr] { ... } +# 525| getBody(): [BraceStmt] { ... } +# 526| getElement(0): [ForEachStmt] for ... in ... { ... } +# 526| getPattern(): [NamedPattern] i +# 526| getSequence(): [CallExpr] call to makeIterator() +# 526| getFunction(): [MethodLookupExpr] .makeIterator() +# 526| getBase(): [BinaryExpr] ... ....(_:_:) ... +# 526| getFunction(): [MethodLookupExpr] ....(_:_:) +# 526| getBase(): [TypeExpr] Int.Type +# 526| getTypeRepr(): [TypeRepr] Int +# 526| getMethodRef(): [DeclRefExpr] ...(_:_:) +# 526| getArgument(0): [Argument] : 1 +# 526| getExpr(): [IntegerLiteralExpr] 1 +# 526| getArgument(1): [Argument] : 100 +# 526| getExpr(): [IntegerLiteralExpr] 100 +#-----| getMethodRef(): [DeclRefExpr] makeIterator() +# 526| getBody(): [BraceStmt] { ... } +# 527| getElement(0): [CallExpr] call to yield(_:) +# 527| getFunction(): [MethodLookupExpr] .yield(_:) +# 527| getBase(): [DeclRefExpr] continuation +# 527| getMethodRef(): [DeclRefExpr] yield(_:) +# 527| getArgument(0): [Argument] : i +# 527| getExpr(): [DeclRefExpr] i +# 529| getElement(1): [CallExpr] call to finish() +# 529| getFunction(): [MethodLookupExpr] .finish() +# 529| getBase(): [DeclRefExpr] continuation +# 529| getMethodRef(): [DeclRefExpr] finish() +# 527| getCapture(0): [CapturedDecl] continuation # 523| getPattern(0): [NamedPattern] stream # 533| getElement(1): [ForEachStmt] for ... in ... { ... } # 533| getPattern(): [NamedPattern] i diff --git a/swift/ql/test/library-tests/controlflow/graph/Cfg.expected b/swift/ql/test/library-tests/controlflow/graph/Cfg.expected index d3f07e39c15f..7ad1ee0678a7 100644 --- a/swift/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/swift/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -6063,14 +6063,11 @@ cfg.swift: # 525| Task<(), Never>.Type #-----| -> default priority -# 525| return -#-----| return -> exit { ... } (normal) - # 525| .detached(priority:operation:) #-----| -> Task<(), Never>.Type # 525| call to detached(priority:operation:) -#-----| -> return +#-----| -> exit { ... } (normal) # 525| default priority #-----| -> { ... } diff --git a/swift/ql/test/library-tests/elements/expr/methodlookup/PrintAst.expected b/swift/ql/test/library-tests/elements/expr/methodlookup/PrintAst.expected index 5e25ea404d11..11ce74805ce8 100644 --- a/swift/ql/test/library-tests/elements/expr/methodlookup/PrintAst.expected +++ b/swift/ql/test/library-tests/elements/expr/methodlookup/PrintAst.expected @@ -226,7 +226,6 @@ methodlookup.swift: # 47| getFunction(): [MethodLookupExpr] .instanceMethod() # 47| getBase(): [DeclRefExpr] baz # 47| getMethodRef(): [DeclRefExpr] instanceMethod() -# 47| getMethodRef().getFullyConverted(): [FunctionConversionExpr] ((Baz) -> @MainActor () -> ()) ... # 47| getElement(2).getFullyConverted(): [AwaitExpr] await ... # 48| getElement(3): [CallExpr] call to { ... } # 48| getFunction(): [CallExpr] call to Baz.instanceMethod() diff --git a/swift/ql/test/library-tests/elements/expr/methodlookup/methodlookup.swift b/swift/ql/test/library-tests/elements/expr/methodlookup/methodlookup.swift index 5ba364ab0035..9f382db9941e 100644 --- a/swift/ql/test/library-tests/elements/expr/methodlookup/methodlookup.swift +++ b/swift/ql/test/library-tests/elements/expr/methodlookup/methodlookup.swift @@ -14,7 +14,7 @@ actor Bar { @MainActor class Baz { init() {} - func instanceMethod() {} + nonisolated func instanceMethod() {} static func staticMethod() {} class func classMethod() {} } diff --git a/swift/third_party/load.bzl b/swift/third_party/load.bzl index 3319886ff8d2..1266d793e152 100644 --- a/swift/third_party/load.bzl +++ b/swift/third_party/load.bzl @@ -1,14 +1,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -# TODO: remove `remove-result-of.patch` once we update to a Swift version containing -# https://github.com/apple/swift/commit/2ed2cea2 -# (probably when updating to 5.9) -_swift_prebuilt_version = "swift-5.8.1-RELEASE.214" +_swift_prebuilt_version = "swift-5.9-RELEASE.226" _swift_sha_map = { - "Linux-X64": "009594131d2f6327e0033c4b7b0479a5730427575eb59a81a439fe0e343aa777", - "macOS-ARM64": "304a918e3699d404f57e967eff79b982388d8c5330c2135272c9f3a825920a39", - "macOS-X64": "c763c493e5782869b54887dc72df2aad00d59af7272c6d96377f1debb98741f2", + "Linux-X64": "674b8da9d8c7cc585055b1821076510553a9df340ef931aa45cbe00eb0f7f86e", + "macOS-ARM64": "a4c2486d0532e43f0b7c55d1203e17672900541c72fd3fcb8d9ffdef3698dc6f", + "macOS-X64": "b84ba67f9024ff9ce43879eb6503efd2f9952ac85ab2c2fb8d2f01d0af432ac9", } _swift_arch_map = { @@ -46,7 +43,6 @@ def load_dependencies(workspace_name): patches = [ "@%s//swift/third_party/swift-llvm-support:patches/%s.patch" % (workspace_name, patch_name) for patch_name in ( - "remove-result-of", "remove-redundant-operators", "add-constructor-to-Compilation", ) diff --git a/swift/third_party/swift-llvm-support/patches/remove-result-of.patch b/swift/third_party/swift-llvm-support/patches/remove-result-of.patch deleted file mode 100644 index ab3f2155b678..000000000000 --- a/swift/third_party/swift-llvm-support/patches/remove-result-of.patch +++ /dev/null @@ -1,30 +0,0 @@ -`std::result_of` was removed in C++20, but is still used in the Swift headers. We can't -remove it from there before prebuilding, as that is still done with C++14, but we can -replace it with `std::invoke_result` for compiling the extractor. - -diff --git a/include/swift/Basic/RelativePointer.h b/include/swift/Basic/RelativePointer.h -index 73f91262afa..bdaa304c804 100644 ---- a/include/swift/Basic/RelativePointer.h -+++ b/include/swift/Basic/RelativePointer.h -@@ -551,7 +551,7 @@ public: - } - - template -- typename std::result_of::type operator()(ArgTy... arg) const { -+ typename std::invoke_result::type operator()(ArgTy... arg) const { - #if SWIFT_PTRAUTH - void *ptr = this->super::getWithoutCast(); - return reinterpret_cast(ptrauth_sign_unauthenticated( -diff --git a/include/swift/Basic/STLExtras.h b/include/swift/Basic/STLExtras.h -index 7fa3d0c8890..6bc891a9b63 100644 ---- a/include/swift/Basic/STLExtras.h -+++ b/include/swift/Basic/STLExtras.h -@@ -405,7 +405,7 @@ class OptionalTransformIterator { - typename std::iterator_traits::reference; - - using ResultReference = -- typename std::result_of::type; -+ typename std::invoke_result::type; - - public: - /// Used to indicate when the current iterator has already been