[clang] 77a9e0a - Basic: Split out DirectoryEntry.h, NFC
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 11:12:07 PST 2020
Author: Duncan P. N. Exon Smith
Date: 2020-11-04T14:11:57-05:00
New Revision: 77a9e0a4af5aea3795ed79a0db61ee5b19b837e4
URL: https://github.com/llvm/llvm-project/commit/77a9e0a4af5aea3795ed79a0db61ee5b19b837e4
DIFF: https://github.com/llvm/llvm-project/commit/77a9e0a4af5aea3795ed79a0db61ee5b19b837e4.diff
LOG: Basic: Split out DirectoryEntry.h, NFC
Move `DirectoryEntry` and `DirectoryEntryRef` into their own header,
similar to the creation of FileEntry.h. No functionality change here,
just preparing to include it in more places to allow wider adoption of
`DirectoryEntryRef` without requiring all of `FileManager.h`.
Differential Revision: https://reviews.llvm.org/D90478
Added:
clang/include/clang/Basic/DirectoryEntry.h
Modified:
clang/include/clang/Basic/FileManager.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DirectoryEntry.h b/clang/include/clang/Basic/DirectoryEntry.h
new file mode 100644
index 000000000000..7c634709ca9b
--- /dev/null
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -0,0 +1,56 @@
+//===- clang/Basic/DirectoryEntry.h - Directory references ------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Defines interfaces for clang::DirectoryEntry and clang::DirectoryEntryRef.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_BASIC_DIRECTORYENTRY_H
+#define LLVM_CLANG_BASIC_DIRECTORYENTRY_H
+
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ErrorOr.h"
+
+namespace clang {
+
+/// Cached information about one directory (either on disk or in
+/// the virtual file system).
+class DirectoryEntry {
+ friend class FileManager;
+
+ // FIXME: We should not be storing a directory entry name here.
+ StringRef Name; // Name of the directory.
+
+public:
+ StringRef getName() const { return Name; }
+};
+
+/// A reference to a \c DirectoryEntry that includes the name of the directory
+/// as it was accessed by the FileManager's client.
+class DirectoryEntryRef {
+public:
+ const DirectoryEntry &getDirEntry() const { return *Entry->getValue(); }
+
+ StringRef getName() const { return Entry->getKey(); }
+
+private:
+ friend class FileManager;
+
+ DirectoryEntryRef(
+ llvm::StringMapEntry<llvm::ErrorOr<DirectoryEntry &>> *Entry)
+ : Entry(Entry) {}
+
+ const llvm::StringMapEntry<llvm::ErrorOr<DirectoryEntry &>> *Entry;
+};
+
+} // end namespace clang
+
+#endif // LLVM_CLANG_BASIC_DIRECTORYENTRY_H
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index 224f87ffcb26..d7135a4f0ac3 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_BASIC_FILEMANAGER_H
#define LLVM_CLANG_BASIC_FILEMANAGER_H
+#include "clang/Basic/DirectoryEntry.h"
#include "clang/Basic/FileEntry.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/LLVM.h"
@@ -42,36 +43,6 @@ namespace clang {
class FileSystemStatCache;
-/// Cached information about one directory (either on disk or in
-/// the virtual file system).
-class DirectoryEntry {
- friend class FileManager;
-
- // FIXME: We should not be storing a directory entry name here.
- StringRef Name; // Name of the directory.
-
-public:
- StringRef getName() const { return Name; }
-};
-
-/// A reference to a \c DirectoryEntry that includes the name of the directory
-/// as it was accessed by the FileManager's client.
-class DirectoryEntryRef {
-public:
- const DirectoryEntry &getDirEntry() const { return *Entry->getValue(); }
-
- StringRef getName() const { return Entry->getKey(); }
-
-private:
- friend class FileManager;
-
- DirectoryEntryRef(
- llvm::StringMapEntry<llvm::ErrorOr<DirectoryEntry &>> *Entry)
- : Entry(Entry) {}
-
- const llvm::StringMapEntry<llvm::ErrorOr<DirectoryEntry &>> *Entry;
-};
-
/// Implements support for file system lookup, file system caching,
/// and directory search management.
///
More information about the cfe-commits
mailing list