1//===- llvm/Support/FileSystem/UniqueID.h - UniqueID for files --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is cut out of llvm/Support/FileSystem.h to allow UniqueID to be
10// reused without bloating the includes.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H
15#define LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H
16
17#include <cstdint>
18
19namespace llvm {
20namespace sys {
21namespace fs {
22
23class UniqueID {
24 uint64_t Device;
25 uint64_t File;
26
27public:
28 UniqueID() = default;
29 UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {}
30
31 bool operator==(const UniqueID &Other) const {
32 return Device == Other.Device && File == Other.File;
33 }
34 bool operator!=(const UniqueID &Other) const { return !(*this == Other); }
35 bool operator<(const UniqueID &Other) const {
36 /// Don't use std::tie since it bloats the compile time of this header.
37 if (Device < Other.Device)
38 return true;
39 if (Other.Device < Device)
40 return false;
41 return File < Other.File;
42 }
43
44 uint64_t getDevice() const { return Device; }
45 uint64_t getFile() const { return File; }
46};
47
48} // end namespace fs
49} // end namespace sys
50} // end namespace llvm
51
52#endif // LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H
53