File indexing completed on 2026-05-10 08:36:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_CLANG_BASIC_FILESYSTEMSTATCACHE_H
0015 #define LLVM_CLANG_BASIC_FILESYSTEMSTATCACHE_H
0016
0017 #include "clang/Basic/LLVM.h"
0018 #include "llvm/ADT/StringMap.h"
0019 #include "llvm/ADT/StringRef.h"
0020 #include "llvm/Support/Allocator.h"
0021 #include "llvm/Support/FileSystem.h"
0022 #include "llvm/Support/VirtualFileSystem.h"
0023 #include <cstdint>
0024 #include <ctime>
0025 #include <memory>
0026 #include <optional>
0027 #include <string>
0028 #include <utility>
0029
0030 namespace clang {
0031
0032
0033
0034
0035 class FileSystemStatCache {
0036 virtual void anchor();
0037
0038 public:
0039 virtual ~FileSystemStatCache() = default;
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 static std::error_code get(StringRef Path, llvm::vfs::Status &Status,
0052 bool isFile, std::unique_ptr<llvm::vfs::File> *F,
0053 FileSystemStatCache *Cache,
0054 llvm::vfs::FileSystem &FS, bool IsText = true);
0055
0056 protected:
0057
0058
0059
0060 virtual std::error_code getStat(StringRef Path, llvm::vfs::Status &Status,
0061 bool isFile,
0062 std::unique_ptr<llvm::vfs::File> *F,
0063 llvm::vfs::FileSystem &FS) = 0;
0064 };
0065
0066
0067
0068
0069 class MemorizeStatCalls : public FileSystemStatCache {
0070 public:
0071
0072 llvm::StringMap<llvm::vfs::Status, llvm::BumpPtrAllocator> StatCalls;
0073
0074 using iterator =
0075 llvm::StringMap<llvm::vfs::Status,
0076 llvm::BumpPtrAllocator>::const_iterator;
0077
0078 iterator begin() const { return StatCalls.begin(); }
0079 iterator end() const { return StatCalls.end(); }
0080
0081 std::error_code getStat(StringRef Path, llvm::vfs::Status &Status,
0082 bool isFile,
0083 std::unique_ptr<llvm::vfs::File> *F,
0084 llvm::vfs::FileSystem &FS) override;
0085 };
0086
0087 }
0088
0089 #endif