14 #ifndef LLVM_CLANG_BASIC_FILEMANAGER_H 15 #define LLVM_CLANG_BASIC_FILEMANAGER_H 19 #include "llvm/ADT/DenseMap.h" 20 #include "llvm/ADT/IntrusiveRefCntPtr.h" 21 #include "llvm/ADT/SmallVector.h" 22 #include "llvm/ADT/StringMap.h" 23 #include "llvm/ADT/StringRef.h" 24 #include "llvm/Support/Allocator.h" 25 #include "llvm/Support/ErrorOr.h" 26 #include "llvm/Support/FileSystem.h" 27 #include "llvm/Support/VirtualFileSystem.h" 41 class FileSystemStatCache;
51 StringRef
getName()
const {
return Name; }
63 std::string RealPathName;
68 llvm::sys::fs::UniqueID UniqueID;
73 mutable std::unique_ptr<llvm::vfs::File> File;
77 : UniqueID(0, 0), IsNamedPipe(
false), IsValid(
false)
83 StringRef
getName()
const {
return Name; }
87 unsigned getUID()
const {
return UID; }
88 const llvm::sys::fs::UniqueID &
getUniqueID()
const {
return UniqueID; }
121 std::map<llvm::sys::fs::UniqueID, DirectoryEntry> UniqueRealDirs;
124 std::map<llvm::sys::fs::UniqueID, FileEntry> UniqueRealFiles;
142 llvm::StringMap<DirectoryEntry*, llvm::BumpPtrAllocator> SeenDirEntries;
148 llvm::StringMap<FileEntry*, llvm::BumpPtrAllocator> SeenFileEntries;
151 llvm::DenseMap<const DirectoryEntry *, llvm::StringRef> CanonicalDirNames;
154 llvm::BumpPtrAllocator CanonicalNameStorage;
158 unsigned NextFileUID;
161 unsigned NumDirLookups, NumFileLookups;
162 unsigned NumDirCacheMisses, NumFileCacheMisses;
165 std::unique_ptr<FileSystemStatCache> StatCache;
167 bool getStatValue(StringRef Path, llvm::vfs::Status &Status,
bool isFile,
168 std::unique_ptr<llvm::vfs::File> *F);
172 void addAncestorsAsVirtualDirs(StringRef Path);
175 void fillRealPathName(
FileEntry *UFE, llvm::StringRef FileName);
193 void setStatCache(std::unique_ptr<FileSystemStatCache> statCache);
196 void clearStatCache();
206 bool CacheFailure =
true);
218 bool CacheFailure =
true);
230 const FileEntry *getVirtualFile(StringRef Filename, off_t Size,
231 time_t ModificationTime);
235 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
236 getBufferForFile(
const FileEntry *Entry,
bool isVolatile =
false,
237 bool ShouldCloseOpenFile =
true);
238 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
239 getBufferForFile(StringRef Filename,
bool isVolatile =
false);
247 bool getNoncachedStatValue(StringRef Path, llvm::vfs::Status &Result);
250 void invalidateCache(
const FileEntry *Entry);
265 void GetUniqueIDMapping(
270 static void modifyFileEntry(
FileEntry *File, off_t Size,
271 time_t ModificationTime);
280 void PrintStats()
const;
285 #endif // LLVM_CLANG_BASIC_FILEMANAGER_H StringRef tryGetRealPathName() const
Implements support for file system lookup, file system caching, and directory search management...
time_t getModificationTime() const
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
const llvm::sys::fs::UniqueID & getUniqueID() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const DirectoryEntry * getDir() const
Return the directory the file lives in.
StringRef getName() const
FileSystemOptions & getFileSystemOpts()
Returns the current file system options.
bool isNamedPipe() const
Check whether the file is a named pipe (and thus can't be opened by the native FileManager methods)...
bool operator<(const FileEntry &RHS) const
Cached information about one file (either on disk or in the virtual file system). ...
const FileSystemOptions & getFileSystemOpts() const
Dataflow Directional Tag Classes.
bool isOpenForTests() const
Defines the clang::FileSystemOptions interface.
Cached information about one directory (either on disk or in the virtual file system).
Keeps track of options that affect how file operations are performed.
llvm::vfs::FileSystem & getVirtualFileSystem() const
StringRef getName() const