[llvm] 5ac1295 - [ADT] Deprecate StringRef::{starts, ends}with (#75491)

via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 17 15:52:53 PST 2023


Author: Kazu Hirata
Date: 2023-12-17T15:52:50-08:00
New Revision: 5ac12951b4e9bbfcc5791282d0961ec2b65575e9

URL: https://github.com/llvm/llvm-project/commit/5ac12951b4e9bbfcc5791282d0961ec2b65575e9
DIFF: https://github.com/llvm/llvm-project/commit/5ac12951b4e9bbfcc5791282d0961ec2b65575e9.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/StringRef.h

Removed: 
    


################################################################################
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