Skip to content

Conversation

kazutakahirata
Copy link
Contributor

While I am at it, this patch adds [[nodiscard]].

While I am at it, this patch adds [[nodiscard]].
@llvmbot
Copy link
Member

llvmbot commented Sep 30, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

While I am at it, this patch adds [[nodiscard]].


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

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/ArrayRef.h (+4-2)
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);
   }
 

Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should also be constexpr

@kuhar
Copy link
Member

kuhar commented Sep 30, 2025

These should also be constexpr

We can't have constexpr SmallVector though

@kazutakahirata kazutakahirata merged commit 0db995e into llvm:main Sep 30, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250929_ADT_SmallVector_ArrayRef_operator_eq branch September 30, 2025 15:57
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
While I am at it, this patch adds [[nodiscard]].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants