Index: include/llvm/Support/raw_os_ostream.h =================================================================== --- include/llvm/Support/raw_os_ostream.h +++ include/llvm/Support/raw_os_ostream.h @@ -27,6 +27,12 @@ /// write_impl - See raw_ostream::write_impl. void write_impl(const char *Ptr, size_t Size) override; + /// Implement optional seek support. + bool supportsSeeking() override { return true; } + + /// Implement optional seek support. + uint64_t seek(uint64_t off) override; + /// current_pos - Return the current position within the stream, not /// counting the bytes currently in the buffer. uint64_t current_pos() const override; Index: include/llvm/Support/raw_ostream.h =================================================================== --- include/llvm/Support/raw_ostream.h +++ include/llvm/Support/raw_ostream.h @@ -95,6 +95,12 @@ virtual ~raw_ostream(); + /// Seek support is optional. + virtual bool supportsSeeking() { return false; } + + /// Optional seek support. Defaults to not changing the file position. + virtual uint64_t seek(uint64_t off) { return current_pos(); }; + /// tell - Return the current offset with the file. uint64_t tell() const { return current_pos() + GetNumBytesInBuffer(); } @@ -426,11 +432,11 @@ /// fsync. void close(); - bool supportsSeeking() { return SupportsSeeking; } + bool supportsSeeking() override { return SupportsSeeking; } /// Flushes the stream and repositions the underlying file descriptor position /// to the offset specified from the beginning of the file. - uint64_t seek(uint64_t off); + uint64_t seek(uint64_t off) override; raw_ostream &changeColor(enum Colors colors, bool bold=false, bool bg=false) override; Index: lib/Support/raw_os_ostream.cpp =================================================================== --- lib/Support/raw_os_ostream.cpp +++ lib/Support/raw_os_ostream.cpp @@ -26,4 +26,9 @@ OS.write(Ptr, Size); } +uint64_t raw_os_ostream::seek(uint64_t off) { + OS.seekp(off); + return current_pos(); +}; + uint64_t raw_os_ostream::current_pos() const { return OS.tellp(); }