[llvm] [ADT] Fix llvm::concat_iterator for `ValueT == common_base_class *` (PR #144744)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 20 14:24:43 PDT 2025


================
@@ -1032,13 +1032,17 @@ class concat_iterator
 
   static constexpr bool ReturnsByValue =
       !(std::is_reference_v<decltype(*std::declval<IterTs>())> && ...);
+  static constexpr bool ReturnsConvertiblePointer =
+      std::is_pointer_v<ValueT> &&
+      (std::is_convertible_v<decltype(*std::declval<IterTs>()), ValueT> && ...);
 
   using reference_type =
-      typename std::conditional_t<ReturnsByValue, ValueT, ValueT &>;
+      typename std::conditional_t<ReturnsByValue || ReturnsConvertiblePointer,
+                                  ValueT, ValueT &>;
----------------
kuhar wrote:

Doesn't this change the reference type in the case where all pointer types are the same? Prior to this PR, the `reference_type` used to be `T *&`, now it will become `T *`.

https://github.com/llvm/llvm-project/pull/144744


More information about the llvm-commits mailing list