[PATCH] D26884: Change setDiagnosticsOutputFile to take a unique_ptr from a raw pointer (NFC)
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 18 20:41:08 PST 2016
mehdi_amini created this revision.
mehdi_amini added a reviewer: anemet.
mehdi_amini added a subscriber: llvm-commits.
This makes it explicit that ownership is taken. Also replace all `new`
with make_unique<> at call sites.
https://reviews.llvm.org/D26884
Files:
clang/lib/CodeGen/CodeGenAction.cpp
llvm/include/llvm/IR/LLVMContext.h
llvm/lib/IR/LLVMContext.cpp
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/tools/opt/opt.cpp
Index: llvm/tools/opt/opt.cpp
===================================================================
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -424,7 +424,8 @@
errs() << EC.message() << '\n';
return 1;
}
- Context.setDiagnosticsOutputFile(new yaml::Output(YamlFile->os()));
+ Context.setDiagnosticsOutputFile(
+ llvm::make_unique<yaml::Output>(YamlFile->os()));
}
// Load the input module...
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -511,7 +511,7 @@
return false;
}
Context.setDiagnosticsOutputFile(
- new yaml::Output(DiagnosticOutputFile->os()));
+ llvm::make_unique<yaml::Output>(DiagnosticOutputFile->os()));
}
return true;
}
Index: llvm/lib/IR/LLVMContext.cpp
===================================================================
--- llvm/lib/IR/LLVMContext.cpp
+++ llvm/lib/IR/LLVMContext.cpp
@@ -212,8 +212,8 @@
return pImpl->DiagnosticsOutputFile.get();
}
-void LLVMContext::setDiagnosticsOutputFile(yaml::Output *F) {
- pImpl->DiagnosticsOutputFile.reset(F);
+void LLVMContext::setDiagnosticsOutputFile(std::unique_ptr<yaml::Output> F) {
+ pImpl->DiagnosticsOutputFile = std::move(F);
}
LLVMContext::DiagnosticHandlerTy LLVMContext::getDiagnosticHandler() const {
Index: llvm/include/llvm/IR/LLVMContext.h
===================================================================
--- llvm/include/llvm/IR/LLVMContext.h
+++ llvm/include/llvm/IR/LLVMContext.h
@@ -194,7 +194,7 @@
/// 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<yaml::Output> F);
/// \brief Get the prefix that should be printed in front of a diagnostic of
/// the given \p Severity
Index: clang/lib/CodeGen/CodeGenAction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -195,7 +195,8 @@
return;
}
- Ctx.setDiagnosticsOutputFile(new yaml::Output(OptRecordFile->os()));
+ Ctx.setDiagnosticsOutputFile(
+ llvm::make_unique<yaml::Output>(OptRecordFile->os()));
if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
Ctx.setDiagnosticHotnessRequested(true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26884.78618.patch
Type: text/x-patch
Size: 2641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161119/8b85aeee/attachment.bin>
More information about the llvm-commits
mailing list