Share some code that is common between integer and
[oota-llvm.git] / lib / Support / Timer.cpp
index a39f169cb7bed35d547d40de9b806473a44700cc..9cbb3c705c5471b5f187f4099ef362051511d256 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/System/Process.h"
 #include <algorithm>
 #include <fstream>
 #include <functional>
-#include <iostream>
 #include <map>
 using namespace llvm;
 
@@ -39,12 +39,12 @@ static std::string &getLibSupportInfoOutputFilename() {
 }
 
 namespace {
-  cl::opt<bool>
+  static cl::opt<bool>
   TrackSpace("track-memory", cl::desc("Enable -time-passes memory "
                                       "tracking (this may be slow)"),
              cl::Hidden);
 
-  cl::opt<std::string, true>
+  static cl::opt<std::string, true>
   InfoOutputFilename("info-output-file", cl::value_desc("filename"),
                      cl::desc("File to append -stats and -timer output to"),
                    cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
@@ -263,17 +263,17 @@ std::ostream *
 llvm::GetLibSupportInfoOutputFile() {
   std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
   if (LibSupportInfoOutputFilename.empty())
-    return &std::cerr;
+    return cerr.stream();
   if (LibSupportInfoOutputFilename == "-")
-    return &std::cout;
+    return cout.stream();
 
   std::ostream *Result = new std::ofstream(LibSupportInfoOutputFilename.c_str(),
                                            std::ios::app);
   if (!Result->good()) {
-    std::cerr << "Error opening info-output-file '"
-              << LibSupportInfoOutputFilename << " for appending!\n";
+    cerr << "Error opening info-output-file '"
+         << LibSupportInfoOutputFilename << " for appending!\n";
     delete Result;
-    return &std::cerr;
+    return cerr.stream();
   }
   return Result;
 }
@@ -342,7 +342,7 @@ void TimerGroup::removeTimer() {
 
     TimersToPrint.clear();
 
-    if (OutStream != &std::cerr && OutStream != &std::cout)
+    if (OutStream != cerr.stream() && OutStream != cout.stream())
       delete OutStream;   // Close the file...
   }