Add StringRef::endswith
authorDaniel Dunbar <daniel@zuster.org>
Wed, 5 Aug 2009 15:48:26 +0000 (15:48 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 5 Aug 2009 15:48:26 +0000 (15:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78197 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringRef.h

index 0b1bfb28c239562fde52e814d2f9029efb383a13..e771cd0edd5b04df48ec8cc11bc252bae4d9286e 100644 (file)
@@ -174,6 +174,11 @@ namespace llvm {
       return substr(0, Prefix.Length).equals(Prefix);
     }
 
+    /// endswith - Check if this string ends with the given \arg Suffix.
+    bool endswith(const StringRef &Suffix) const {
+      return slice(size() - Suffix.Length, size()).equals(Suffix);
+    }
+
     /// @}
   };