summaryrefslogtreecommitdiffstats
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.h93
1 files changed, 60 insertions, 33 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h
index 5c7d9eb..b00f2b7 100644
--- a/include/clang/Basic/FileManager.h
+++ b/include/clang/Basic/FileManager.h
@@ -6,9 +6,10 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-// This file defines the FileManager interface.
-//
+///
+/// \file
+/// \brief Defines the clang::FileManager interface and associated types.
+///
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FILEMANAGER_H
@@ -40,9 +41,8 @@ namespace clang {
class FileManager;
class FileSystemStatCache;
-/// DirectoryEntry - Cached information about one directory (either on
-/// the disk or in the virtual file system).
-///
+/// \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;
@@ -51,10 +51,11 @@ public:
const char *getName() const { return Name; }
};
-/// FileEntry - Cached information about one file (either on the disk
-/// or in the virtual file system). If the 'FD' member is valid, then
-/// this FileEntry has an open file descriptor for the file.
+/// \brief Cached information about one file (either on disk
+/// or in the virtual file system).
///
+/// If the 'FD' member is valid, then this FileEntry has an open file
+/// descriptor for the file.
class FileEntry {
const char *Name; // Name of the file.
off_t Size; // File size in bytes.
@@ -96,8 +97,7 @@ public:
time_t getModificationTime() const { return ModTime; }
mode_t getFileMode() const { return FileMode; }
- /// getDir - Return the directory the file lives in.
- ///
+ /// \brief Return the directory the file lives in.
const DirectoryEntry *getDir() const { return Dir; }
bool operator<(const FileEntry &RHS) const {
@@ -105,10 +105,12 @@ public:
}
};
-/// FileManager - Implements support for file system lookup, file system
-/// caching, and directory search management. This also handles more advanced
-/// properties, such as uniquing files based on "inode", so that a file with two
-/// names (e.g. symlinked) will be treated as a single file.
+/// \brief Implements support for file system lookup, file system caching,
+/// and directory search management.
+///
+/// This also handles more advanced properties, such as uniquing files based
+/// on "inode", so that a file with two names (e.g. symlinked) will be treated
+/// as a single file.
///
class FileManager : public RefCountedBase<FileManager> {
FileSystemOptions FileSystemOpts;
@@ -116,30 +118,37 @@ class FileManager : public RefCountedBase<FileManager> {
class UniqueDirContainer;
class UniqueFileContainer;
- /// UniqueRealDirs/UniqueRealFiles - Cache for existing real
- /// directories/files.
- ///
+ /// \brief Cache for existing real directories.
UniqueDirContainer &UniqueRealDirs;
+
+ /// \brief Cache for existing real files.
UniqueFileContainer &UniqueRealFiles;
- /// \brief The virtual directories that we have allocated. For each
- /// virtual file (e.g. foo/bar/baz.cpp), we add all of its parent
+ /// \brief The virtual directories that we have allocated.
+ ///
+ /// For each virtual file (e.g. foo/bar/baz.cpp), we add all of its parent
/// directories (foo/ and foo/bar/) here.
SmallVector<DirectoryEntry*, 4> VirtualDirectoryEntries;
/// \brief The virtual files that we have allocated.
SmallVector<FileEntry*, 4> VirtualFileEntries;
- /// SeenDirEntries/SeenFileEntries - This is a cache that maps paths
- /// to directory/file entries (either real or virtual) we have
- /// looked up. The actual Entries for real directories/files are
+ /// \brief A cache that maps paths to directory entries (either real or
+ /// virtual) we have looked up
+ ///
+ /// The actual Entries for real directories/files are
/// owned by UniqueRealDirs/UniqueRealFiles above, while the Entries
/// for virtual directories/files are owned by
/// VirtualDirectoryEntries/VirtualFileEntries above.
///
llvm::StringMap<DirectoryEntry*, llvm::BumpPtrAllocator> SeenDirEntries;
+
+ /// \brief A cache that maps paths to file entries (either real or
+ /// virtual) we have looked up.
+ ///
+ /// \see SeenDirEntries
llvm::StringMap<FileEntry*, llvm::BumpPtrAllocator> SeenFileEntries;
- /// NextFileUID - Each FileEntry we create is assigned a unique ID #.
+ /// \brief Each FileEntry we create is assigned a unique ID #.
///
unsigned NextFileUID;
@@ -177,8 +186,13 @@ public:
/// \brief Removes the specified FileSystemStatCache object from the manager.
void removeStatCache(FileSystemStatCache *statCache);
- /// getDirectory - Lookup, cache, and verify the specified directory
- /// (real or virtual). This returns NULL if the directory doesn't exist.
+ /// \brief Removes all FileSystemStatCache objects from the manager.
+ void clearStatCaches();
+
+ /// \brief Lookup, cache, and verify the specified directory (real or
+ /// virtual).
+ ///
+ /// This returns NULL if the directory doesn't exist.
///
/// \param CacheFailure If true and the file does not exist, we'll cache
/// the failure to find this file.
@@ -186,7 +200,9 @@ public:
bool CacheFailure = true);
/// \brief Lookup, cache, and verify the specified file (real or
- /// virtual). This returns NULL if the file doesn't exist.
+ /// virtual).
+ ///
+ /// This returns NULL if the file doesn't exist.
///
/// \param OpenFile if true and the file exists, it will be opened.
///
@@ -199,23 +215,29 @@ public:
const FileSystemOptions &getFileSystemOptions() { return FileSystemOpts; }
/// \brief Retrieve a file entry for a "virtual" file that acts as
- /// if there were a file with the given name on disk. The file
- /// itself is not accessed.
+ /// if there were a file with the given name on disk.
+ ///
+ /// The file itself is not accessed.
const FileEntry *getVirtualFile(StringRef Filename, off_t Size,
time_t ModificationTime);
/// \brief Open the specified file as a MemoryBuffer, returning a new
/// MemoryBuffer if successful, otherwise returning null.
llvm::MemoryBuffer *getBufferForFile(const FileEntry *Entry,
- std::string *ErrorStr = 0);
+ std::string *ErrorStr = 0,
+ bool isVolatile = false);
llvm::MemoryBuffer *getBufferForFile(StringRef Filename,
std::string *ErrorStr = 0);
- // getNoncachedStatValue - Will get the 'stat' information for the given path.
- // If the path is relative, it will be resolved against the WorkingDir of the
- // FileManager's FileSystemOptions.
+ /// \brief Get the 'stat' information for the given \p Path.
+ ///
+ /// If the path is relative, it will be resolved against the WorkingDir of the
+ /// FileManager's FileSystemOptions.
bool getNoncachedStatValue(StringRef Path, struct stat &StatBuf);
+ /// \brief Remove the real file \p Entry from the cache.
+ void invalidateCache(const FileEntry *Entry);
+
/// \brief If path is not absolute and FileSystemOptions set the working
/// directory, the path is modified to be relative to the given
/// working directory.
@@ -226,6 +248,11 @@ public:
void GetUniqueIDMapping(
SmallVectorImpl<const FileEntry *> &UIDToFiles) const;
+ /// \brief Modifies the size and modification time of a previously created
+ /// FileEntry. Use with caution.
+ static void modifyFileEntry(FileEntry *File, off_t Size,
+ time_t ModificationTime);
+
void PrintStats() const;
};
OpenPOWER on IntegriCloud