[llvm-commits] [llvm] r75199 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp

David Greene greened at obbligato.org
Thu Jul 9 16:43:42 PDT 2009


Author: greened
Date: Thu Jul  9 18:43:41 2009
New Revision: 75199

URL: http://llvm.org/viewvc/llvm-project?rev=75199&view=rev
Log:

Add some hooks that a redesigned AsmStream needs to do its job.  These
allow derived classes to examine the stream buffer before it's flushed.

Modified:
    llvm/trunk/include/llvm/Support/raw_ostream.h
    llvm/trunk/lib/Support/raw_ostream.cpp

Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=75199&r1=75198&r2=75199&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Thu Jul  9 18:43:41 2009
@@ -44,6 +44,22 @@
   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 {

Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=75199&r1=75198&r2=75199&view=diff

==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Thu Jul  9 18:43:41 2009
@@ -120,6 +120,7 @@
 
 void raw_ostream::flush_nonempty() {
   assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty.");
+  AboutToFlush();
   write_impl(OutBufStart, OutBufCur - OutBufStart);
   OutBufCur = OutBufStart;    
 }





More information about the llvm-commits mailing list