From c9af366fc39d657b7d416d16988265d86a641184 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 5 Aug 2009 15:48:26 +0000 Subject: [PATCH] Add StringRef::endswith git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78197 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/StringRef.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 0b1bfb28c23..e771cd0edd5 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -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); + } + /// @} };