r366084 - Use unique_ptr instead of manual delete in one place. No behavior change.
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 10:12:08 PDT 2019
Author: nico
Date: Mon Jul 15 10:12:08 2019
New Revision: 366084
URL: http://llvm.org/viewvc/llvm-project?rev=366084&view=rev
Log:
Use unique_ptr instead of manual delete in one place. No behavior change.
Modified:
cfe/trunk/lib/Driver/Compilation.cpp
Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=366084&r1=366083&r2=366084&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Mon Jul 15 10:12:08 2019
@@ -153,30 +153,28 @@ int Compilation::ExecuteCommand(const Co
if ((getDriver().CCPrintOptions ||
getArgs().hasArg(options::OPT_v)) && !getDriver().CCGenDiagnostics) {
raw_ostream *OS = &llvm::errs();
+ std::unique_ptr<llvm::raw_fd_ostream> 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;
More information about the cfe-commits
mailing list