ABataev updated the summary for this revision.
ABataev updated this revision to Diff 35698.
ABataev added a comment.

Reworked patch after some discussion


http://reviews.llvm.org/D13128

Files:
  lib/Support/raw_ostream.cpp
  test/Other/empty.ll

Index: lib/Support/raw_ostream.cpp
===================================================================
--- lib/Support/raw_ostream.cpp
+++ lib/Support/raw_ostream.cpp
@@ -490,8 +490,8 @@
 static int getFD(StringRef Filename, std::error_code &EC,
                  sys::fs::OpenFlags Flags) {
   // Handle "-" as stdout. Note that when we do this, we consider ourself
-  // the owner of stdout. This means that we can do things like close the
-  // file descriptor when we're done and set the "binary" flag globally.
+  // the owner of stdout. This means that we can do things like set the 
"binary"
+  // flag globally.
   if (Filename == "-") {
     EC = std::error_code();
     // If user requested binary then put stdout into binary mode if
@@ -523,6 +523,10 @@
     return;
   }
 
+  // Do not close standard input/output streams.
+  if (FD <= STDERR_FILENO)
+    ShouldClose = false;
+
   // Get the starting position.
   off_t loc = ::lseek(FD, 0, SEEK_CUR);
 #ifdef LLVM_ON_WIN32
Index: test/Other/empty.ll
===================================================================
--- test/Other/empty.ll
+++ test/Other/empty.ll
@@ -0,0 +1,2 @@
+; RUN: /export/bpart/_users/abataev/development/llvm_commit3/build/bin/opt 
-analyze -time-passes -rewrite-map-file=- -stats -info-output-file=- %s 2>&1 | 
FileCheck %s
+; CHECK: Total Execution Time


Index: lib/Support/raw_ostream.cpp
===================================================================
--- lib/Support/raw_ostream.cpp
+++ lib/Support/raw_ostream.cpp
@@ -490,8 +490,8 @@
 static int getFD(StringRef Filename, std::error_code &EC,
                  sys::fs::OpenFlags Flags) {
   // Handle "-" as stdout. Note that when we do this, we consider ourself
-  // the owner of stdout. This means that we can do things like close the
-  // file descriptor when we're done and set the "binary" flag globally.
+  // the owner of stdout. This means that we can do things like set the "binary"
+  // flag globally.
   if (Filename == "-") {
     EC = std::error_code();
     // If user requested binary then put stdout into binary mode if
@@ -523,6 +523,10 @@
     return;
   }
 
+  // Do not close standard input/output streams.
+  if (FD <= STDERR_FILENO)
+    ShouldClose = false;
+
   // Get the starting position.
   off_t loc = ::lseek(FD, 0, SEEK_CUR);
 #ifdef LLVM_ON_WIN32
Index: test/Other/empty.ll
===================================================================
--- test/Other/empty.ll
+++ test/Other/empty.ll
@@ -0,0 +1,2 @@
+; RUN: /export/bpart/_users/abataev/development/llvm_commit3/build/bin/opt -analyze -time-passes -rewrite-map-file=- -stats -info-output-file=- %s 2>&1 | FileCheck %s
+; CHECK: Total Execution Time
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to