[llvm] [ADT] Deprecate StringRef::equals (PR #92351)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 00:20:45 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/92351
>From 8afd75e69facff9c06da911aec5d9c3b03786d68 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 26 Jan 2024 00:05:21 -0800
Subject: [PATCH 1/2] [ADT] Deprecate StringRef::equals
This patch deprecates StringRef::equals. Note that I've migrated all
known users to operator==(StringRef, StringRef).
---
llvm/include/llvm/ADT/StringRef.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 8ed8e424cfe13..641de5dcef280 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -161,7 +161,9 @@ namespace llvm {
/// equals - Check for string equality, this is more efficient than
/// compare() when the relative ordering of inequal strings isn't needed.
- [[nodiscard]] bool equals(StringRef RHS) const {
+ [[nodiscard]] LLVM_DEPRECATED(
+ "Use operator==(StringRef, StringRef) instead",
+ "==") bool equals(StringRef RHS) const {
return (Length == RHS.Length &&
compareMemory(Data, RHS.Data, RHS.Length) == 0);
}
>From 4ad206641ff13fe51f8e37e9209c24f463b5ff0e Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 16 May 2024 00:19:17 -0700
Subject: [PATCH 2/2] Address a comment.
---
llvm/include/llvm/ADT/StringRef.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 641de5dcef280..2120c04530b23 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -161,9 +161,8 @@ namespace llvm {
/// equals - Check for string equality, this is more efficient than
/// compare() when the relative ordering of inequal strings isn't needed.
- [[nodiscard]] LLVM_DEPRECATED(
- "Use operator==(StringRef, StringRef) instead",
- "==") bool equals(StringRef RHS) const {
+ [[nodiscard]] LLVM_DEPRECATED("Use == instead",
+ "==") bool equals(StringRef RHS) const {
return (Length == RHS.Length &&
compareMemory(Data, RHS.Data, RHS.Length) == 0);
}
More information about the llvm-commits
mailing list