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 {
104
104
private:
105
105
TrapLabel<FileTag> fetchFileLabel (const std::filesystem::path& file);
106
106
TrapDomain& trap;
107
- std::unordered_map<std::filesystem::path, TrapLabel<FileTag>> store;
107
+ std::unordered_map<std::filesystem::path, TrapLabel<FileTag>, codeql::PathHash > store;
108
108
};
109
109
110
110
template <typename Locatable>
Original file line number Diff line number Diff line change @@ -9,26 +9,7 @@ swift_cc_library(
9
9
hdrs = glob (
10
10
["*.h" ],
11
11
exclude = ["FsLogger.h" ],
12
- ) + [ ":path_hash_workaround" ] ,
12
+ ),
13
13
visibility = ["//swift:__subpackages__" ],
14
14
deps = ["//swift/logging" ],
15
15
)
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 {
114
114
}
115
115
116
116
int open (const char * path, int flags, mode_t mode = 0 ) const {
117
- fs::path fsPath{path};
118
117
CODEQL_ASSERT ((flags & O_ACCMODE) == O_RDONLY, " We should only be intercepting file reads" );
119
118
// try to use the hash map first
120
119
errno = 0 ;
@@ -162,7 +161,7 @@ class FileInterceptor {
162
161
};
163
162
164
163
std::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;
166
165
auto resolved = resolvePath (path);
167
166
if (auto found = cache.find (resolved); found != cache.end ()) {
168
167
return found->second ;
You can’t perform that action at this time.
0 commit comments