aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2009-07-09 23:43:41 +0000
committerDavid Greene <greened@obbligato.org>2009-07-09 23:43:41 +0000
commit1e3fe6c538ba7beac73bb4e1a6337da203a6f0f7 (patch)
tree20db7728f1795eb85c05c0eba2a49e36b93b0d46
parentb8d0743fecd1f44323524e60e3aadc835f95755d (diff)
downloadexternal_llvm-1e3fe6c538ba7beac73bb4e1a6337da203a6f0f7.tar.gz
external_llvm-1e3fe6c538ba7beac73bb4e1a6337da203a6f0f7.tar.bz2
external_llvm-1e3fe6c538ba7beac73bb4e1a6337da203a6f0f7.zip
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75199 91177308-0d34-0410-b5e6-96231b3b80d8
-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;
}