add a raw_ostream::indent method, to be used like:
OS.indent(i) << "whatever";
people seem to like indenting things ;-)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79784 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 917e6be..94507bd 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -289,6 +289,23 @@
}
}
+/// 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
//===----------------------------------------------------------------------===//