From 6f408368237fdb0beb2ac1bf1d1bb7ad6124b99b Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sat, 19 Nov 2016 18:19:41 +0000 Subject: [PATCH] Change setDiagnosticsOutputFile to take a unique_ptr from a raw pointer (NFC) Summary: This makes it explicit that ownership is taken. Also replace all `new` with make_unique<> at call sites. Reviewers: anemet Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26884 llvm-svn: 287449 --- clang/lib/CodeGen/CodeGenAction.cpp | 3 ++- llvm/include/llvm/IR/LLVMContext.h | 2 +- llvm/lib/IR/LLVMContext.cpp | 4 ++-- llvm/lib/LTO/LTOCodeGenerator.cpp | 2 +- llvm/tools/opt/opt.cpp | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 6961f01..da8f372 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -195,7 +195,8 @@ namespace clang { return; } - Ctx.setDiagnosticsOutputFile(new yaml::Output(OptRecordFile->os())); + Ctx.setDiagnosticsOutputFile( + llvm::make_unique(OptRecordFile->os())); if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone) Ctx.setDiagnosticHotnessRequested(true); diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h index 16286d7..2b537eb 100644 --- a/llvm/include/llvm/IR/LLVMContext.h +++ b/llvm/include/llvm/IR/LLVMContext.h @@ -194,7 +194,7 @@ public: /// By default or if invoked with null, diagnostics are not saved in a file /// but only emitted via the diagnostic handler. Even if an output file is /// set, the handler is invoked for each diagnostic message. - void setDiagnosticsOutputFile(yaml::Output *F); + void setDiagnosticsOutputFile(std::unique_ptr F); /// \brief Get the prefix that should be printed in front of a diagnostic of /// the given \p Severity diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index 9dac615..94934b3 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -212,8 +212,8 @@ yaml::Output *LLVMContext::getDiagnosticsOutputFile() { return pImpl->DiagnosticsOutputFile.get(); } -void LLVMContext::setDiagnosticsOutputFile(yaml::Output *F) { - pImpl->DiagnosticsOutputFile.reset(F); +void LLVMContext::setDiagnosticsOutputFile(std::unique_ptr F) { + pImpl->DiagnosticsOutputFile = std::move(F); } LLVMContext::DiagnosticHandlerTy LLVMContext::getDiagnosticHandler() const { diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index d2f964e4..146ad45 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -511,7 +511,7 @@ bool LTOCodeGenerator::setupOptimizationRemarks() { return false; } Context.setDiagnosticsOutputFile( - new yaml::Output(DiagnosticOutputFile->os())); + llvm::make_unique(DiagnosticOutputFile->os())); } return true; } diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index 0a42c13..035629a 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -424,7 +424,8 @@ int main(int argc, char **argv) { errs() << EC.message() << '\n'; return 1; } - Context.setDiagnosticsOutputFile(new yaml::Output(YamlFile->os())); + Context.setDiagnosticsOutputFile( + llvm::make_unique(YamlFile->os())); } // Load the input module... -- 2.7.4