Introduce a string_ostream string builder facilty

string_ostream is a safe and efficient string builder that combines opaque
stack storage with a built-in ostream interface.

small_string_ostream<bytes> additionally permits an explicit stack storage size
other than the default 128 bytes to be provided. Beyond that, storage is
transferred to the heap.

This convenient class can be used in most places an
std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair
would previously have been used, in order to guarantee consistent access
without byte truncation.

The patch also converts much of LLVM to use the new facility. These changes
include several probable bug fixes for truncated output, a programming error
that's no longer possible with the new interface.

llvm-svn: 211749
diff --git a/llvm/lib/Transforms/Instrumentation/DebugIR.cpp b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp
index f2f1738..56e60e6 100644
--- a/llvm/lib/Transforms/Instrumentation/DebugIR.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp
@@ -352,14 +352,12 @@
   }
 
   std::string getTypeName(Type *T) {
-    std::string TypeName;
-    raw_string_ostream TypeStream(TypeName);
+    string_ostream OS;
     if (T)
-      T->print(TypeStream);
+      T->print(OS);
     else
-      TypeStream << "Printing <null> Type";
-    TypeStream.flush();
-    return TypeName;
+      OS << "Printing <null> Type";
+    return OS.str();
   }
 
   /// Returns the MDNode that represents type T if it is already created, or 0