|
14 | 14 | #ifndef LLVM_CAS_CASCONFIGURATION_H |
15 | 15 | #define LLVM_CAS_CASCONFIGURATION_H |
16 | 16 |
|
| 17 | +#include "llvm/ADT/Hashing.h" |
17 | 18 | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
18 | 19 | #include "llvm/Support/Error.h" |
19 | 20 | #include "llvm/Support/VirtualFileSystem.h" |
20 | 21 | #include <string> |
21 | 22 | #include <vector> |
22 | 23 |
|
23 | | -namespace llvm::cas { |
| 24 | +namespace llvm { |
| 25 | +namespace cas { |
24 | 26 |
|
25 | 27 | class ActionCache; |
26 | 28 | class ObjectStore; |
@@ -72,8 +74,42 @@ class CASConfiguration { |
72 | 74 | createFromSearchConfigFile( |
73 | 75 | StringRef Path, |
74 | 76 | llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr); |
| 77 | + |
| 78 | + /// DenseMap support \{ |
| 79 | + static cas::CASConfiguration getDenseMapEmptyKey() { return {}; } |
| 80 | + |
| 81 | + static cas::CASConfiguration getDenseMapTombstoneKey() { |
| 82 | + return {"$", "$", {}}; |
| 83 | + } |
| 84 | + unsigned getHashValue() const { |
| 85 | + return detail::combineHashValue( |
| 86 | + DenseMapInfo<StringRef>::getHashValue(StringRef(CASPath)), |
| 87 | + DenseMapInfo<StringRef>::getHashValue(StringRef(PluginPath))); |
| 88 | + } |
| 89 | + /// \} |
| 90 | + operator bool() { return !CASPath.empty() || !PluginPath.empty(); } |
75 | 91 | }; |
76 | 92 |
|
77 | | -} // namespace llvm::cas |
| 93 | +} // namespace cas |
| 94 | + |
| 95 | +template <> struct DenseMapInfo<cas::CASConfiguration> { |
| 96 | + static cas::CASConfiguration getEmptyKey() { |
| 97 | + return cas::CASConfiguration::getDenseMapEmptyKey(); |
| 98 | + } |
| 99 | + |
| 100 | + static cas::CASConfiguration getTombstoneKey() { |
| 101 | + return cas::CASConfiguration::getDenseMapTombstoneKey(); |
| 102 | + } |
| 103 | + |
| 104 | + static unsigned getHashValue(const cas::CASConfiguration &config) { |
| 105 | + return config.getHashValue(); |
| 106 | + } |
| 107 | + |
| 108 | + static bool isEqual(const cas::CASConfiguration &LHS, |
| 109 | + const cas::CASConfiguration &RHS) { |
| 110 | + return LHS == RHS; |
| 111 | + } |
| 112 | +}; |
78 | 113 |
|
| 114 | +} // namespace llvm |
79 | 115 | #endif |
0 commit comments