[PATCH] D155441: [ADT] Remove SFINAE constraint from llvm::iterator_range ctor

Balázs Benics via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 17 04:28:06 PDT 2023


steakhal created this revision.
steakhal added reviewers: dblaikie, barannikov88, mehdi_amini.
Herald added subscribers: bzcheeseman, martong, rriddle.
Herald added a project: All.
steakhal requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer.
Herald added a project: LLVM.

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 <https://reviews.llvm.org/D152891>.

Allegedly, GCC-8 and above builds just fine.

Depends on D152891 <https://reviews.llvm.org/D152891>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155441

Files:
  llvm/include/llvm/ADT/iterator_range.h


Index: llvm/include/llvm/ADT/iterator_range.h
===================================================================
--- llvm/include/llvm/ADT/iterator_range.h
+++ llvm/include/llvm/ADT/iterator_range.h
@@ -24,16 +24,6 @@
 
 namespace llvm {
 
-template <typename From, typename To, typename = void>
-struct explicitly_convertible : std::false_type {};
-
-template <typename From, typename To>
-struct explicitly_convertible<
-    From, To,
-    std::void_t<decltype(static_cast<To>(
-        std::declval<std::add_rvalue_reference_t<From>>()))>> : std::true_type {
-};
-
 /// A range adaptor for a pair of iterators.
 ///
 /// This just wraps two iterators into a range-compatible interface. Nothing
@@ -43,9 +33,10 @@
   IteratorT begin_iterator, end_iterator;
 
 public:
-  template <typename Container,
-            std::enable_if_t<explicitly_convertible<
-                detail::IterOfRange<Container>, IteratorT>::value> * = nullptr>
+  // TODO: Add SFINAE to test that the Container's iterators match the range's
+  //       iterators. Be careful no to break gcc-7 on the mlir target.
+  //       See https://github.com/llvm/llvm-project/issues/63843
+  template <typename Container>
   iterator_range(Container &&c)
       : begin_iterator(adl_begin(std::forward<Container>(c))),
         end_iterator(adl_end(std::forward<Container>(c))) {}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155441.540947.patch
Type: text/x-patch
Size: 1349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230717/17fd063c/attachment.bin>


More information about the llvm-commits mailing list