From: Nico Weber Date: Mon, 15 Jul 2019 17:12:08 +0000 (+0000) Subject: Use unique_ptr instead of manual delete in one place. No behavior change. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e98c48e7a31f475440b3fb4abb26bc61c758c372;p=clang Use unique_ptr instead of manual delete in one place. No behavior change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@366084 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index 931dd19f04..5f3026e6ce 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -153,30 +153,28 @@ int Compilation::ExecuteCommand(const Command &C, if ((getDriver().CCPrintOptions || getArgs().hasArg(options::OPT_v)) && !getDriver().CCGenDiagnostics) { raw_ostream *OS = &llvm::errs(); + std::unique_ptr OwnedStream; // Follow gcc implementation of CC_PRINT_OPTIONS; we could also cache the // output stream. if (getDriver().CCPrintOptions && getDriver().CCPrintOptionsFilename) { std::error_code EC; - OS = new llvm::raw_fd_ostream(getDriver().CCPrintOptionsFilename, EC, - llvm::sys::fs::F_Append | - llvm::sys::fs::F_Text); + OwnedStream.reset(new llvm::raw_fd_ostream( + getDriver().CCPrintOptionsFilename, EC, + llvm::sys::fs::F_Append | llvm::sys::fs::F_Text)); if (EC) { getDriver().Diag(diag::err_drv_cc_print_options_failure) << EC.message(); FailingCommand = &C; - delete OS; return 1; } + OS = OwnedStream.get(); } if (getDriver().CCPrintOptions) *OS << "[Logging clang options]"; C.Print(*OS, "\n", /*Quote=*/getDriver().CCPrintOptions); - - if (OS != &llvm::errs()) - delete OS; } std::string Error;