9#ifndef LLVM_CLANG_SERIALIZATION_MODULECACHE_H
10#define LLVM_CLANG_SERIALIZATION_MODULECACHE_H
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/STLFunctionalExtras.h"
15#include "llvm/ADT/StringMap.h"
16#include "llvm/Support/ErrorOr.h"
17#include "llvm/Support/FileSystem/UniqueID.h"
23#include <system_error>
43 llvm::StringMap<const ModuleCacheDirectory *> ByPath;
46 llvm::DenseMap<llvm::sys::fs::UniqueID, std::unique_ptr<ModuleCacheDirectory>>
63 virtual std::unique_ptr<llvm::AdvisoryLock>
86 virtual void maybePrune(StringRef Path, time_t PruneInterval,
87 time_t PruneAfter) = 0;
98 virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
99 write(StringRef Path, std::unique_ptr<llvm::MemoryBuffer> Buffer, off_t &Size,
100 time_t &ModTime) = 0;
121void maybePruneImpl(StringRef Path, time_t PruneInterval, time_t PruneAfter,
122 bool PruneTopLevel =
false,
123 llvm::function_ref<
void(StringRef)> OnPrune = {});
130llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
131writeImpl(StringRef Path, llvm::MemoryBufferRef Buffer, off_t &Size,
132 time_t &ModTime,
bool ReadBack);
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
In-memory cache for modules.
The address of an instance of this class represents the identity of a module cache directory.
virtual std::optional< bool > isDirectoryInvalidated(StringRef Directory)
Whether the build system reported that Directory changed before the build session started,...
AtomicLineLogger & getLogger()
virtual ~ModuleCache()=default
virtual llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > write(StringRef Path, std::unique_ptr< llvm::MemoryBuffer > Buffer, off_t &Size, time_t &ModTime)=0
Write the PCM contents to the given path in the module cache.
virtual const InMemoryModuleCache & getInMemoryModuleCache() const =0
virtual std::time_t getModuleTimestamp(StringRef ModuleFilename)=0
Returns the timestamp denoting the last time inputs of the module file were validated.
AtomicLineLogger & Logger
A logger to record timestamp read/write and file read/write.
virtual InMemoryModuleCache & getInMemoryModuleCache()=0
Returns this process's view of the module cache.
virtual void updateModuleTimestamp(StringRef ModuleFilename)=0
Updates the timestamp denoting the last time inputs of the module file were validated.
virtual Expected< std::unique_ptr< llvm::MemoryBuffer > > read(StringRef FileName, off_t &Size, time_t &ModTime)=0
ModuleCache(AtomicLineLogger &Logger)
virtual const ModuleCacheDirectory * getDirectoryPtr(StringRef Path)
Returns an opaque pointer representing the module cache directory.
virtual void maybePrune(StringRef Path, time_t PruneInterval, time_t PruneAfter)=0
Prune module files that haven't been accessed in a long time.
virtual std::unique_ptr< llvm::AdvisoryLock > getLock(StringRef ModuleFilename)=0
Returns lock for the given module file. The lock is initially unlocked.
Top level wrappers for InstallAPI frontend operations.
Expected< std::unique_ptr< llvm::MemoryBuffer > > readImpl(StringRef FileName, off_t &Size, time_t &ModTime)
Shared implementation of ModuleCache::read().
std::shared_ptr< ModuleCache > createCrossProcessModuleCache()
Creates new ModuleCache backed by a file system directory that may be operated on by multiple process...
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > writeImpl(StringRef Path, llvm::MemoryBufferRef Buffer, off_t &Size, time_t &ModTime, bool ReadBack)
Shared implementation of ModuleCache::write().
void maybePruneImpl(StringRef Path, time_t PruneInterval, time_t PruneAfter, bool PruneTopLevel=false, llvm::function_ref< void(StringRef)> OnPrune={})
Shared implementation of ModuleCache::maybePrune().
Diagnostic wrappers for TextAPI types for error reporting.