summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-22 23:10:29 +0000
committerChris Lattner <sabre@nondot.org>2009-08-22 23:10:29 +0000
commite6db2c338b52fe4dadf29c6bdba76b7f8a50ba18 (patch)
treee7f28dfedcfc25f6aca57600322a14e6a4fe5db9 /llvm/lib/Support/raw_ostream.cpp
parent9cedbefb24a5d7a0cf6612fb779dbb9f046ffe97 (diff)
downloadbcm5719-llvm-e6db2c338b52fe4dadf29c6bdba76b7f8a50ba18.tar.gz
bcm5719-llvm-e6db2c338b52fe4dadf29c6bdba76b7f8a50ba18.zip
add a raw_ostream::indent method, to be used like:
OS.indent(i) << "whatever"; people seem to like indenting things ;-) llvm-svn: 79784
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 917e6be6699..94507bd67ba 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -289,6 +289,23 @@ raw_ostream &raw_ostream::operator<<(const format_object_base &Fmt) {
}
}
+/// indent - Insert 'NumSpaces' spaces.
+raw_ostream &raw_ostream::indent(unsigned NumSpaces) {
+ const char *Spaces = " ";
+
+ // Usually the indentation is small, handle it with a fastpath.
+ if (NumSpaces <= 16)
+ return write(Spaces, NumSpaces);
+
+ while (NumSpaces) {
+ unsigned NumToWrite = std::min(NumSpaces, 16U);
+ write(Spaces, NumToWrite);
+ NumSpaces -= NumToWrite;
+ }
+ return *this;
+}
+
+
//===----------------------------------------------------------------------===//
// Formatted Output
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud