File tree Expand file tree Collapse file tree 6 files changed +14
-44
lines changed
Expand file tree Collapse file tree 6 files changed +14
-44
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ class SwiftLocationExtractor {
104104 private:
105105 TrapLabel<FileTag> fetchFileLabel (const std::filesystem::path& file);
106106 TrapDomain& trap;
107- std::unordered_map<std::filesystem::path, TrapLabel<FileTag>> store;
107+ std::unordered_map<std::filesystem::path, TrapLabel<FileTag>, codeql::PathHash > store;
108108};
109109
110110template <typename Locatable>
Original file line number Diff line number Diff line change @@ -9,26 +9,7 @@ swift_cc_library(
99 hdrs = glob (
1010 ["*.h" ],
1111 exclude = ["FsLogger.h" ],
12- ) + [ ":path_hash_workaround" ] ,
12+ ),
1313 visibility = ["//swift:__subpackages__" ],
1414 deps = ["//swift/logging" ],
1515)
16-
17- genrule (
18- name = "path_hash_workaround" ,
19- srcs = [
20- "PathHash.h.workaround" ,
21- "PathHash.h.fixed" ,
22- ],
23- outs = ["PathHash.h" ],
24- # see if https://cplusplus.github.io/LWG/issue3657 is fixed with the current compiler or not
25- # if fixed, PathHash.h.workaround will not compile
26- cmd = "\n " .join ([
27- "if clang -c -x c++ -std=c++20 -Wno-pragma-once-outside-header \\ " ,
28- " $(rootpath PathHash.h.workaround) -o /dev/null &> /dev/null; then" ,
29- " cp $(rootpath PathHash.h.workaround) $@" ,
30- "else" ,
31- " cp $(rootpath PathHash.h.fixed) $@" ,
32- "fi" ,
33- ]),
34- )
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < filesystem>
4+
5+ namespace codeql {
6+ struct PathHash {
7+ auto operator ()(const std::filesystem::path& path) const {
8+ return std::filesystem::hash_value (path);
9+ }
10+ };
11+ } // namespace codeql
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -114,7 +114,6 @@ class FileInterceptor {
114114 }
115115
116116 int open (const char * path, int flags, mode_t mode = 0 ) const {
117- fs::path fsPath{path};
118117 CODEQL_ASSERT ((flags & O_ACCMODE) == O_RDONLY, " We should only be intercepting file reads" );
119118 // try to use the hash map first
120119 errno = 0 ;
@@ -162,7 +161,7 @@ class FileInterceptor {
162161};
163162
164163std::optional<std::string> getHashOfRealFile (const fs::path& path) {
165- static std::unordered_map<fs::path, std::string> cache;
164+ static std::unordered_map<fs::path, std::string, codeql::PathHash > cache;
166165 auto resolved = resolvePath (path);
167166 if (auto found = cache.find (resolved); found != cache.end ()) {
168167 return found->second ;
You can’t perform that action at this time.
0 commit comments