Simplify error path using OwningPtr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98722 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index edd19d7..5d399bd 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -109,12 +109,11 @@
unsigned argc, char **argv,
Diagnostic &Diags) {
std::string ErrorInfo;
- llvm::raw_ostream *OS =
- new llvm::raw_fd_ostream(DiagOpts.DumpBuildInformation.c_str(), ErrorInfo);
+ llvm::OwningPtr<llvm::raw_ostream> OS(
+ new llvm::raw_fd_ostream(DiagOpts.DumpBuildInformation.c_str(), ErrorInfo));
if (!ErrorInfo.empty()) {
Diags.Report(diag::err_fe_unable_to_open_logfile)
<< DiagOpts.DumpBuildInformation << ErrorInfo;
- delete OS;
return;
}
@@ -125,7 +124,7 @@
// Chain in a diagnostic client which will log the diagnostics.
DiagnosticClient *Logger =
- new TextDiagnosticPrinter(*OS, DiagOpts, /*OwnsOutputStream=*/true);
+ new TextDiagnosticPrinter(*OS.take(), DiagOpts, /*OwnsOutputStream=*/true);
Diags.setClient(new ChainedDiagnosticClient(Diags.getClient(), Logger));
}