Skip to content

Commit 5ac1295

Browse files
[ADT] Deprecate StringRef::{starts,ends}with (#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.
1 parent 364d7e7 commit 5ac1295

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/include/llvm/ADT/StringRef.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ namespace llvm {
258258
return Length >= Prefix.Length &&
259259
compareMemory(Data, Prefix.Data, Prefix.Length) == 0;
260260
}
261-
[[nodiscard]] bool startswith(StringRef Prefix) const {
261+
[[nodiscard]] LLVM_DEPRECATED(
262+
"Use starts_with instead",
263+
"starts_with") bool startswith(StringRef Prefix) const {
262264
return starts_with(Prefix);
263265
}
264266

@@ -271,7 +273,9 @@ namespace llvm {
271273
compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) ==
272274
0;
273275
}
274-
[[nodiscard]] bool endswith(StringRef Suffix) const {
276+
[[nodiscard]] LLVM_DEPRECATED(
277+
"Use ends_with instead",
278+
"ends_with") bool endswith(StringRef Suffix) const {
275279
return ends_with(Suffix);
276280
}
277281

0 commit comments

Comments
 (0)