diff options
author | Chris Lattner <sabre@nondot.org> | 2008-08-19 04:23:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-08-19 04:23:02 +0000 |
commit | 071acf4279abb72e0accc6b76212ec8959c6b637 (patch) | |
tree | 9f6ee6f9e6d3c1c37700debbdf8e45d37541d140 | |
parent | 4869456c29ef3926f9eb2c9021b409c6bf7dd367 (diff) |
add raw_ostream method for emitting an unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54972 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Support/raw_ostream.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index fc73bab06b..1694520084 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -72,6 +72,23 @@ public: return write(Str, strlen(Str)); } + raw_ostream &operator<<(unsigned N) { + // Zero is a special case. + if (N == 0) + return *this << '0'; + + char NumberBuffer[20]; + char *EndPtr = NumberBuffer+sizeof(NumberBuffer); + char *CurPtr = EndPtr; + + while (N) { + *--CurPtr = '0' + char(N % 10); + N /= 10; + } + return write(CurPtr, EndPtr-CurPtr); + } + + raw_ostream &write(const char *Ptr, unsigned Size) { if (OutBufCur+Size > OutBufEnd) flush_impl(); |