summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/raw_ostream.h16
-rw-r--r--lib/Support/raw_ostream.cpp1
2 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h
index 8242f04e23..22fb38485d 100644
--- a/include/llvm/Support/raw_ostream.h
+++ b/include/llvm/Support/raw_ostream.h
@@ -44,6 +44,22 @@ private:
char *OutBufStart, *OutBufEnd, *OutBufCur;
bool Unbuffered;
+protected:
+ /// CurBufPtr - Get a pointer to the current location in the buffer.
+ ///
+ char *CurBufPtr(void) { return OutBufCur; }
+ /// StartBufPtr - Get a pointer to the start of the buffer
+ ///
+ char *StartBufPtr(void) { return OutBufStart; }
+ /// EndBufPtr - Get a pointer to the end of the buffer
+ ///
+ char *EndBufPtr(void) { return OutBufEnd; }
+
+ /// AboutToFlush- Called when the buffer is about to be flushed,
+ /// allowing derived classes to take some action.
+ ///
+ virtual void AboutToFlush(void) {};
+
public:
// color order matches ANSI escape sequence, don't change
enum Colors {
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 42e6fda97b..403300f1bc 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -120,6 +120,7 @@ raw_ostream &raw_ostream::operator<<(const void *P) {
void raw_ostream::flush_nonempty() {
assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty.");
+ AboutToFlush();
write_impl(OutBufStart, OutBufCur - OutBufStart);
OutBufCur = OutBufStart;
}