Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADT] Deprecate StringRef::equals #92351

Merged

Conversation

kazutakahirata
Copy link
Contributor

This patch deprecates StringRef::equals. Note that I've migrated all
known users to operator==(StringRef, StringRef).

This patch deprecates StringRef::equals.  Note that I've migrated all
known users to operator==(StringRef, StringRef).
@llvmbot
Copy link
Member

llvmbot commented May 16, 2024

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

This patch deprecates StringRef::equals. Note that I've migrated all
known users to operator==(StringRef, StringRef).


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

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/StringRef.h (+3-1)
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);
     }

@kazutakahirata kazutakahirata merged commit de483ad into llvm:main May 16, 2024
3 of 4 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_StringRef_equals_deprecate branch May 16, 2024 07:38
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