14#ifndef LLVM_CLANG_BASIC_FILEMANAGER_H
15#define LLVM_CLANG_BASIC_FILEMANAGER_H
21#include "llvm/ADT/DenseMap.h"
22#include "llvm/ADT/IntrusiveRefCntPtr.h"
23#include "llvm/ADT/PointerUnion.h"
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/ADT/StringMap.h"
26#include "llvm/ADT/StringRef.h"
27#include "llvm/Support/Allocator.h"
28#include "llvm/Support/ErrorOr.h"
29#include "llvm/Support/FileSystem.h"
30#include "llvm/Support/VirtualFileSystem.h"
44class FileSystemStatCache;
56 llvm::SpecificBumpPtrAllocator<FileEntry> FilesAlloc;
57 llvm::SpecificBumpPtrAllocator<DirectoryEntry> DirsAlloc;
60 llvm::DenseMap<llvm::sys::fs::UniqueID, DirectoryEntry *> UniqueRealDirs;
63 llvm::DenseMap<llvm::sys::fs::UniqueID, FileEntry *> UniqueRealFiles;
86 llvm::StringMap<llvm::ErrorOr<DirectoryEntry &>, llvm::BumpPtrAllocator>
94 llvm::StringMap<llvm::ErrorOr<FileEntryRef::MapValue>, llvm::BumpPtrAllocator>
101 std::unique_ptr<llvm::StringMap<llvm::ErrorOr<FileEntryRef::MapValue>>>
102 SeenBypassFileEntries;
108 llvm::DenseMap<const void *, llvm::StringRef> CanonicalNames;
111 llvm::BumpPtrAllocator CanonicalNameStorage;
115 unsigned NextFileUID;
118 unsigned NumDirLookups = 0;
119 unsigned NumFileLookups = 0;
120 unsigned NumDirCacheMisses = 0;
121 unsigned NumFileCacheMisses = 0;
124 std::unique_ptr<FileSystemStatCache> StatCache;
126 std::error_code getStatValue(StringRef
Path, llvm::vfs::Status &Status,
127 bool isFile, std::unique_ptr<llvm::vfs::File> *F,
132 void addAncestorsAsVirtualDirs(StringRef
Path);
153 void setStatCache(std::unique_ptr<FileSystemStatCache> statCache);
172 bool CacheFailure =
true);
176 bool CacheFailure =
true) {
177 return llvm::expectedToOptional(
getDirectoryRef(DirName, CacheFailure));
194 "getOptionalDirectoryRef()")
196 getDirectory(StringRef DirName,
bool CacheFailure =
true);
232 bool OpenFile =
false,
233 bool CacheFailure =
true,
246 bool OpenFile =
false,
247 bool CacheFailure =
true) {
248 return llvm::expectedToOptional(
267 this->FS = std::move(FS);
278 "getVirtualFileRef()")
299 bool RequiresNullTerminator =
true,
300 std::optional<int64_t> MaybeLimit =
std::nullopt,
304 bool RequiresNullTerminator =
true,
305 std::optional<int64_t> MaybeLimit =
std::nullopt,
306 bool IsText =
true)
const {
307 return getBufferForFileImpl(
Filename,
308 MaybeLimit.value_or(-1),
309 isVolatile, RequiresNullTerminator, IsText);
313 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
314 getBufferForFileImpl(StringRef
Filename, int64_t FileSize,
bool isVolatile,
315 bool RequiresNullTerminator,
bool IsText)
const;
317 DirectoryEntry *&getRealDirEntry(
const llvm::vfs::Status &Status);
327 llvm::vfs::Status &
Result);
Defines interfaces for clang::DirectoryEntry and clang::DirectoryEntryRef.
Defines interfaces for clang::FileEntry and clang::FileEntryRef.
Defines the clang::FileSystemOptions interface.