[clang] 81ac81f - FileManager: Reorder declarations of FileEntry and FileEntryRef, NFC
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 23 17:47:33 PDT 2020
Author: Duncan P. N. Exon Smith
Date: 2020-10-23T20:47:15-04:00
New Revision: 81ac81f8644a7c6ed19bea95385794f7870d0fda
URL: https://github.com/llvm/llvm-project/commit/81ac81f8644a7c6ed19bea95385794f7870d0fda
DIFF: https://github.com/llvm/llvm-project/commit/81ac81f8644a7c6ed19bea95385794f7870d0fda.diff
LOG: FileManager: Reorder declarations of FileEntry and FileEntryRef, NFC
This reduces noise in a future patch, but shouldn't change anything
otherwise.
Differential Revision: https://reviews.llvm.org/D89521
Added:
Modified:
clang/include/clang/Basic/FileManager.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index 089304e1d1e6..8fcea2d5cbf3 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -71,6 +71,37 @@ class DirectoryEntryRef {
const llvm::StringMapEntry<llvm::ErrorOr<DirectoryEntry &>> *Entry;
};
+class FileEntry;
+
+/// A reference to a \c FileEntry that includes the name of the file as it was
+/// accessed by the FileManager's client.
+class FileEntryRef {
+public:
+ FileEntryRef() = delete;
+ FileEntryRef(StringRef Name, const FileEntry &Entry)
+ : Name(Name), Entry(&Entry) {}
+
+ const StringRef getName() const { return Name; }
+ const FileEntry &getFileEntry() const { return *Entry; }
+
+ inline bool isValid() const;
+ inline off_t getSize() const;
+ inline unsigned getUID() const;
+ inline const llvm::sys::fs::UniqueID &getUniqueID() const;
+ inline time_t getModificationTime() const;
+
+ friend bool operator==(const FileEntryRef &LHS, const FileEntryRef &RHS) {
+ return LHS.Entry == RHS.Entry && LHS.Name == RHS.Name;
+ }
+ friend bool operator!=(const FileEntryRef &LHS, const FileEntryRef &RHS) {
+ return !(LHS == RHS);
+ }
+
+private:
+ StringRef Name;
+ const FileEntry *Entry;
+};
+
/// Cached information about one file (either on disk
/// or in the virtual file system).
///
@@ -126,41 +157,19 @@ class FileEntry {
bool isOpenForTests() const { return File != nullptr; }
};
-/// A reference to a \c FileEntry that includes the name of the file as it was
-/// accessed by the FileManager's client.
-class FileEntryRef {
-public:
- FileEntryRef() = delete;
- FileEntryRef(StringRef Name, const FileEntry &Entry)
- : Name(Name), Entry(&Entry) {}
+bool FileEntryRef::isValid() const { return getFileEntry().isValid(); }
- const StringRef getName() const { return Name; }
-
- bool isValid() const { return Entry->isValid(); }
-
- const FileEntry &getFileEntry() const { return *Entry; }
-
- off_t getSize() const { return Entry->getSize(); }
+off_t FileEntryRef::getSize() const { return getFileEntry().getSize(); }
- unsigned getUID() const { return Entry->getUID(); }
+unsigned FileEntryRef::getUID() const { return getFileEntry().getUID(); }
- const llvm::sys::fs::UniqueID &getUniqueID() const {
- return Entry->getUniqueID();
- }
+const llvm::sys::fs::UniqueID &FileEntryRef::getUniqueID() const {
+ return getFileEntry().getUniqueID();
+}
- time_t getModificationTime() const { return Entry->getModificationTime(); }
-
- friend bool operator==(const FileEntryRef &LHS, const FileEntryRef &RHS) {
- return LHS.Entry == RHS.Entry && LHS.Name == RHS.Name;
- }
- friend bool operator!=(const FileEntryRef &LHS, const FileEntryRef &RHS) {
- return !(LHS == RHS);
- }
-
-private:
- StringRef Name;
- const FileEntry *Entry;
-};
+time_t FileEntryRef::getModificationTime() const {
+ return getFileEntry().getModificationTime();
+}
/// Implements support for file system lookup, file system caching,
/// and directory search management.
More information about the cfe-commits
mailing list