Index: include/llvm/Support/FormatVariadic.h =================================================================== --- include/llvm/Support/FormatVariadic.h +++ include/llvm/Support/FormatVariadic.h @@ -94,6 +94,15 @@ Adapters.reserve(ParamCount); } + formatv_object_base(formatv_object_base const &rhs) = delete; + + formatv_object_base(formatv_object_base &&rhs) + : Fmt(std::move(rhs.Fmt)), + Adapters(), // Adapters are initialized by formatv_object + Replacements(std::move(rhs.Replacements)) { + Adapters.reserve(rhs.Adapters.size()); + }; + void format(raw_ostream &S) const { for (auto &R : Replacements) { if (R.Type == ReplacementType::Empty) @@ -149,6 +158,14 @@ Parameters(std::move(Params)) { Adapters = apply_tuple(create_adapters(), Parameters); } + + formatv_object(formatv_object const &rhs) = delete; + + formatv_object(formatv_object &&rhs) + : formatv_object_base(std::move(rhs)), + Parameters(std::move(rhs.Parameters)) { + Adapters = apply_tuple(create_adapters(), Parameters); + } }; // \brief Format text given a format string and replacement parameters. Index: unittests/Support/FormatVariadicTest.cpp =================================================================== --- unittests/Support/FormatVariadicTest.cpp +++ unittests/Support/FormatVariadicTest.cpp @@ -553,6 +553,12 @@ formatv("{0,=34:X-}", fmt_repeat(fmt_pad(N, 1, 3), 5)).str()); } +TEST(FormatVariadicTest, MoveConstructor) { + auto fmt = formatv("{0} {1}", 1, 2); + auto fmt2 = std::move(fmt); + std::string S = fmt2; + EXPECT_EQ("1 2", S); +} TEST(FormatVariadicTest, ImplicitConversions) { std::string S = formatv("{0} {1}", 1, 2); EXPECT_EQ("1 2", S);