]> granicus.if.org Git - llvm/commitdiff
[Support] Add a formatv provider for Twine.
authorZachary Turner <zturner@google.com>
Sat, 11 Mar 2017 02:45:50 +0000 (02:45 +0000)
committerZachary Turner <zturner@google.com>
Sat, 11 Mar 2017 02:45:50 +0000 (02:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297548 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/FormatProviders.h

index 54a37169d3af6a0491f09e2201410b57d5dd9435..ee0f4eb1b307a66155a1491055ae5cd1dbe805bf 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/FormatVariadicDetails.h"
 #include "llvm/Support/NativeFormatting.h"
 
@@ -209,6 +210,17 @@ struct format_provider<
   }
 };
 
+/// Implementation of format_provider<T> for llvm::Twine.
+///
+/// This follows the same rules as the string formatter.
+
+template <> struct format_provider<Twine> {
+  static void format(const Twine &V, llvm::raw_ostream &Stream,
+                     StringRef Style) {
+    format_provider<std::string>::format(V.str(), Stream, Style);
+  }
+};
+
 /// Implementation of format_provider<T> for characters.
 ///
 /// The options string of a character type has the grammar: