summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-18 01:34:52 +0000
committerDan Gohman <gohman@apple.com>2010-08-18 01:34:52 +0000
commitd2da32711d8780a20df4554d41754bd0bc7fa35f (patch)
tree29a346f94a6f0bbfa2e60083d2e7625a577a7c00 /lib/Support
parent5083912dd79249a8954fd3e1e381a0cd7c624fbd (diff)
downloadllvm-d2da32711d8780a20df4554d41754bd0bc7fa35f.tar.gz
llvm-d2da32711d8780a20df4554d41754bd0bc7fa35f.tar.bz2
llvm-d2da32711d8780a20df4554d41754bd0bc7fa35f.tar.xz
Revert r111321. This doesn't fix a problem.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/raw_ostream.cpp42
1 files changed, 19 insertions, 23 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 76c83d16ac..ac118a91a3 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -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);