clang 20.0.0git
|
In-memory cache for modules. More...
#include "clang/Serialization/InMemoryModuleCache.h"
Public Types | |
enum | State { Unknown , Tentative , ToBuild , Final } |
There are four states for a PCM. More... | |
Public Member Functions | |
State | getPCMState (llvm::StringRef Filename) const |
Get the state of the PCM. | |
llvm::MemoryBuffer & | addPCM (llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer) |
Store the PCM under the Filename. | |
llvm::MemoryBuffer & | addBuiltPCM (llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer) |
Store a just-built PCM under the Filename. | |
bool | tryToDropPCM (llvm::StringRef Filename) |
Try to remove a buffer from the cache. | |
void | finalizePCM (llvm::StringRef Filename) |
Mark a PCM as final. | |
llvm::MemoryBuffer * | lookupPCM (llvm::StringRef Filename) const |
Get a pointer to the pCM if it exists; else nullptr. | |
bool | isPCMFinal (llvm::StringRef Filename) const |
Check whether the PCM is final and has been shown to work. | |
bool | shouldBuildPCM (llvm::StringRef Filename) const |
Check whether the PCM is waiting to be built. | |
In-memory cache for modules.
This is a cache for modules for use across a compilation, sharing state between the CompilerInstances in an implicit modules build. It must be shared by each CompilerInstance, ASTReader, ASTWriter, and ModuleManager that are coordinating.
Critically, it ensures that a single process has a consistent view of each PCM. This is used by CompilerInstance when building PCMs to ensure that each ModuleManager sees the same files.
Definition at line 29 of file InMemoryModuleCache.h.
There are four states for a PCM.
It must monotonically increase.
Enumerator | |
---|---|
Unknown | |
Tentative | |
ToBuild | |
Final |
Definition at line 56 of file InMemoryModuleCache.h.
llvm::MemoryBuffer & InMemoryModuleCache::addBuiltPCM | ( | llvm::StringRef | Filename, |
std::unique_ptr< llvm::MemoryBuffer > | Buffer | ||
) |
Store a just-built PCM under the Filename.
Definition at line 33 of file InMemoryModuleCache.cpp.
References Filename.
Referenced by clang::ASTWriter::WriteAST().
llvm::MemoryBuffer & InMemoryModuleCache::addPCM | ( | llvm::StringRef | Filename, |
std::unique_ptr< llvm::MemoryBuffer > | Buffer | ||
) |
Store the PCM under the Filename.
Definition at line 25 of file InMemoryModuleCache.cpp.
References Filename.
Referenced by clang::serialization::ModuleManager::addModule().
void InMemoryModuleCache::finalizePCM | ( | llvm::StringRef | Filename | ) |
Mark a PCM as final.
Definition at line 73 of file InMemoryModuleCache.cpp.
References Filename.
InMemoryModuleCache::State InMemoryModuleCache::getPCMState | ( | llvm::StringRef | Filename | ) | const |
Get the state of the PCM.
Definition at line 15 of file InMemoryModuleCache.cpp.
References Filename, Final, Tentative, ToBuild, and Unknown.
Referenced by isPCMFinal(), and shouldBuildPCM().
bool InMemoryModuleCache::isPCMFinal | ( | llvm::StringRef | Filename | ) | const |
Check whether the PCM is final and has been shown to work.
Definition at line 51 of file InMemoryModuleCache.cpp.
References Filename, Final, and getPCMState().
llvm::MemoryBuffer * InMemoryModuleCache::lookupPCM | ( | llvm::StringRef | Filename | ) | const |
Get a pointer to the pCM if it exists; else nullptr.
Definition at line 44 of file InMemoryModuleCache.cpp.
References Filename.
Referenced by clang::ASTReader::readASTFileControlBlock().
bool InMemoryModuleCache::shouldBuildPCM | ( | llvm::StringRef | Filename | ) | const |
Check whether the PCM is waiting to be built.
Definition at line 55 of file InMemoryModuleCache.cpp.
References Filename, getPCMState(), and ToBuild.
bool InMemoryModuleCache::tryToDropPCM | ( | llvm::StringRef | Filename | ) |
Try to remove a buffer from the cache.
No effect if state is Final.
Definition at line 59 of file InMemoryModuleCache.cpp.
References Filename.