Switch some utilities in clang-cc to take a stream instead of a 
filename (or unconditionally using stdout).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72085 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 767ae14..4bf9257 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -1748,12 +1748,20 @@
       
   case GeneratePTH: {
     llvm::TimeRegion Timer(ClangFrontendTimer);
-    CacheTokens(PP, OutputFile);
+    if (OutputFile.empty() || OutputFile == "-") {
+      // FIXME: Don't fail this way.
+      // FIXME: Verify that we can actually seek in the given file.
+      llvm::cerr << "ERROR: PTH requires an seekable file for output!\n";
+      ::exit(1);
+    }
+    OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
+    CacheTokens(PP, static_cast<llvm::raw_fd_ostream*>(OS.get()));
     ClearSourceMgr = true;
     break;
   }      
 
   case PrintPreprocessedInput:
+    OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
     break;
       
   case ParseNoop:
@@ -1761,7 +1769,8 @@
     
   case ParsePrintCallbacks: {
     llvm::TimeRegion Timer(ClangFrontendTimer);
-    ParseFile(PP, CreatePrintParserActionsAction(PP));
+    OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
+    ParseFile(PP, CreatePrintParserActionsAction(PP, OS.get()));
     ClearSourceMgr = true;
     break;
   }
@@ -1773,15 +1782,16 @@
   }
       
   case RewriteMacros:
-    RewriteMacrosInInput(PP, InFile, OutputFile);
+    OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
+    RewriteMacrosInInput(PP, OS.get());
     ClearSourceMgr = true;
     break;
       
-  case RewriteTest: {
-    DoRewriteTest(PP, InFile, OutputFile);
+  case RewriteTest:
+    OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
+    DoRewriteTest(PP, OS.get());
     ClearSourceMgr = true;
     break;
-  }
 
   case FixIt:
     llvm::TimeRegion Timer(ClangFrontendTimer);
@@ -1906,7 +1916,7 @@
     ClearSourceMgr = true;
   } else if (PA == PrintPreprocessedInput){  // -E mode.
     llvm::TimeRegion Timer(ClangFrontendTimer);
-    DoPrintPreprocessedInput(PP, OutputFile);
+    DoPrintPreprocessedInput(PP, OS.get());
     ClearSourceMgr = true;
   }