Patch by Csaba Hruska!

"Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch
covers the AST library, but ignores Analysis lib."


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56185 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index ec809ab..9c74301 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -24,6 +24,7 @@
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Support/Timer.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/OwningPtr.h"
 #include <fstream>
 
@@ -35,10 +36,11 @@
 namespace {
   class DeclPrinter {
   public:
-    std::ostream& Out;
+    llvm::raw_ostream& Out;
 
-    DeclPrinter(std::ostream* out) : Out(out ? *out : *llvm::cerr.stream()) {}
-    DeclPrinter() : Out(*llvm::cerr.stream()) {}
+    DeclPrinter(llvm::raw_ostream* out) : Out(out ? *out : llvm::errs()) {}
+    DeclPrinter() : Out(llvm::errs()) {}
+    virtual ~DeclPrinter();
     
     void PrintDecl(Decl *D);
     void PrintFunctionDeclStart(FunctionDecl *FD);    
@@ -56,6 +58,10 @@
   };
 } // end anonymous namespace
 
+DeclPrinter::~DeclPrinter() {
+  Out.flush();
+}
+
 void DeclPrinter:: PrintDecl(Decl *D) {
   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     PrintFunctionDeclStart(FD);
@@ -422,7 +428,7 @@
 namespace {
   class ASTPrinter : public ASTConsumer, public DeclPrinter {
   public:
-    ASTPrinter(std::ostream* o = NULL) : DeclPrinter(o) {}
+    ASTPrinter(llvm::raw_ostream* o = NULL) : DeclPrinter(o) {}
     
     virtual void HandleTopLevelDecl(Decl *D) {
       PrintDecl(D);
@@ -430,7 +436,7 @@
   };
 }
 
-ASTConsumer *clang::CreateASTPrinter(std::ostream* out) {
+ASTConsumer *clang::CreateASTPrinter(llvm::raw_ostream* out) {
   return new ASTPrinter(out);
 }