Remove attribution from file headers, per discussion on llvmdev.
[oota-llvm.git] / lib / Support / Debug.cpp
index 1af23380a27b50321d02bbb95ec25e19d5d4a129..29eda26c6896b6d9ee90527b4b0d0a2e835351fb 100644 (file)
@@ -1,10 +1,10 @@
 //===-- Debug.cpp - An easy way to add debug output to your code ----------===//
-// 
+//
 //                     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.
+//
 //===----------------------------------------------------------------------===//
 //
 // This file implements a handle way of adding debugging information to your
 //
 //===----------------------------------------------------------------------===//
 
-#include "Support/Statistic.h"
-#include "Support/CommandLine.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
+using namespace llvm;
 
-namespace llvm {
-
-bool DebugFlag;  // DebugFlag - Exported boolean set by the -debug option
+bool llvm::DebugFlag;  // DebugFlag - Exported boolean set by the -debug option
 
 namespace {
 #ifndef NDEBUG
@@ -57,7 +56,7 @@ namespace {
 // specified on the command line, or if none was specified on the command line
 // with the -debug-only=X option.
 //
-bool isCurrentDebugType(const char *DebugType) {
+bool llvm::isCurrentDebugType(const char *DebugType) {
 #ifndef NDEBUG
   return CurrentDebugType.empty() || DebugType == CurrentDebugType;
 #else
@@ -65,4 +64,14 @@ bool isCurrentDebugType(const char *DebugType) {
 #endif
 }
 
-} // End llvm namespace
+// getErrorOutputStream - Returns the error output stream (std::cerr). This
+// places the std::c* I/O streams into one .cpp file and relieves the whole
+// program from having to have hundreds of static c'tor/d'tors for them.
+// 
+OStream &llvm::getErrorOutputStream(const char *DebugType) {
+  static OStream cnoout(0);
+  if (DebugFlag && isCurrentDebugType(DebugType))
+    return cerr;
+  else
+    return cnoout;
+}