Add some hooks that a redesigned AsmStream needs to do its job. These
authorDavid Greene <greened@obbligato.org>
Thu, 9 Jul 2009 23:43:41 +0000 (23:43 +0000)
committerDavid Greene <greened@obbligato.org>
Thu, 9 Jul 2009 23:43:41 +0000 (23:43 +0000)
allow derived classes to examine the stream buffer before it's flushed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75199 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/raw_ostream.h
lib/Support/raw_ostream.cpp

index 8242f04e23ce4670fa2e3d8005b3c8c284adeff5..22fb38485d7aa8de6a5da2f2d9249dbd049ab710 100644 (file)
@@ -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 {
index 42e6fda97baf03807413792a7a48077fe4213058..403300f1bc46d88196a63aee6db9a2fe6b1e0501 100644 (file)
@@ -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;    
 }