[llvm] r287449 - Change setDiagnosticsOutputFile to take a unique_ptr from a raw pointer (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 19 10:19:41 PST 2016
Author: mehdi_amini
Date: Sat Nov 19 12:19:41 2016
New Revision: 287449
URL: http://llvm.org/viewvc/llvm-project?rev=287449&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/IR/LLVMContext.h
llvm/trunk/lib/IR/LLVMContext.cpp
llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/include/llvm/IR/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/LLVMContext.h?rev=287449&r1=287448&r2=287449&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/IR/LLVMContext.h Sat Nov 19 12:19:41 2016
@@ -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<yaml::Output> F);
/// \brief Get the prefix that should be printed in front of a diagnostic of
/// the given \p Severity
Modified: llvm/trunk/lib/IR/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=287449&r1=287448&r2=287449&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContext.cpp (original)
+++ llvm/trunk/lib/IR/LLVMContext.cpp Sat Nov 19 12:19:41 2016
@@ -212,8 +212,8 @@ yaml::Output *LLVMContext::getDiagnostic
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 {
Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=287449&r1=287448&r2=287449&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Sat Nov 19 12:19:41 2016
@@ -511,7 +511,7 @@ bool LTOCodeGenerator::setupOptimization
return false;
}
Context.setDiagnosticsOutputFile(
- new yaml::Output(DiagnosticOutputFile->os()));
+ llvm::make_unique<yaml::Output>(DiagnosticOutputFile->os()));
}
return true;
}
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=287449&r1=287448&r2=287449&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Sat Nov 19 12:19:41 2016
@@ -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<yaml::Output>(YamlFile->os()));
}
// Load the input module...
More information about the llvm-commits
mailing list