[llvm] 5ea8de2 - Revert "[Support] Format provider improvements"

Vladislav Vinogradov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 05:15:22 PST 2022


Author: Vladislav Vinogradov
Date: 2022-11-09T16:14:39+03:00
New Revision: 5ea8de22f6288ea758f858058756ce81aa1c79f5

URL: https://github.com/llvm/llvm-project/commit/5ea8de22f6288ea758f858058756ce81aa1c79f5
DIFF: https://github.com/llvm/llvm-project/commit/5ea8de22f6288ea758f858058756ce81aa1c79f5.diff

LOG: Revert "[Support] Format provider improvements"

This reverts commit 791bdba0b183371ca3e16bb8411a059b4f8636ac.

Bot failure: https://lab.llvm.org/buildbot/#/builders/223/builds/9914

Added: 
    

Modified: 
    llvm/include/llvm/Support/FormatProviders.h
    llvm/unittests/Support/FormatVariadicTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/FormatProviders.h b/llvm/include/llvm/Support/FormatProviders.h
index c25453e9e881..2bdc316a68a2 100644
--- a/llvm/include/llvm/Support/FormatProviders.h
+++ b/llvm/include/llvm/Support/FormatProviders.h
@@ -355,6 +355,7 @@ struct range_item_has_provider
 
 template <typename IterT> class format_provider<llvm::iterator_range<IterT>> {
   using value = typename std::iterator_traits<IterT>::value_type;
+  using reference = typename std::iterator_traits<IterT>::reference;
 
   static StringRef consumeOneOption(StringRef &Style, char Indicator,
                                     StringRef Default) {
@@ -402,13 +403,15 @@ template <typename IterT> class format_provider<llvm::iterator_range<IterT>> {
     auto Begin = V.begin();
     auto End = V.end();
     if (Begin != End) {
-      auto Adapter = detail::build_format_adapter(*Begin);
+      auto Adapter =
+          detail::build_format_adapter(std::forward<reference>(*Begin));
       Adapter.format(Stream, ArgStyle);
       ++Begin;
     }
     while (Begin != End) {
       Stream << Sep;
-      auto Adapter = detail::build_format_adapter(*Begin);
+      auto Adapter =
+          detail::build_format_adapter(std::forward<reference>(*Begin));
       Adapter.format(Stream, ArgStyle);
       ++Begin;
     }

diff  --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index 44e4477eb0b0..40c94b7fdbff 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -697,31 +697,3 @@ TEST(FormatVariadicTest, FormatError) {
   EXPECT_EQ("X", formatv("{0}", fmt_consume(std::move(E1))).str());
   EXPECT_FALSE(E1.isA<StringError>()); // consumed
 }
-
-TEST(FormatVariadicTest, FormatFilterRange) {
-  std::vector<int> Vec{0, 1, 2};
-  auto Range = map_range(Vec, [](int V) { return V + 1; });
-  EXPECT_EQ("1, 2, 3", formatv("{0}", Range).str());
-}
-
-namespace {
-
-class IntegerValuesRange final
-    : public indexed_accessor_range<IntegerValuesRange, NoneType, int, int *,
-                                    int> {
-public:
-  using indexed_accessor_range<IntegerValuesRange, NoneType, int, int *,
-                               int>::indexed_accessor_range;
-
-  static int dereference(const NoneType &, ptr
diff _t Index) {
-    return static_cast<int>(Index);
-  }
-};
-
-TEST(FormatVariadicTest, FormatRangeNonRef) {
-  IntegerValuesRange Range(None, 0, 3);
-  EXPECT_EQ("0, 1, 2",
-            formatv("{0}", make_range(Range.begin(), Range.end())).str());
-}
-
-} // namespace


        


More information about the llvm-commits mailing list