[llvm] [ADT] Deprecate StringRef::{starts,ends}with (PR #75491)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 14 08:16:52 PST 2023
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/75491
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.
>From bbb82851622638aa93bbcd15607b7470673116cc Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 13 Dec 2023 23:50:08 -0800
Subject: [PATCH] [ADT] Deprecate StringRef::{starts,ends}with
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.
---
llvm/include/llvm/ADT/StringRef.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
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);
}
More information about the llvm-commits
mailing list