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/FileSystem/UniqueID.h"
22#include <system_error>
42 llvm::StringMap<const ModuleCacheDirectory *> ByPath;
45 llvm::DenseMap<llvm::sys::fs::UniqueID, std::unique_ptr<ModuleCacheDirectory>>
62 virtual std::unique_ptr<llvm::AdvisoryLock>
85 virtual void maybePrune(StringRef Path, time_t PruneInterval,
86 time_t PruneAfter) = 0;
93 virtual std::error_code
write(StringRef Path, llvm::MemoryBufferRef Buffer,
94 off_t &Size, time_t &ModTime) = 0;
115void maybePruneImpl(StringRef Path, time_t PruneInterval, time_t PruneAfter,
116 bool PruneTopLevel =
false,
117 llvm::function_ref<
void(StringRef)> OnPrune = {});
120std::error_code
writeImpl(StringRef Path, llvm::MemoryBufferRef Buffer,
121 off_t &Size, time_t &ModTime);
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 std::error_code write(StringRef Path, llvm::MemoryBufferRef 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...
std::error_code writeImpl(StringRef Path, llvm::MemoryBufferRef Buffer, off_t &Size, time_t &ModTime)
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.