From a51666a4d624a745df90e1c84777fb7a644ff80b Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 17 Jul 2014 20:40:36 +0000 Subject: unique_ptr-ify ownership of ASTConsumers (after fixing a bug in MultiplexConsumer I noticed the ownership of the nested consumers was implemented with raw pointers - so this fixes that... and follows the source back to its origin pushing unique_ptr ownership up through there too) llvm-svn: 213307 --- clang/lib/CodeGen/CodeGenAction.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenAction.cpp') diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 559c2ef4bad..0c949492685 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -590,8 +590,8 @@ static raw_ostream *GetOutputStream(CompilerInstance &CI, llvm_unreachable("Invalid action!"); } -ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { +std::unique_ptr +CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { BackendAction BA = static_cast(Act); std::unique_ptr OS(GetOutputStream(CI, InFile, BA)); if (BA != Backend_EmitNothing && !OS) @@ -623,11 +623,12 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, LinkModuleToUse = ModuleOrErr.get(); } - BEConsumer = new BackendConsumer(BA, CI.getDiagnostics(), CI.getCodeGenOpts(), - CI.getTargetOpts(), CI.getLangOpts(), - CI.getFrontendOpts().ShowTimers, InFile, - LinkModuleToUse, OS.release(), *VMContext); - return BEConsumer; + auto Result = llvm::make_unique( + BA, CI.getDiagnostics(), CI.getCodeGenOpts(), CI.getTargetOpts(), + CI.getLangOpts(), (bool)CI.getFrontendOpts().ShowTimers, InFile, + LinkModuleToUse, OS.release(), *VMContext); + BEConsumer = Result.get(); + return std::move(Result); } void CodeGenAction::ExecuteAction() { -- cgit v1.2.3