[ADT] Remove SFINAE constraint from llvm::iterator_range ctor for gcc-7
authorBalazs Benics <benicsbalazs@gmail.com>
Tue, 18 Jul 2023 07:15:11 +0000 (09:15 +0200)
committerBalazs Benics <benicsbalazs@gmail.com>
Tue, 18 Jul 2023 07:15:11 +0000 (09:15 +0200)
It turns out the SFINAE constraint breaks building MLIR using GCC-7,
which is an outdated, but supported compiler by llvm-project.

I tried to find a solution for fixing it, but I decided to cut branches
and just simply remove the SFINAE constraint until we drop GCC-7.
It was originally introduced by D152891.

Allegedly, GCC-8 and above builds just fine.
I tested GCC 8.4.0, and GCC 7.5.0, and now builds fine on both.

Differential Revision: https://reviews.llvm.org/D155441

Fixes https://github.com/llvm/llvm-project/issues/63843

llvm/include/llvm/ADT/iterator_range.h

index 05379c1..8c37455 100644 (file)
@@ -43,12 +43,19 @@ class iterator_range {
   IteratorT begin_iterator, end_iterator;
 
 public:
+#if __GNUC__ == 7
+  // Be careful no to break gcc-7 on the mlir target.
+  // See https://github.com/llvm/llvm-project/issues/63843
+  template <typename Container>
+#else
   template <typename Container,
             std::enable_if_t<explicitly_convertible<
                 detail::IterOfRange<Container>, IteratorT>::value> * = nullptr>
+#endif
   iterator_range(Container &&c)
       : begin_iterator(adl_begin(std::forward<Container>(c))),
-        end_iterator(adl_end(std::forward<Container>(c))) {}
+        end_iterator(adl_end(std::forward<Container>(c))) {
+  }
   iterator_range(IteratorT begin_iterator, IteratorT end_iterator)
       : begin_iterator(std::move(begin_iterator)),
         end_iterator(std::move(end_iterator)) {}