summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/FormatVariadicTest.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-07-06 05:45:45 +0000
committerSam McCall <sam.mccall@gmail.com>2018-07-06 05:45:45 +0000
commit8ca99100ba26d534a0cda05028afb41b0ed49647 (patch)
treea1d66595645a571c1effe0ad1da397303bf04660 /llvm/unittests/Support/FormatVariadicTest.cpp
parent390abe4a75123db1fe2a6ace53505607af13c7b4 (diff)
downloadbcm5719-llvm-8ca99100ba26d534a0cda05028afb41b0ed49647.tar.gz
bcm5719-llvm-8ca99100ba26d534a0cda05028afb41b0ed49647.zip
[Support] Make support types more easily printable.
Summary: Error's new operator<< is the first way to print an error without consuming it. formatv() can now print objects with an operator<< that works with raw_ostream. Reviewers: bkramer Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D48966 llvm-svn: 336412
Diffstat (limited to 'llvm/unittests/Support/FormatVariadicTest.cpp')
-rw-r--r--llvm/unittests/Support/FormatVariadicTest.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index 54373da51c4..6d621464c0e 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -671,3 +671,12 @@ TEST(FormatVariadicTest, CopiesAndMoves) {
EXPECT_EQ(0, R.Copied);
EXPECT_EQ(0, R.Moved);
}
+
+namespace adl {
+struct X {};
+raw_ostream &operator<<(raw_ostream &OS, const X &) { return OS << "X"; }
+} // namespace adl
+TEST(FormatVariadicTest, FormatStreamable) {
+ adl::X X;
+ EXPECT_EQ("X", formatv("{0}", X).str());
+}
OpenPOWER on IntegriCloud