9 #ifndef LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_FILESYSTEM_H 10 #define LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_FILESYSTEM_H 14 #include "llvm/ADT/StringMap.h" 15 #include "llvm/ADT/StringSet.h" 16 #include "llvm/Support/Allocator.h" 17 #include "llvm/Support/ErrorOr.h" 18 #include "llvm/Support/VirtualFileSystem.h" 23 namespace dependencies {
50 llvm::vfs::FileSystem &FS,
51 bool Minimize =
true);
57 bool isValid()
const {
return !MaybeStat || MaybeStat->isStatusKnown(); }
60 bool isDirectory()
const {
return MaybeStat && MaybeStat->isDirectory(); }
65 return MaybeStat.getError();
66 assert(!MaybeStat->isDirectory() &&
"not a file");
67 assert(
isValid() &&
"not initialized");
68 return StringRef(Contents);
72 llvm::ErrorOr<llvm::vfs::Status>
getStatus()
const {
73 assert(
isValid() &&
"not initialized");
79 assert(
isValid() &&
"not initialized");
80 return MaybeStat->getName();
86 return PPSkippedRangeMapping;
96 llvm::ErrorOr<llvm::vfs::Status> MaybeStat;
127 std::mutex CacheLock;
128 llvm::StringMap<SharedFileSystemEntry, llvm::BumpPtrAllocator>
Cache;
130 std::unique_ptr<CacheShard[]> CacheShards;
150 PPSkipMappings(PPSkipMappings) {}
152 llvm::ErrorOr<llvm::vfs::Status> status(
const Twine &Path)
override;
153 llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
154 openFileForRead(
const Twine &Path)
override;
161 bool IsInserted =
Cache.try_emplace(Filename, Entry).second;
163 assert(IsInserted &&
"local cache is updated more than once");
167 auto It =
Cache.find(Filename);
168 return It ==
Cache.end() ? nullptr : It->getValue();
171 llvm::ErrorOr<const CachedFileSystemEntry *>
172 getOrCreateFileSystemEntry(
const StringRef Filename);
177 llvm::StringMap<const CachedFileSystemEntry *, llvm::BumpPtrAllocator>
Cache;
188 #endif // LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_FILESYSTEM_H Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
TypePropertyCache< Private > Cache
CachedFileSystemEntry()
Default constructor creates an entry with an invalid stat.
StringRef getName() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
CachedFileSystemEntry(std::error_code Error)
static CachedFileSystemEntry createFileEntry(StringRef Filename, llvm::vfs::FileSystem &FS, bool Minimize=true)
Create an entry that represents an opened source file with minimized or original contents.
static CachedFileSystemEntry createDirectoryEntry(llvm::vfs::Status &&Stat)
Create an entry that represents a directory on the filesystem.
const PreprocessorSkippedRangeMapping & getPPSkippedRangeMapping() const
Return the mapping between location -> distance that is used to speed up the block skipping in the pr...
llvm::ErrorOr< llvm::vfs::Status > getStatus() const
Dataflow Directional Tag Classes.
llvm::DenseMap< unsigned, unsigned > PreprocessorSkippedRangeMapping
A mapping from an offset into a buffer to the number of bytes that can be skipped by the preprocessor...
CachedFileSystemEntry & operator=(CachedFileSystemEntry &&)=default
llvm::DenseMap< const llvm::MemoryBuffer *, const PreprocessorSkippedRangeMapping * > ExcludedPreprocessorDirectiveSkipMapping
The datastructure that holds the mapping between the active memory buffers and the individual skip ma...
llvm::ErrorOr< StringRef > getContents() const
An in-memory representation of a file system entity that is of interest to the dependency scanning fi...
CachedFileSystemEntry Value