Skip to content

Commit 21ad3e8

Browse files
authored
Merge pull request github#13497 from github/redsun82/swift-remove-result-of
Swift: remove `std::result_of` from swift headers
2 parents 4233363 + 592e7f0 commit 21ad3e8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

swift/third_party/load.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
33

4+
# TODO: remove `remove-result-of.patch` once we update to a Swift version containing
5+
# https://github.com/apple/swift/commit/2ed2cea2
6+
# (probably when updating to 5.9)
47
_swift_prebuilt_version = "swift-5.8.1-RELEASE.208"
58
_swift_sha_map = {
69
"Linux-X64": "1d93286d6219e5c5746938ab9287d90efea98039f022cb1433296ccbc1684bc0",
@@ -39,6 +42,8 @@ def load_dependencies(workspace_name):
3942
),
4043
build_file = _build(workspace_name, "swift-llvm-support"),
4144
sha256 = sha256,
45+
patch_args = ["-p1"],
46+
patches = ["@%s//swift/third_party/swift-llvm-support:patches/remove-result-of.patch" % workspace_name],
4247
)
4348

4449
_github_archive(
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
`std::result_of` was removed in C++20, but is still used in the Swift headers. We can't
2+
remove it from there before prebuilding, as that is still done with C++14, but we can
3+
replace it with `std::invoke_result` for compiling the extractor.
4+
5+
diff --git a/include/swift/Basic/RelativePointer.h b/include/swift/Basic/RelativePointer.h
6+
index 73f91262afa..bdaa304c804 100644
7+
--- a/include/swift/Basic/RelativePointer.h
8+
+++ b/include/swift/Basic/RelativePointer.h
9+
@@ -551,7 +551,7 @@ public:
10+
}
11+
12+
template <typename... ArgTy>
13+
- typename std::result_of<T *(ArgTy...)>::type operator()(ArgTy... arg) const {
14+
+ typename std::invoke_result<T*, ArgTy...>::type operator()(ArgTy... arg) const {
15+
#if SWIFT_PTRAUTH
16+
void *ptr = this->super::getWithoutCast();
17+
return reinterpret_cast<T *>(ptrauth_sign_unauthenticated(
18+
diff --git a/include/swift/Basic/STLExtras.h b/include/swift/Basic/STLExtras.h
19+
index 7fa3d0c8890..6bc891a9b63 100644
20+
--- a/include/swift/Basic/STLExtras.h
21+
+++ b/include/swift/Basic/STLExtras.h
22+
@@ -405,7 +405,7 @@ class OptionalTransformIterator {
23+
typename std::iterator_traits<Iterator>::reference;
24+
25+
using ResultReference =
26+
- typename std::result_of<OptionalTransform(UnderlyingReference)>::type;
27+
+ typename std::invoke_result<OptionalTransform, UnderlyingReference>::type;
28+
29+
public:
30+
/// Used to indicate when the current iterator has already been

0 commit comments

Comments
 (0)