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::{starts,ends}with #75491

Merged

Conversation

kazutakahirata
Copy link
Contributor

This patch deprecates StringRef::{starts,ends}with. Note that I've
replaced all known uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

This patch deprecates StringRef::{starts,ends}with.  Note that I've
replaced all known uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.
@llvmbot
Copy link
Member

llvmbot commented Dec 14, 2023

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

This patch deprecates StringRef::{starts,ends}with. Note that I've
replaced all known uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.


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

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/StringRef.h (+6-2)
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 4e69d5b633546d..d892333de391ce 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -258,7 +258,9 @@ namespace llvm {
       return Length >= Prefix.Length &&
              compareMemory(Data, Prefix.Data, Prefix.Length) == 0;
     }
-    [[nodiscard]] bool startswith(StringRef Prefix) const {
+    [[nodiscard]] LLVM_DEPRECATED(
+        "Use starts_with instead",
+        "starts_with") bool startswith(StringRef Prefix) const {
       return starts_with(Prefix);
     }
 
@@ -271,7 +273,9 @@ namespace llvm {
              compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) ==
                  0;
     }
-    [[nodiscard]] bool endswith(StringRef Suffix) const {
+    [[nodiscard]] LLVM_DEPRECATED(
+        "Use ends_with instead",
+        "ends_with") bool endswith(StringRef Suffix) const {
       return ends_with(Suffix);
     }
 

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@zero9178 zero9178 left a comment

Choose a reason for hiding this comment

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

LGTM assuming CI doesn't produce any warnings

@kazutakahirata kazutakahirata merged commit 5ac1295 into llvm:main Dec 17, 2023
5 checks passed
@kazutakahirata kazutakahirata deleted the pr_cleanup_StringRef_starts_with_llvm branch December 17, 2023 23:53
github-merge-queue bot pushed a commit to carbon-language/carbon-lang that referenced this pull request Dec 18, 2023
This matches the change to upstream `llvm::StringRef`, see
llvm/llvm-project#75491 .
AlexeySachkov added a commit to AlexeySachkov/llvm that referenced this pull request Jan 16, 2024
The method was deprecated in favor of `StringRef::starts_with` in
llvm/llvm-project#75491
AlexeySachkov added a commit to intel/llvm that referenced this pull request Jan 23, 2024
The method was deprecated in favor of `StringRef::starts_with` in
llvm/llvm-project#75491
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.

5 participants