10#include "llvm/Support/MemoryBuffer.h"
16 auto I = PCMs.find(Filename);
19 if (I->second.IsFinal)
26 std::unique_ptr<llvm::MemoryBuffer> Buffer,
27 off_t Size, time_t ModTime) {
28 auto Insertion = PCMs.insert(
29 std::make_pair(Filename, PCM(std::move(Buffer), Size, ModTime)));
30 assert(Insertion.second &&
"Already has a PCM");
31 return *Insertion.first->second.Buffer;
36 std::unique_ptr<llvm::MemoryBuffer> Buffer,
37 off_t Size, time_t ModTime) {
38 auto &PCM = PCMs[Filename];
39 assert(!PCM.IsFinal &&
"Trying to override finalized PCM?");
40 assert(!PCM.Buffer &&
"Trying to override tentative PCM?");
41 PCM.Buffer = std::move(Buffer);
43 PCM.ModTime = ModTime;
50 time_t &ModTime)
const {
51 auto I = PCMs.find(Filename);
54 Size = I->second.Size;
55 ModTime = I->second.ModTime;
56 return I->second.Buffer.get();
68 auto I = PCMs.find(Filename);
69 assert(I != PCMs.end() &&
"PCM to remove is unknown...");
71 auto &PCM = I->second;
72 assert(PCM.Buffer &&
"PCM to remove is scheduled to be built...");
82 auto I = PCMs.find(Filename);
83 assert(I != PCMs.end() &&
"PCM to finalize is unknown...");
85 auto &PCM = I->second;
86 assert(PCM.Buffer &&
"Trying to finalize a dropped PCM...");
llvm::MemoryBuffer * lookupPCM(llvm::StringRef Filename, off_t &Size, time_t &ModTime) const
Get a pointer to the PCM if it exists and set Size and ModTime to its on-disk size and modification t...
llvm::MemoryBuffer & addPCM(llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer, off_t Size, time_t ModTime)
Store the PCM under the Filename.
State getPCMState(llvm::StringRef Filename) const
Get the state of the PCM.
State
There are four states for a PCM.
bool isPCMFinal(llvm::StringRef Filename) const
Check whether the PCM is final and has been shown to work.
void finalizePCM(llvm::StringRef Filename)
Mark a PCM as final.
bool tryToDropPCM(llvm::StringRef Filename)
Try to remove a buffer from the cache.
bool shouldBuildPCM(llvm::StringRef Filename) const
Check whether the PCM is waiting to be built.
llvm::MemoryBuffer & addBuiltPCM(llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer, off_t Size, time_t ModTime)
Store a just-built PCM under the Filename.
The JSON file list parser is used to communicate input to InstallAPI.