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/RewriteMacros.cpp b/tools/clang-cc/RewriteMacros.cpp
index d601f86..c9c4444 100644
--- a/tools/clang-cc/RewriteMacros.cpp
+++ b/tools/clang-cc/RewriteMacros.cpp
@@ -85,8 +85,7 @@
 
 
 /// RewriteMacrosInInput - Implement -rewrite-macros mode.
-void clang::RewriteMacrosInInput(Preprocessor &PP,const std::string &InFileName,
-                                 const std::string &OutFileName) {
+void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
   SourceManager &SM = PP.getSourceManager();
   
   Rewriter Rewrite;
@@ -202,35 +201,15 @@
     Expansion += ' ';
     RB.InsertTextBefore(InsertPos, &Expansion[0], Expansion.size());
   }
-  
-  // Create the output file.
-  llvm::OwningPtr<llvm::raw_ostream> OwnedStream;
-  llvm::raw_ostream *OutFile;
-  if (OutFileName == "-") {
-    OutFile = &llvm::outs();
-  } else if (!OutFileName.empty()) {
-    std::string Err;
-    OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(), false, Err);
-    OwnedStream.reset(OutFile);
-  } else if (InFileName == "-") {
-    OutFile = &llvm::outs();
-  } else {
-    llvm::sys::Path Path(InFileName);
-    Path.eraseSuffix();
-    Path.appendSuffix("cpp");
-    std::string Err;
-    OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), false, Err);
-    OwnedStream.reset(OutFile);
-  }
 
   // Get the buffer corresponding to MainFileID.  If we haven't changed it, then
   // we are done.
   if (const RewriteBuffer *RewriteBuf = 
       Rewrite.getRewriteBufferFor(SM.getMainFileID())) {
     //printf("Changed:\n");
-    *OutFile << std::string(RewriteBuf->begin(), RewriteBuf->end());
+    *OS << std::string(RewriteBuf->begin(), RewriteBuf->end());
   } else {
     fprintf(stderr, "No changes\n");
   }
-  OutFile->flush();
+  OS->flush();
 }