diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-16 22:28:34 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-16 22:28:34 +0000 |
commit | b94ab5ffbd23393af5cd5b3d162daa4b83e79360 (patch) | |
tree | cf631c464f9c141ce4eb642547400f69203c178a /llvm/lib/Support/Statistic.cpp | |
parent | 533336a3684d1b610c8bef0703b2317a99d568a4 (diff) | |
download | bcm5719-llvm-b94ab5ffbd23393af5cd5b3d162daa4b83e79360.tar.gz bcm5719-llvm-b94ab5ffbd23393af5cd5b3d162daa4b83e79360.zip |
Simplify memory management with std::unique_ptr.
llvm-svn: 255831
Diffstat (limited to 'llvm/lib/Support/Statistic.cpp')
-rw-r--r-- | llvm/lib/Support/Statistic.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp index ee6c1305cdb..e49d1cbe063 100644 --- a/llvm/lib/Support/Statistic.cpp +++ b/llvm/lib/Support/Statistic.cpp @@ -34,9 +34,6 @@ #include <cstring> using namespace llvm; -// CreateInfoOutputFile - Return a file stream to print our output on. -namespace llvm { extern raw_ostream *CreateInfoOutputFile(); } - /// -stats - Command line option to cause transformations to emit stats about /// what they did. /// @@ -145,20 +142,18 @@ void llvm::PrintStatistics() { if (Stats.Stats.empty()) return; // Get the stream to write to. - raw_ostream &OutStream = *CreateInfoOutputFile(); - PrintStatistics(OutStream); - delete &OutStream; // Close the file. + std::unique_ptr<raw_ostream> OutStream = CreateInfoOutputFile(); + PrintStatistics(*OutStream); + #else // Check if the -stats option is set instead of checking // !Stats.Stats.empty(). In release builds, Statistics operators // do nothing, so stats are never Registered. if (Enabled) { // Get the stream to write to. - raw_ostream &OutStream = *CreateInfoOutputFile(); - OutStream << "Statistics are disabled. " - << "Build with asserts or with -DLLVM_ENABLE_STATS\n"; - OutStream.flush(); - delete &OutStream; // Close the file. + std::unique_ptr<raw_ostream> OutStream = CreateInfoOutputFile(); + (*OutStream) << "Statistics are disabled. " + << "Build with asserts or with -DLLVM_ENABLE_STATS\n"; } #endif } |