15 #ifndef LLVM_CLANG_BASIC_FILEMANAGER_H 16 #define LLVM_CLANG_BASIC_FILEMANAGER_H 20 #include "llvm/ADT/DenseMap.h" 21 #include "llvm/ADT/IntrusiveRefCntPtr.h" 22 #include "llvm/ADT/SmallVector.h" 23 #include "llvm/ADT/StringMap.h" 24 #include "llvm/ADT/StringRef.h" 25 #include "llvm/Support/Allocator.h" 26 #include "llvm/Support/ErrorOr.h" 27 #include "llvm/Support/FileSystem.h" 28 #include "llvm/Support/VirtualFileSystem.h" 42 class FileSystemStatCache;
52 StringRef
getName()
const {
return Name; }
64 std::string RealPathName;
69 llvm::sys::fs::UniqueID UniqueID;
76 mutable std::unique_ptr<llvm::vfs::File> File;
81 DeferredOpen(
false) {}
86 StringRef
getName()
const {
return Name; }
90 unsigned getUID()
const {
return UID; }
91 const llvm::sys::fs::UniqueID &
getUniqueID()
const {
return UniqueID; }
127 std::map<llvm::sys::fs::UniqueID, DirectoryEntry> UniqueRealDirs;
130 std::map<llvm::sys::fs::UniqueID, FileEntry> UniqueRealFiles;
148 llvm::StringMap<DirectoryEntry*, llvm::BumpPtrAllocator> SeenDirEntries;
154 llvm::StringMap<FileEntry*, llvm::BumpPtrAllocator> SeenFileEntries;
157 llvm::DenseMap<const DirectoryEntry *, llvm::StringRef> CanonicalDirNames;
160 llvm::BumpPtrAllocator CanonicalNameStorage;
164 unsigned NextFileUID;
167 unsigned NumDirLookups, NumFileLookups;
168 unsigned NumDirCacheMisses, NumFileCacheMisses;
171 std::unique_ptr<FileSystemStatCache> StatCache;
173 bool getStatValue(StringRef Path,
FileData &Data,
bool isFile,
174 std::unique_ptr<llvm::vfs::File> *F);
178 void addAncestorsAsVirtualDirs(StringRef Path);
181 void fillRealPathName(
FileEntry *UFE, llvm::StringRef FileName);
195 void setStatCache(std::unique_ptr<FileSystemStatCache> statCache);
198 void clearStatCache();
208 bool CacheFailure =
true);
220 bool CacheFailure =
true);
234 const FileEntry *getVirtualFile(StringRef Filename, off_t Size,
235 time_t ModificationTime);
239 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
240 getBufferForFile(
const FileEntry *Entry,
bool isVolatile =
false,
241 bool ShouldCloseOpenFile =
true);
242 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
243 getBufferForFile(StringRef Filename,
bool isVolatile =
false);
251 bool getNoncachedStatValue(StringRef Path, llvm::vfs::Status &Result);
254 void invalidateCache(
const FileEntry *Entry);
269 void GetUniqueIDMapping(
274 static void modifyFileEntry(
FileEntry *File, off_t Size,
275 time_t ModificationTime);
284 void PrintStats()
const;
289 #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
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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.
IntrusiveRefCntPtr< llvm::vfs::FileSystem > getVirtualFileSystem() const
StringRef getName() const