[llvm-commits] [llvm] r99874 - in /llvm/trunk/lib/Support: Statistic.cpp Timer.cpp

Chris Lattner sabre at nondot.org
Mon Mar 29 22:01:08 PDT 2010


Author: lattner
Date: Tue Mar 30 00:01:08 2010
New Revision: 99874

URL: http://llvm.org/viewvc/llvm-project?rev=99874&view=rev
Log:
rename GetLibSupportInfoOutputFile -> CreateInfoOutputFile and
have it always return a new stream to simplify clients.

Modified:
    llvm/trunk/lib/Support/Statistic.cpp
    llvm/trunk/lib/Support/Timer.cpp

Modified: llvm/trunk/lib/Support/Statistic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Statistic.cpp?rev=99874&r1=99873&r2=99874&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Statistic.cpp (original)
+++ llvm/trunk/lib/Support/Statistic.cpp Tue Mar 30 00:01:08 2010
@@ -32,8 +32,8 @@
 #include <cstring>
 using namespace llvm;
 
-// GetLibSupportInfoOutputFile - Return a file stream to print our output on.
-namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); }
+// 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.
@@ -96,7 +96,7 @@
   if (Stats.empty()) return;
 
   // Get the stream to write to.
-  raw_ostream &OutStream = *GetLibSupportInfoOutputFile();
+  raw_ostream &OutStream = *CreateInfoOutputFile();
 
   // Figure out how long the biggest Value and Name fields are.
   unsigned MaxNameLen = 0, MaxValLen = 0;
@@ -125,9 +125,8 @@
     
   }
   
-  OutStream << '\n';  // Flush the output stream...
+  OutStream << '\n';  // Flush the output stream.
   OutStream.flush();
   
-  if (&OutStream != &outs() && &OutStream != &errs())
-    delete &OutStream;   // Close the file.
+  delete &OutStream;   // Close the file.
 }

Modified: llvm/trunk/lib/Support/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99874&r1=99873&r2=99874&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Timer.cpp (original)
+++ llvm/trunk/lib/Support/Timer.cpp Tue Mar 30 00:01:08 2010
@@ -22,8 +22,8 @@
 #include "llvm/ADT/StringMap.h"
 using namespace llvm;
 
-// GetLibSupportInfoOutputFile - Return a file stream to print our output on.
-namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); }
+// CreateInfoOutputFile - Return a file stream to print our output on.
+namespace llvm { extern raw_ostream *CreateInfoOutputFile(); }
 
 // getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
 // of constructor/destructor ordering being unspecified by C++.  Basically the
@@ -52,13 +52,13 @@
                    cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
 }
 
-// GetLibSupportInfoOutputFile - Return a file stream to print our output on.
-raw_ostream *llvm::GetLibSupportInfoOutputFile() {
+// CreateInfoOutputFile - Return a file stream to print our output on.
+raw_ostream *llvm::CreateInfoOutputFile() {
   std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
   if (LibSupportInfoOutputFilename.empty())
-    return &errs();
+    return new raw_fd_ostream(2, false); // stderr.
   if (LibSupportInfoOutputFilename == "-")
-    return &outs();
+    return new raw_fd_ostream(1, false); // stdout.
   
   std::string Error;
   raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(),
@@ -69,7 +69,7 @@
   errs() << "Error opening info-output-file '"
     << LibSupportInfoOutputFilename << " for appending!\n";
   delete Result;
-  return &errs();
+  return new raw_fd_ostream(2, false); // stderr.
 }
 
 
@@ -264,12 +264,9 @@
   if (FirstTimer != 0 || TimersToPrint.empty())
     return;
   
-  raw_ostream *OutStream = GetLibSupportInfoOutputFile();
-  
+  raw_ostream *OutStream = CreateInfoOutputFile();
   PrintQueuedTimers(*OutStream);
-  
-  if (OutStream != &errs() && OutStream != &outs())
-    delete OutStream;   // Close the file.
+  delete OutStream;   // Close the file.
 }
 
 void TimerGroup::addTimer(Timer &T) {





More information about the llvm-commits mailing list