[llvm] [ADT] Add const to operator== in ArrayRef.h (PR #161321)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 23:29:34 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/161321
While I am at it, this patch adds [[nodiscard]].
>From 4f703c656474539ba532dd1870e21d8a3f715526 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 28 Sep 2025 21:36:19 -0700
Subject: [PATCH] [ADT] Add const to operator== in ArrayRef.h
While I am at it, this patch adds [[nodiscard]].
---
llvm/include/llvm/ADT/ArrayRef.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index fb91690bb0eb3..448d10013d371 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -547,7 +547,8 @@ namespace llvm {
}
template <typename T>
- inline bool operator==(SmallVectorImpl<T> &LHS, ArrayRef<T> RHS) {
+ [[nodiscard]] inline bool operator==(const SmallVectorImpl<T> &LHS,
+ ArrayRef<T> RHS) {
return ArrayRef<T>(LHS).equals(RHS);
}
@@ -557,7 +558,8 @@ namespace llvm {
}
template <typename T>
- inline bool operator!=(SmallVectorImpl<T> &LHS, ArrayRef<T> RHS) {
+ [[nodiscard]] inline bool operator!=(const SmallVectorImpl<T> &LHS,
+ ArrayRef<T> RHS) {
return !(LHS == RHS);
}
More information about the llvm-commits
mailing list