]> granicus.if.org Git - llvm/commitdiff
Change setDiagnosticsOutputFile to take a unique_ptr from a raw pointer (NFC)
authorMehdi Amini <mehdi.amini@apple.com>
Sat, 19 Nov 2016 18:19:41 +0000 (18:19 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Sat, 19 Nov 2016 18:19:41 +0000 (18:19 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287449 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/LLVMContext.h
lib/IR/LLVMContext.cpp
lib/LTO/LTOCodeGenerator.cpp
tools/opt/opt.cpp

index 16286d732892a4603cb68ff24325bfa0d78ddd3c..2b537ebf1fed9ec5ddb475bd5804c68a98051bc8 100644 (file)
@@ -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
index 9dac61514998ff7d38fe5af1db79ac57ea999990..94934b385de876f4d7b3350d08e511c6a23bbba8 100644 (file)
@@ -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<yaml::Output> F) {
+  pImpl->DiagnosticsOutputFile = std::move(F);
 }
 
 LLVMContext::DiagnosticHandlerTy LLVMContext::getDiagnosticHandler() const {
index d2f964e4d246fd14a00a83b87130772642ad63fc..146ad454a0d4bd5eeebe4efb618118ce3cd37888 100644 (file)
@@ -511,7 +511,7 @@ bool LTOCodeGenerator::setupOptimizationRemarks() {
       return false;
     }
     Context.setDiagnosticsOutputFile(
-        new yaml::Output(DiagnosticOutputFile->os()));
+        llvm::make_unique<yaml::Output>(DiagnosticOutputFile->os()));
   }
   return true;
 }
index 0a42c13898ab3bdc816e0688751e77e2d80cd8ff..035629a8aa4b6b8d83b778767e76d88403fdf186 100644 (file)
@@ -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...