aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ModuleManager.cpp
diff options
context:
space:
mode:
authorRenato Golin <renato.golin@linaro.org>2017-03-18 12:31:32 +0000
committerRenato Golin <renato.golin@linaro.org>2017-03-18 12:31:32 +0000
commitf1966cf6467e60c60d1c3fe6fa8b669d79ecf8e9 (patch)
treeb2ada42a7d0c7f06002a987e9e75d0c0ec4ec64f /clang/lib/Serialization/ModuleManager.cpp
parente6ff30b696739aca2e86484750c68dce113712a1 (diff)
downloadllvm-f1966cf6467e60c60d1c3fe6fa8b669d79ecf8e9.zip
llvm-f1966cf6467e60c60d1c3fe6fa8b669d79ecf8e9.tar.gz
llvm-f1966cf6467e60c60d1c3fe6fa8b669d79ecf8e9.tar.bz2
Revert "Modules: Cache PCMs in memory and avoid a use-after-free"
This reverts commit r298165, as it broke the ARM builds. llvm-svn: 298185
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
-rw-r--r--clang/lib/Serialization/ModuleManager.cpp27
1 files changed, 7 insertions, 20 deletions
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index d9c9fb7..f0654fc 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Serialization/ModuleManager.h"
-#include "clang/Basic/MemoryBufferCache.h"
#include "clang/Frontend/PCHContainerOperations.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/ModuleMap.h"
@@ -138,9 +137,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
// Load the contents of the module
if (std::unique_ptr<llvm::MemoryBuffer> Buffer = lookupBuffer(FileName)) {
// The buffer was already provided for us.
- NewModule->Buffer = &PCMCache->addBuffer(FileName, std::move(Buffer));
- } else if (llvm::MemoryBuffer *Buffer = PCMCache->lookupBuffer(FileName)) {
- NewModule->Buffer = Buffer;
+ NewModule->Buffer = std::move(Buffer);
} else {
// Open the AST file.
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buf((std::error_code()));
@@ -161,7 +158,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
return Missing;
}
- NewModule->Buffer = &PCMCache->addBuffer(FileName, std::move(*Buf));
+ NewModule->Buffer = std::move(*Buf);
}
// Initialize the stream.
@@ -170,13 +167,8 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
// Read the signature eagerly now so that we can check it. Avoid calling
// ReadSignature unless there's something to check though.
if (ExpectedSignature && checkSignature(ReadSignature(NewModule->Data),
- ExpectedSignature, ErrorStr)) {
- // Try to remove the buffer. If it can't be removed, then it was already
- // validated by this process.
- if (!PCMCache->tryToRemoveBuffer(NewModule->FileName))
- FileMgr.invalidateCache(NewModule->File);
+ ExpectedSignature, ErrorStr))
return OutOfDate;
- }
// We're keeping this module. Store it everywhere.
Module = Modules[Entry] = NewModule.get();
@@ -243,12 +235,7 @@ void ModuleManager::removeModules(
// Files that didn't make it through ReadASTCore successfully will be
// rebuilt (or there was an error). Invalidate them so that we can load the
// new files that will be renamed over the old ones.
- //
- // The PCMCache tracks whether the module was succesfully loaded in another
- // thread/context; in that case, it won't need to be rebuilt (and we can't
- // safely invalidate it anyway).
- if (LoadedSuccessfully.count(&*victim) == 0 &&
- !PCMCache->tryToRemoveBuffer(victim->FileName))
+ if (LoadedSuccessfully.count(&*victim) == 0)
FileMgr.invalidateCache(victim->File);
}
@@ -305,10 +292,10 @@ void ModuleManager::moduleFileAccepted(ModuleFile *MF) {
ModulesInCommonWithGlobalIndex.push_back(MF);
}
-ModuleManager::ModuleManager(FileManager &FileMgr, MemoryBufferCache &PCMCache,
+ModuleManager::ModuleManager(FileManager &FileMgr,
const PCHContainerReader &PCHContainerRdr)
- : FileMgr(FileMgr), PCMCache(&PCMCache), PCHContainerRdr(PCHContainerRdr),
- GlobalIndex(), FirstVisitState(nullptr) {}
+ : FileMgr(FileMgr), PCHContainerRdr(PCHContainerRdr), GlobalIndex(),
+ FirstVisitState(nullptr) {}
ModuleManager::~ModuleManager() { delete FirstVisitState; }