File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,26 @@ load("//swift:rules.bzl", "swift_cc_library")
3
3
swift_cc_library (
4
4
name = "file" ,
5
5
srcs = glob (["*.cpp" ]),
6
- hdrs = glob (["*.h" ]),
6
+ hdrs = glob (["*.h" ]) + [ ":path_hash_workaround" ] ,
7
7
visibility = ["//swift:__subpackages__" ],
8
8
deps = ["@picosha2" ],
9
9
)
10
+
11
+ genrule (
12
+ name = "path_hash_workaround" ,
13
+ srcs = [
14
+ "PathHash.h.workaround" ,
15
+ "PathHash.h.fixed" ,
16
+ ],
17
+ outs = ["PathHash.h" ],
18
+ # see if https://cplusplus.github.io/LWG/issue3657 is fixed with the current compiler or not
19
+ # if fixed, PathHash.h.workaround will not compile
20
+ cmd = "\n " .join ([
21
+ "if clang -c -x c++ -std=c++17 -Wno-pragma-once-outside-header \\ " ,
22
+ " $(rootpath PathHash.h.workaround) -o /dev/null &> /dev/null; then" ,
23
+ " cp $(rootpath PathHash.h.workaround) $@" ,
24
+ "else" ,
25
+ " cp $(rootpath PathHash.h.fixed) $@" ,
26
+ "fi" ,
27
+ ]),
28
+ )
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include <filesystem>
4
+ #include <functional>
Original file line number Diff line number Diff line change 8
8
// but it works, and this is recognized as a defect of the standard.
9
9
// Using a non-standard Hasher type would be a huge pain, as the automatic hash implementation of
10
10
// std::variant would not kick in (we use std::filesystem::path in a variant used as a map key).
11
- // We can reconsider when the fix to the above issue hits clang, which might require a version check
12
- // here
13
11
namespace std {
14
12
template <>
15
- struct std :: hash<std:: filesystem::path> {
16
- std:: size_t operator ()(const std:: filesystem::path& path) const { return hash_value (path); }
13
+ struct hash<filesystem::path> {
14
+ size_t operator()(const filesystem::path& path) const { return hash_value(path); }
17
15
};
16
+
18
17
} // namespace std
You can’t perform that action at this time.
0 commit comments