File indexing completed on 2026-05-10 08:44:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H
0015 #define LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H
0016
0017 #include "llvm/ADT/DenseMapInfo.h"
0018 #include "llvm/ADT/Hashing.h"
0019 #include <cstdint>
0020 #include <utility>
0021
0022 namespace llvm {
0023 namespace sys {
0024 namespace fs {
0025
0026 class UniqueID {
0027 uint64_t Device;
0028 uint64_t File;
0029
0030 public:
0031 UniqueID() = default;
0032 UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {}
0033
0034 bool operator==(const UniqueID &Other) const {
0035 return Device == Other.Device && File == Other.File;
0036 }
0037 bool operator!=(const UniqueID &Other) const { return !(*this == Other); }
0038 bool operator<(const UniqueID &Other) const {
0039
0040 if (Device < Other.Device)
0041 return true;
0042 if (Other.Device < Device)
0043 return false;
0044 return File < Other.File;
0045 }
0046
0047 uint64_t getDevice() const { return Device; }
0048 uint64_t getFile() const { return File; }
0049 };
0050
0051 }
0052 }
0053
0054
0055 template <> struct DenseMapInfo<llvm::sys::fs::UniqueID> {
0056 static inline llvm::sys::fs::UniqueID getEmptyKey() {
0057 auto EmptyKey = DenseMapInfo<std::pair<uint64_t, uint64_t>>::getEmptyKey();
0058 return {EmptyKey.first, EmptyKey.second};
0059 }
0060
0061 static inline llvm::sys::fs::UniqueID getTombstoneKey() {
0062 auto TombstoneKey =
0063 DenseMapInfo<std::pair<uint64_t, uint64_t>>::getTombstoneKey();
0064 return {TombstoneKey.first, TombstoneKey.second};
0065 }
0066
0067 static hash_code getHashValue(const llvm::sys::fs::UniqueID &Tag) {
0068 return hash_value(std::make_pair(Tag.getDevice(), Tag.getFile()));
0069 }
0070
0071 static bool isEqual(const llvm::sys::fs::UniqueID &LHS,
0072 const llvm::sys::fs::UniqueID &RHS) {
0073 return LHS == RHS;
0074 }
0075 };
0076
0077 }
0078
0079 #endif