From 3306c566df801af2a7533aaaf3c9943729a0e4af Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Wed, 5 Jul 2023 17:04:38 +0200 Subject: [PATCH 1/3] Swift: minimal 5.9 support --- swift/third_party/load.bzl | 1 - .../patches/remove-result-of.patch | 30 ------------------- 2 files changed, 31 deletions(-) delete mode 100644 swift/third_party/swift-llvm-support/patches/remove-result-of.patch diff --git a/swift/third_party/load.bzl b/swift/third_party/load.bzl index 3319886ff8d2..f5550a787085 100644 --- a/swift/third_party/load.bzl +++ b/swift/third_party/load.bzl @@ -46,7 +46,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 From 09b16554ad7e3307c1b26f25a5906a34aee83811 Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Mon, 10 Jul 2023 09:24:57 +0200 Subject: [PATCH 2/3] Swift: remove FallthroughStmt assertion --- swift/third_party/load.bzl | 1 + .../patches/remove-fallthrough-assertion.patch | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 swift/third_party/swift-llvm-support/patches/remove-fallthrough-assertion.patch diff --git a/swift/third_party/load.bzl b/swift/third_party/load.bzl index f5550a787085..7873e8a5b1d0 100644 --- a/swift/third_party/load.bzl +++ b/swift/third_party/load.bzl @@ -48,6 +48,7 @@ def load_dependencies(workspace_name): for patch_name in ( "remove-redundant-operators", "add-constructor-to-Compilation", + "remove-fallthrough-assertion", ) ], ) diff --git a/swift/third_party/swift-llvm-support/patches/remove-fallthrough-assertion.patch b/swift/third_party/swift-llvm-support/patches/remove-fallthrough-assertion.patch new file mode 100644 index 000000000000..63c8c4803377 --- /dev/null +++ b/swift/third_party/swift-llvm-support/patches/remove-fallthrough-assertion.patch @@ -0,0 +1,12 @@ +diff --git a/include/swift/AST/Stmt.h b/include/swift/AST/Stmt.h +index 56f8769a502..4d1ea5f84c1 100644 +--- a/include/swift/AST/Stmt.h ++++ b/include/swift/AST/Stmt.h +@@ -1049,7 +1049,6 @@ public: + /// Get the CaseStmt block to which the fallthrough transfers control. + /// Set during Sema. + CaseStmt *getFallthroughDest() const { +- assert(FallthroughDest && "fallthrough dest is not set until Sema"); + return FallthroughDest; + } + void setFallthroughDest(CaseStmt *C) { From e36089ec0eb89af09a0e8c0296bdf0727eedbced Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Mon, 10 Jul 2023 12:22:54 +0200 Subject: [PATCH 3/3] Swift: update test expectations --- .../generated/decl/ModuleDecl/ModuleDecl.expected | 4 ++-- .../decl/ModuleDecl/ModuleDecl_getAnImportedModule.expected | 2 ++ .../generated/decl/NamedFunction/NamedFunction.expected | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) 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 e28d4ef33b54..8251321b6415 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 | getNumberOfBaseTypes: | 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 | getNumberOfBaseTypes: | 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 | getNumberOfBaseTypes: | 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 | getNumberOfBaseTypes: | 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 | getNumberOfBaseTypes: | 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/decl/NamedFunction/NamedFunction.expected b/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.expected index 975da0933216..8f91d382599d 100644 --- a/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.expected +++ b/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.expected @@ -2,4 +2,4 @@ | functions.swift:5:1:7:1 | bar(_:d:) | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 2 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Int, Double) -> Int | | functions.swift:10:5:10:28 | noBody(x:) | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | no | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Self) -> (Int) -> Int | | functions.swift:13:1:15:1 | variadic(_:) | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Int...) -> () | -| functions.swift:17:1:19:1 | generic(x:y:) | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 2 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 2 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (X, Y) -> () | +| functions.swift:17:1:19:1 | generic(x:y:) | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 2 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 2 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (x: X, y: Y) -> () |