//===- InMemoryModuleCache.cpp - Cache for loaded memory buffers ----------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "clang/Serialization/InMemoryModuleCache.h" #include "llvm/Support/MemoryBuffer.h" using namespace clang; InMemoryModuleCache::State InMemoryModuleCache::getPCMState(llvm::StringRef Filename) const { auto I = PCMs.find(Filename); if (I == PCMs.end()) return Unknown; if (I->second.IsFinal) return Final; return I->second.Buffer ? Tentative : ToBuild; } llvm::MemoryBuffer & InMemoryModuleCache::addPCM(llvm::StringRef Filename, std::unique_ptr Buffer) { auto Insertion = PCMs.insert(std::make_pair(Filename, std::move(Buffer))); assert(Insertion.second && "Already has a PCM"); return *Insertion.first->second.Buffer; } llvm::MemoryBuffer & InMemoryModuleCache::addBuiltPCM(llvm::StringRef Filename, std::unique_ptr Buffer) { auto &PCM = PCMs[Filename]; assert(!PCM.IsFinal && "Trying to override finalized PCM?"); assert(!PCM.Buffer && "Trying to override tentative PCM?"); PCM.Buffer = std::move(Buffer); PCM.IsFinal = true; return *PCM.Buffer; } llvm::MemoryBuffer * InMemoryModuleCache::lookupPCM(llvm::StringRef Filename) const { auto I = PCMs.find(Filename); if (I == PCMs.end()) return nullptr; return I->second.Buffer.get(); } bool InMemoryModuleCache::isPCMFinal(llvm::StringRef Filename) const { return getPCMState(Filename) == Final; } bool InMemoryModuleCache::shouldBuildPCM(llvm::StringRef Filename) const { return getPCMState(Filename) == ToBuild; } bool InMemoryModuleCache::tryToDropPCM(llvm::StringRef Filename) { auto I = PCMs.find(Filename); assert(I != PCMs.end() && "PCM to remove is unknown..."); auto &PCM = I->second; assert(PCM.Buffer && "PCM to remove is scheduled to be built..."); if (PCM.IsFinal) return true; PCM.Buffer.reset(); return false; } void InMemoryModuleCache::finalizePCM(llvm::StringRef Filename) { auto I = PCMs.find(Filename); assert(I != PCMs.end() && "PCM to finalize is unknown..."); auto &PCM = I->second; assert(PCM.Buffer && "Trying to finalize a dropped PCM..."); PCM.IsFinal = true; } ap'>AgeCommit message (Expand)Author 2018-01-18implement 32-bit compat support for raidframe.mrg 2013-02-19Check for RUMP programs before using them.joerg 2011-10-15Fix cut-and-paste-o that casused the raid1_normal test case to have nogson 2011-08-09Add missing RUMP_SERVER export, so the "normal" test does not fail withmartin 2011-07-29Note that PR kern/44251 is fixed.oster 2011-05-14Instead of doing 'atf_check ... sh -c foo', just do 'atf_check ... -x foo'.jmmv 2011-03-01PR#44239 is now fixed, remove the xfail from the test.riz 2011-02-04convert tests from oldstyle dd rif/rof to newstyle dd | rump.ddpooka 2010-12-30Substitute a surgical rump_server configuration for rump_allserverpooka 2010-12-18test case for PR kern/44251pooka 2010-12-18Check that raid1 and raid5 can serve data after a component haspooka 2010-12-17fix editing artifactpooka 2010-12-15fix post-move testsdir. duhpooka 2010-12-15"A few seconds later" I realized the kernel directory is dev/raidframe,pooka