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
This commit is contained in:
Mehdi Amini 2016-11-19 18:19:41 +00:00
parent cd4d111105
commit dbccde2834
4 changed files with 6 additions and 5 deletions

View 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

View 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 {

View 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;
}

View 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...