11#include "llvm/Support/MemoryBuffer.h"
17 auto I = PCMs.find(Filename);
20 if (I->second.IsFinal)
27 std::unique_ptr<llvm::MemoryBuffer> Buffer,
28 off_t Size, time_t ModTime) {
29 Logger.log() <<
"pcm_add: " << Filename;
30 auto Insertion = PCMs.insert(
31 std::make_pair(Filename, PCM(std::move(Buffer), Size, ModTime)));
32 assert(Insertion.second &&
"Already has a PCM");
33 return *Insertion.first->second.Buffer;
38 std::unique_ptr<llvm::MemoryBuffer> Buffer,
39 off_t Size, time_t ModTime) {
40 Logger.log() <<
"pcm_add_built: " << Filename;
41 auto &PCM = PCMs[Filename];
42 assert(!PCM.IsFinal &&
"Trying to override finalized PCM?");
43 assert(!PCM.Buffer &&
"Trying to override tentative PCM?");
44 PCM.Buffer = std::move(Buffer);
46 PCM.ModTime = ModTime;
53 time_t &ModTime)
const {
54 Logger.log() <<
"pcm_read_cached: " << Filename;
55 auto I = PCMs.find(Filename);
58 Size = I->second.Size;
59 ModTime = I->second.ModTime;
60 return I->second.Buffer.get();
72 auto I = PCMs.find(Filename);
73 assert(I != PCMs.end() &&
"PCM to remove is unknown...");
75 auto &PCM = I->second;
76 assert(PCM.Buffer &&
"PCM to remove is scheduled to be built...");
79 Logger.log() <<
"pcm_not_dropped: " << Filename;
83 Logger.log() <<
"pcm_dropped: " << Filename;
89 Logger.log() <<
"pcm_finalized: " << Filename;
91 auto I = PCMs.find(Filename);
92 assert(I != PCMs.end() &&
"PCM to finalize is unknown...");
94 auto &PCM = I->second;
95 assert(PCM.Buffer &&
"Trying to finalize a dropped PCM...");
Defines a logger where each line is written atomically to the file.
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.