diff options
author | David Blaikie <dblaikie@gmail.com> | 2017-01-06 19:49:01 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2017-01-06 19:49:01 +0000 |
commit | ea4395ebcd37905487b7a978db2f460bc576a5d1 (patch) | |
tree | 92303c3c362a7eee408868cfa554f15683b0c02d /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 9cbcc5ff0b325ef2c0638e6c5c365b35a1e4f087 (diff) | |
download | bcm5719-llvm-ea4395ebcd37905487b7a978db2f460bc576a5d1.tar.gz bcm5719-llvm-ea4395ebcd37905487b7a978db2f460bc576a5d1.zip |
Reapply "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and CodeCompleteConsumer"
Aleksey Shlypanikov pointed out my mistake in migrating an explicit
unique_ptr to auto - I was expecting the function returned a unique_ptr,
but instead it returned a raw pointer - introducing a leak.
Thanks Aleksey!
This reapplies r291184, reverted in r291249.
llvm-svn: 291270
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 6f39d48f596..afcaa6e8787 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -66,8 +66,9 @@ CompilerInstance::~CompilerInstance() { assert(OutputFiles.empty() && "Still output files in flight?"); } -void CompilerInstance::setInvocation(CompilerInvocation *Value) { - Invocation = Value; +void CompilerInstance::setInvocation( + std::shared_ptr<CompilerInvocation> Value) { + Invocation = std::move(Value); } bool CompilerInstance::shouldBuildGlobalModuleIndex() const { @@ -1019,8 +1020,8 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance, = ImportingInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap(); // Construct a compiler invocation for creating this module. - IntrusiveRefCntPtr<CompilerInvocation> Invocation - (new CompilerInvocation(ImportingInstance.getInvocation())); + auto Invocation = + std::make_shared<CompilerInvocation>(ImportingInstance.getInvocation()); PreprocessorOptions &PPOpts = Invocation->getPreprocessorOpts(); @@ -1076,7 +1077,8 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance, // module. CompilerInstance Instance(ImportingInstance.getPCHContainerOperations(), /*BuildingModule=*/true); - Instance.setInvocation(&*Invocation); + auto &Inv = *Invocation; + Instance.setInvocation(std::move(Invocation)); Instance.createDiagnostics(new ForwardingDiagnosticConsumer( ImportingInstance.getDiagnosticClient()), @@ -1098,7 +1100,7 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance, // between all of the module CompilerInstances. Other than that, we don't // want to produce any dependency output from the module build. Instance.setModuleDepCollector(ImportingInstance.getModuleDepCollector()); - Invocation->getDependencyOutputOpts() = DependencyOutputOptions(); + Inv.getDependencyOutputOpts() = DependencyOutputOptions(); // Get or create the module map that we'll use to build this module. std::string InferredModuleMapContent; |