mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Change raw_ostream so that it doesn't call llvm_report_error
immediately on every output error. Instead, add a flag to raw_ostream, and set the flag whenever an error is detected. The flag can be queried and cleared from the public API. This gives applications more flexibility to handling errors in application-specific ways. If the flag is not cleared when the raw_ostream is destructed, llvm_report_error is called from the destructor. This ensures that errors are not implicitly silenced, and provides convenient default behavior for tools like llc and opt. Clients wishing to avoid llvm_report_error calls from raw_ostream should check for errors and clear the error flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75857 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -44,6 +44,16 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
raw_ostream::~raw_ostream() {
|
||||
delete [] OutBufStart;
|
||||
|
||||
// If there are any pending errors, report them now. Clients wishing
|
||||
// to avoid llvm_report_error calls should check for errors with
|
||||
// has_error() and clear the error flag with clear_error() before
|
||||
// destructing raw_ostream objects which may have errors.
|
||||
if (Error)
|
||||
llvm_report_error("IO failure on output stream.");
|
||||
}
|
||||
|
||||
// An out of line virtual method to provide a home for the class vtable.
|
||||
void raw_ostream::handle() {}
|
||||
@@ -282,7 +292,7 @@ raw_fd_ostream::~raw_fd_ostream() {
|
||||
flush();
|
||||
if (ShouldClose)
|
||||
if (::close(FD) != 0)
|
||||
llvm_report_error("IO failure closing output stream.");
|
||||
error_detected();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +300,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, unsigned Size) {
|
||||
assert (FD >= 0 && "File already closed.");
|
||||
pos += Size;
|
||||
if (::write(FD, Ptr, Size) != (ssize_t) Size)
|
||||
llvm_report_error("IO failure writing to output stream.");
|
||||
error_detected();
|
||||
}
|
||||
|
||||
void raw_fd_ostream::close() {
|
||||
@@ -298,7 +308,7 @@ void raw_fd_ostream::close() {
|
||||
ShouldClose = false;
|
||||
flush();
|
||||
if (::close(FD) != 0)
|
||||
llvm_report_error("IO failure closing output stream.");
|
||||
error_detected();
|
||||
FD = -1;
|
||||
}
|
||||
|
||||
@@ -306,7 +316,7 @@ uint64_t raw_fd_ostream::seek(uint64_t off) {
|
||||
flush();
|
||||
pos = ::lseek(FD, off, SEEK_SET);
|
||||
if (pos != off)
|
||||
llvm_report_error("IO failure seeking on output stream.");
|
||||
error_detected();
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user