Revert r111321. This doesn't fix a problem.
authorDan Gohman <gohman@apple.com>
Wed, 18 Aug 2010 01:34:52 +0000 (01:34 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 18 Aug 2010 01:34:52 +0000 (01:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111339 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/raw_ostream.cpp

index 76c83d16ac801c3cd1eb84c2f5a415834e41e970..ac118a91a3f6b19660d9002693dca3919a979d7c 100644 (file)
@@ -415,32 +415,16 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
 
 raw_fd_ostream::~raw_fd_ostream() {
   if (FD < 0) return;
-  if (!ShouldClose) {
-    flush();
-    return;
-  }
-  
-  bool HadError = has_error();
-  close();
-
-  // If we had a failure closing the stream, there is no way for the client to
-  // handle it, just eat the failure.
-  if (!HadError && has_error())
-    clear_error();
-}
-
-void raw_fd_ostream::close() {
-  assert(ShouldClose);
-  ShouldClose = false;
   flush();
-  while (::close(FD) != 0)
-    if (errno != EINTR) {
-      error_detected();
-      break;
-    }
-  FD = -1;
+  if (ShouldClose)
+    while (::close(FD) != 0)
+      if (errno != EINTR) {
+        error_detected();
+        break;
+      }
 }
 
+
 void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
   assert(FD >= 0 && "File already closed.");
   pos += Size;
@@ -477,6 +461,18 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
   } while (Size > 0);
 }
 
+void raw_fd_ostream::close() {
+  assert(ShouldClose);
+  ShouldClose = false;
+  flush();
+  while (::close(FD) != 0)
+    if (errno != EINTR) {
+      error_detected();
+      break;
+    }
+  FD = -1;
+}
+
 uint64_t raw_fd_ostream::seek(uint64_t off) {
   flush();
   pos = ::lseek(FD, off, SEEK_SET);