Replace std::iostreams with raw_ostream in TableGen.
 - Sorry, I can't help myself.

 - No intended functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74742 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp
index fb80302..6015814 100644
--- a/utils/TableGen/TableGen.cpp
+++ b/utils/TableGen/TableGen.cpp
@@ -18,11 +18,11 @@
 #include "Record.h"
 #include "TGParser.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Streams.h"
 #include "llvm/System/Signals.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
 #include "CallingConvEmitter.h"
 #include "CodeEmitterGen.h"
 #include "RegisterInfoEmitter.h"
@@ -37,8 +37,6 @@
 #include "ClangDiagnosticsEmitter.h"
 #include <algorithm>
 #include <cstdio>
-#include <fstream>
-#include <ios>
 using namespace llvm;
 
 enum ActionType {
@@ -140,7 +138,8 @@
   std::string ErrorStr;
   MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr);
   if (F == 0) {
-    cerr << "Could not open input file '" + Filename + "': " << ErrorStr <<"\n";
+    errs() << "Could not open input file '" + Filename + "': " 
+           << ErrorStr <<"\n";
     return true;
   }
   
@@ -166,12 +165,14 @@
   if (ParseFile(InputFilename, IncludeDirs, SrcMgr))
     return 1;
 
-  std::ostream *Out = cout.stream();
+  raw_ostream *Out = &outs();
   if (OutputFilename != "-") {
-    Out = new std::ofstream(OutputFilename.c_str());
+    std::string Error;
+    Out = new raw_fd_ostream(OutputFilename.c_str(), false, Error);
 
-    if (!Out->good()) {
-      cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
+    if (!Error.empty()) {
+      errs() << argv[0] << ": error opening " << OutputFilename 
+             << ":" << Error << "\n";
       return 1;
     }
 
@@ -246,23 +247,23 @@
       return 1;
     }
     
-    if (Out != cout.stream()) 
+    if (Out != &outs())
       delete Out;                               // Close the file
     return 0;
     
   } catch (const TGError &Error) {
-    cerr << argv[0] << ": error:\n";
+    errs() << argv[0] << ": error:\n";
     PrintError(Error.getLoc(), Error.getMessage());
     
   } catch (const std::string &Error) {
-    cerr << argv[0] << ": " << Error << "\n";
+    errs() << argv[0] << ": " << Error << "\n";
   } catch (const char *Error) {
-    cerr << argv[0] << ": " << Error << "\n";
+    errs() << argv[0] << ": " << Error << "\n";
   } catch (...) {
-    cerr << argv[0] << ": Unknown unexpected exception occurred.\n";
+    errs() << argv[0] << ": Unknown unexpected exception occurred.\n";
   }
   
-  if (Out != cout.stream()) {
+  if (Out != &outs()) {
     delete Out;                             // Close the file
     std::remove(OutputFilename.c_str());    // Remove the file, it's broken
   }