[llvm] r297548 - [Support] Add a formatv provider for Twine.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 10 18:45:50 PST 2017
Author: zturner
Date: Fri Mar 10 20:45:50 2017
New Revision: 297548
URL: http://llvm.org/viewvc/llvm-project?rev=297548&view=rev
Log:
[Support] Add a formatv provider for Twine.
Modified:
llvm/trunk/include/llvm/Support/FormatProviders.h
Modified: llvm/trunk/include/llvm/Support/FormatProviders.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FormatProviders.h?rev=297548&r1=297547&r2=297548&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FormatProviders.h (original)
+++ llvm/trunk/include/llvm/Support/FormatProviders.h Fri Mar 10 20:45:50 2017
@@ -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:
More information about the llvm-commits
mailing list