]> granicus.if.org Git - clang/commitdiff
simplify this code a bit more.
authorChris Lattner <sabre@nondot.org>
Sun, 17 Aug 2008 03:54:39 +0000 (03:54 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 17 Aug 2008 03:54:39 +0000 (03:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54864 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/PrintPreprocessedOutput.cpp

index 5044250fd5c553a9d66cda6092ad90c50203d751..28309860ca3cf118c28680ad757bd4f6c979878f 100644 (file)
@@ -499,23 +499,15 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP,
 
   
   // Open the output buffer.
-  static llvm::raw_ostream *OutStream;
-  
-  if (!OutFile.size() || OutFile == "-") {
-    OutStream = new llvm::raw_stdout_ostream();
-  } else {
-    std::string Err;
-    OutStream = new llvm::raw_fd_ostream(OutFile.c_str(), Err);
-    
-    if (!Err.empty()) {
-      delete OutStream;
-      fprintf(stderr, "%s\n", Err.c_str());
-      exit(1);
-    }
+  std::string Err;
+  llvm::raw_fd_ostream OS(OutFile.c_str(), Err);
+  if (!Err.empty()) {
+    fprintf(stderr, "%s\n", Err.c_str());
+    exit(1);
   }
-  OutStream->SetBufferSize(64*1024);
   
-  llvm::raw_ostream &OS = *OutStream;
+  OS.SetBufferSize(64*1024);
+  
   
   Token Tok, PrevTok;
   char Buffer[256];