Compare commits

...

1 Commits

Author SHA1 Message Date
Alexandre Boulgakov
3c695e3555 Swift: Remove workaround for LWG/issue3657. 2023-06-13 22:56:15 +01:00
4 changed files with 1 additions and 42 deletions

View File

@@ -9,7 +9,6 @@
#include <filesystem>
#include "swift/extractor/trap/generated/TrapEntries.h"
#include "swift/extractor/infra/file/PathHash.h"
namespace codeql {

View File

@@ -9,26 +9,7 @@ swift_cc_library(
hdrs = glob(
["*.h"],
exclude = ["FsLogger.h"],
) + [":path_hash_workaround"],
),
visibility = ["//swift:__subpackages__"],
deps = ["//swift/logging"],
)
genrule(
name = "path_hash_workaround",
srcs = [
"PathHash.h.workaround",
"PathHash.h.fixed",
],
outs = ["PathHash.h"],
# see if https://cplusplus.github.io/LWG/issue3657 is fixed with the current compiler or not
# if fixed, PathHash.h.workaround will not compile
cmd = "\n".join([
"if clang -c -x c++ -std=c++20 -Wno-pragma-once-outside-header \\",
" $(rootpath PathHash.h.workaround) -o /dev/null &> /dev/null; then",
" cp $(rootpath PathHash.h.workaround) $@",
"else",
" cp $(rootpath PathHash.h.fixed) $@",
"fi",
]),
)

View File

@@ -1,4 +0,0 @@
#pragma once
#include <filesystem>
#include <functional>

View File

@@ -1,17 +0,0 @@
#pragma once
#include <filesystem>
#include <functional>
// workaround for https://cplusplus.github.io/LWG/issue3657
// notice that theoretically by the standard you are not allowed to specialize on std types...
// but it works, and this is recognized as a defect of the standard.
// Using a non-standard Hasher type would be a huge pain, as the automatic hash implementation of
// std::variant would not kick in (we use std::filesystem::path in a variant used as a map key).
namespace std {
template <>
struct hash<filesystem::path> {
size_t operator()(const filesystem::path& path) const { return hash_value(path); }
};
} // namespace std