summaryrefslogtreecommitdiff
path: root/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-19 01:38:42 +0000
committerChris Lattner <sabre@nondot.org>2009-12-19 01:38:42 +0000
commitcd0129f5a6f0485ecac525c17a3c5dff0a19ca5f (patch)
treea6a6cd779ab13506bae631aac939fad91d058972 /lib/Support/raw_ostream.cpp
parentc63ca0a71b299ee0b8fc7dc8405d7f3c856ecfa3 (diff)
downloadllvm-cd0129f5a6f0485ecac525c17a3c5dff0a19ca5f.tar.gz
llvm-cd0129f5a6f0485ecac525c17a3c5dff0a19ca5f.tar.bz2
llvm-cd0129f5a6f0485ecac525c17a3c5dff0a19ca5f.tar.xz
Make some methods const. The only interesting change here is that
it changes raw_fd_ostream::preferred_buffer_size to return zero on a scary stat failure instead of setting the stream to an error state. This method really should not mutate the stream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91740 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r--lib/Support/raw_ostream.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 0c90e7720b..a820210f7b 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -67,7 +67,7 @@ raw_ostream::~raw_ostream() {
// An out of line virtual method to provide a home for the class vtable.
void raw_ostream::handle() {}
-size_t raw_ostream::preferred_buffer_size() {
+size_t raw_ostream::preferred_buffer_size() const {
// BUFSIZ is intended to be a reasonable default.
return BUFSIZ;
}
@@ -440,20 +440,20 @@ uint64_t raw_fd_ostream::seek(uint64_t off) {
return pos;
}
-size_t raw_fd_ostream::preferred_buffer_size() {
+size_t raw_fd_ostream::preferred_buffer_size() const {
#if !defined(_MSC_VER) && !defined(__MINGW32__) // Windows has no st_blksize.
assert(FD >= 0 && "File not yet open!");
struct stat statbuf;
- if (fstat(FD, &statbuf) == 0) {
- // If this is a terminal, don't use buffering. Line buffering
- // would be a more traditional thing to do, but it's not worth
- // the complexity.
- if (S_ISCHR(statbuf.st_mode) && isatty(FD))
- return 0;
- // Return the preferred block size.
- return statbuf.st_blksize;
- }
- error_detected();
+ if (fstat(FD, &statbuf) != 0)
+ return 0;
+
+ // If this is a terminal, don't use buffering. Line buffering
+ // would be a more traditional thing to do, but it's not worth
+ // the complexity.
+ if (S_ISCHR(statbuf.st_mode) && isatty(FD))
+ return 0;
+ // Return the preferred block size.
+ return statbuf.st_blksize;
#endif
return raw_ostream::preferred_buffer_size();
}
@@ -578,7 +578,9 @@ void raw_svector_ostream::write_impl(const char *Ptr, size_t Size) {
SetBuffer(OS.end(), OS.capacity() - OS.size());
}
-uint64_t raw_svector_ostream::current_pos() { return OS.size(); }
+uint64_t raw_svector_ostream::current_pos() const {
+ return OS.size();
+}
StringRef raw_svector_ostream::str() {
flush();
@@ -601,6 +603,6 @@ raw_null_ostream::~raw_null_ostream() {
void raw_null_ostream::write_impl(const char *Ptr, size_t Size) {
}
-uint64_t raw_null_ostream::current_pos() {
+uint64_t raw_null_ostream::current_pos() const {
return 0;
}