From aea9dfc1671d0e3f57223ad522cdc4c8e3182c53 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 10 Aug 2009 00:44:02 +0000 Subject: [PATCH] add a simple back() method to StringRef. llvm-svn: 78544 --- llvm/include/llvm/ADT/StringRef.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h index e771cd0edd5b..e24fe05e7cd3 100644 --- a/llvm/include/llvm/ADT/StringRef.h +++ b/llvm/include/llvm/ADT/StringRef.h @@ -76,6 +76,11 @@ namespace llvm { /// size - Get the string size. size_t size() const { return Length; } + + char back() const { + assert(!empty()); + return Data[Length-1]; + } /// equals - Check for string equality, this is more efficient than /// compare() in when the relative ordering of inequal strings isn't needed.