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

Eric Feng via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 16 16:01:57 PST 2026


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

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

>From 375171f3907765e8ed70cf6e3fc18dcb0f29c2cb Mon Sep 17 00:00:00 2001
From: Eric Feng <Eric.Feng at amd.com>
Date: Mon, 16 Feb 2026 15:47:24 -0800
Subject: [PATCH] remove unnecessary const

Signed-off-by: Eric Feng <Eric.Feng at amd.com>
---
 llvm/include/llvm/ADT/ArrayRef.h | 1 -
 1 file changed, 1 deletion(-)

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())>>,



More information about the llvm-commits mailing list