[llvm] Remove misleading is_const check in MutableArrayRef constructor (PR #181758)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 16 16:02:26 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Eric Feng (efric)

<details>
<summary>Changes</summary>

The `std::negation<std::is_const<C>>` check here seems semantically inaccurate; we should care about whether the container provides mutable element access, not the constness of the container itself. This was already being checked but was previously being dropped prior to the change from `const C&` to `C&` in https://github.com/llvm/llvm-project/pull/181190. That was sufficient in itself to fix the referenced issue https://github.com/llvm/llvm-project/issues/181176

---
Full diff: https://github.com/llvm/llvm-project/pull/181758.diff


1 Files Affected:

- (modified) llvm/include/llvm/ADT/ArrayRef.h (-1) 


``````````diff
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index 84c083cb1e666..716e2b0e3bcf3 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -327,7 +327,6 @@ namespace llvm {
     template <typename C,
               typename = std::enable_if_t<
                   std::conjunction_v<
-                      std::negation<std::is_const<C>>,
                       std::is_convertible<
                           decltype(std::declval<C &>().data()) *, T *const *>,
                       std::is_integral<decltype(std::declval<C &>().size())>>,

``````````

</details>


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


More information about the llvm-commits mailing list