From 6beb6aa8f0f6fa20e8c8de7a17f39b101ed0da59 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 10 Aug 2014 19:56:51 +0000 Subject: Recommit 213307: unique_ptr-ify ownership of ASTConsumers (reverted in r213325) After post-commit review and community discussion, this seems like a reasonable direction to continue, making ownership semantics explicit in the source using the type system. llvm-svn: 215323 --- clang/lib/CodeGen/CodeGenAction.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenAction.cpp') diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index d319d220dc5..a7dbd4ae159 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -607,8 +607,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) @@ -646,12 +646,12 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, CoverageInfo = new CoverageSourceInfo; CI.getPreprocessor().addPPCallbacks(CoverageInfo); } - BEConsumer = new BackendConsumer(BA, CI.getDiagnostics(), CI.getCodeGenOpts(), - CI.getTargetOpts(), CI.getLangOpts(), - CI.getFrontendOpts().ShowTimers, InFile, - LinkModuleToUse, OS.release(), *VMContext, - CoverageInfo); - 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, CoverageInfo); + BEConsumer = Result.get(); + return std::move(Result); } void CodeGenAction::ExecuteAction() { -- cgit v1.2.3