aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/FileManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Basic/FileManager.h')
-rw-r--r--include/clang/Basic/FileManager.h43
1 files changed, 21 insertions, 22 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h
index b6a9ca702842..b817dd20c301 100644
--- a/include/clang/Basic/FileManager.h
+++ b/include/clang/Basic/FileManager.h
@@ -16,7 +16,6 @@
#define LLVM_CLANG_BASIC_FILEMANAGER_H
#include "clang/Basic/FileSystemOptions.h"
-#include "clang/Basic/LLVM.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -24,25 +23,32 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/FileSystem.h"
+#include <ctime>
#include <memory>
#include <map>
+#include <string>
namespace llvm {
+
class MemoryBuffer;
-}
+
+} // end namespace llvm
namespace clang {
-class FileManager;
+
class FileSystemStatCache;
/// \brief Cached information about one directory (either on disk or in
/// the virtual file system).
class DirectoryEntry {
- const char *Name; // Name of the directory.
friend class FileManager;
+
+ StringRef Name; // Name of the directory.
+
public:
- DirectoryEntry() : Name(nullptr) {}
- const char *getName() const { return Name; }
+ StringRef getName() const { return Name; }
};
/// \brief Cached information about one file (either on disk
@@ -51,7 +57,9 @@ public:
/// If the 'File' member is valid, then this FileEntry has an open file
/// descriptor for the file.
class FileEntry {
- const char *Name; // Name of the file.
+ friend class FileManager;
+
+ StringRef Name; // Name of the file.
std::string RealPathName; // Real path to the file; could be empty.
off_t Size; // File size in bytes.
time_t ModTime; // Modification time of file.
@@ -64,25 +72,16 @@ class FileEntry {
/// \brief The open file, if it is owned by the \p FileEntry.
mutable std::unique_ptr<vfs::File> File;
- friend class FileManager;
-
- void operator=(const FileEntry &) = delete;
public:
FileEntry()
: UniqueID(0, 0), IsNamedPipe(false), InPCH(false), IsValid(false)
{}
- // FIXME: this is here to allow putting FileEntry in std::map. Once we have
- // emplace, we shouldn't need a copy constructor anymore.
- /// Intentionally does not copy fields that are not set in an uninitialized
- /// \c FileEntry.
- FileEntry(const FileEntry &FE) : UniqueID(FE.UniqueID),
- IsNamedPipe(FE.IsNamedPipe), InPCH(FE.InPCH), IsValid(FE.IsValid) {
- assert(!isValid() && "Cannot copy an initialized FileEntry");
- }
+ FileEntry(const FileEntry &) = delete;
+ FileEntry &operator=(const FileEntry &) = delete;
- const char *getName() const { return Name; }
+ StringRef getName() const { return Name; }
StringRef tryGetRealPathName() const { return RealPathName; }
bool isValid() const { return IsValid; }
off_t getSize() const { return Size; }
@@ -165,7 +164,7 @@ class FileManager : public RefCountedBase<FileManager> {
// Caching.
std::unique_ptr<FileSystemStatCache> StatCache;
- bool getStatValue(const char *Path, FileData &Data, bool isFile,
+ bool getStatValue(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F);
/// Add all ancestors of the given path (pointing to either a file
@@ -285,6 +284,6 @@ public:
void PrintStats() const;
};
-} // end namespace clang
+} // end namespace clang
-#endif
+#endif // LLVM_CLANG_BASIC_FILEMANAGER_H