diff options
author | Renato Golin <renato.golin@linaro.org> | 2017-03-18 12:31:32 +0000 |
---|---|---|
committer | Renato Golin <renato.golin@linaro.org> | 2017-03-18 12:31:32 +0000 |
commit | f1966cf6467e60c60d1c3fe6fa8b669d79ecf8e9 (patch) | |
tree | b2ada42a7d0c7f06002a987e9e75d0c0ec4ec64f /clang/lib/Frontend/CompilerInstance.cpp | |
parent | e6ff30b696739aca2e86484750c68dce113712a1 (diff) | |
download | bcm5719-llvm-f1966cf6467e60c60d1c3fe6fa8b669d79ecf8e9.tar.gz bcm5719-llvm-f1966cf6467e60c60d1c3fe6fa8b669d79ecf8e9.zip |
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/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index f660429e49d..bf15460824f 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -13,7 +13,6 @@ #include "clang/AST/Decl.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/FileManager.h" -#include "clang/Basic/MemoryBufferCache.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/Version.h" @@ -56,15 +55,9 @@ using namespace clang; CompilerInstance::CompilerInstance( std::shared_ptr<PCHContainerOperations> PCHContainerOps, - MemoryBufferCache *SharedPCMCache) - : ModuleLoader(/* BuildingModule = */ SharedPCMCache), - Invocation(new CompilerInvocation()), - PCMCache(SharedPCMCache ? SharedPCMCache : new MemoryBufferCache), - ThePCHContainerOperations(std::move(PCHContainerOps)) { - // Don't allow this to invalidate buffers in use by others. - if (SharedPCMCache) - getPCMCache().finalizeCurrentBuffers(); -} + bool BuildingModule) + : ModuleLoader(BuildingModule), Invocation(new CompilerInvocation()), + ThePCHContainerOperations(std::move(PCHContainerOps)) {} CompilerInstance::~CompilerInstance() { assert(OutputFiles.empty() && "Still output files in flight?"); @@ -135,8 +128,6 @@ IntrusiveRefCntPtr<ASTReader> CompilerInstance::getModuleManager() const { return ModuleManager; } void CompilerInstance::setModuleManager(IntrusiveRefCntPtr<ASTReader> Reader) { - assert(PCMCache.get() == &Reader->getModuleManager().getPCMCache() && - "Expected ASTReader to use the same PCM cache"); ModuleManager = std::move(Reader); } @@ -379,7 +370,7 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { getDiagnostics(), getLangOpts(), &getTarget()); PP = std::make_shared<Preprocessor>( Invocation->getPreprocessorOptsPtr(), getDiagnostics(), getLangOpts(), - getSourceManager(), getPCMCache(), *HeaderInfo, *this, PTHMgr, + getSourceManager(), *HeaderInfo, *this, PTHMgr, /*OwnsHeaderSearch=*/true, TUKind); PP->Initialize(getTarget(), getAuxTarget()); @@ -1082,11 +1073,9 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance, Invocation->getModuleHash() && "Module hash mismatch!"); // Construct a compiler instance that will be used to actually create the - // module. Since we're sharing a PCMCache, - // CompilerInstance::CompilerInstance is responsible for finalizing the - // buffers to prevent use-after-frees. + // module. CompilerInstance Instance(ImportingInstance.getPCHContainerOperations(), - &ImportingInstance.getPreprocessor().getPCMCache()); + /*BuildingModule=*/true); auto &Inv = *Invocation; Instance.setInvocation(std::move(Invocation)); |