diff options
| author | Zachary Turner <zturner@google.com> | 2016-11-12 17:17:12 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2016-11-12 17:17:12 +0000 |
| commit | 17412b03b2019cf0df75b16f8264a696724f45fe (patch) | |
| tree | f54aceb652a9ae6f1194185e9a55fdd0ce860fdb /llvm/include | |
| parent | fe11483b57c1dc6a6758725e6de0d6804ec59ed1 (diff) | |
| download | bcm5719-llvm-17412b03b2019cf0df75b16f8264a696724f45fe.tar.gz bcm5719-llvm-17412b03b2019cf0df75b16f8264a696724f45fe.zip | |
[Support] Add StringRef::find_lower and contains_lower.
Differential Revision: https://reviews.llvm.org/D25299
llvm-svn: 286724
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/ADT/StringRef.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h index 97359dd2630..56f1ab167f1 100644 --- a/llvm/include/llvm/ADT/StringRef.h +++ b/llvm/include/llvm/ADT/StringRef.h @@ -286,6 +286,12 @@ namespace llvm { return npos; } + /// Search for the first character \p C in the string, ignoring case. + /// + /// \returns The index of the first occurrence of \p C, or npos if not + /// found. + size_t find_lower(char C, size_t From = 0) const; + /// Search for the first character satisfying the predicate \p F /// /// \returns The index of the first character satisfying \p F starting from @@ -318,6 +324,12 @@ namespace llvm { /// found. size_t find(StringRef Str, size_t From = 0) const; + /// Search for the first string \p Str in the string, ignoring case. + /// + /// \returns The index of the first occurrence of \p Str, or npos if not + /// found. + size_t find_lower(StringRef Str, size_t From = 0) const; + /// Search for the last character \p C in the string. /// /// \returns The index of the last occurrence of \p C, or npos if not @@ -333,12 +345,24 @@ namespace llvm { return npos; } + /// Search for the last character \p C in the string, ignoring case. + /// + /// \returns The index of the last occurrence of \p C, or npos if not + /// found. + size_t rfind_lower(char C, size_t From = npos) const; + /// Search for the last string \p Str in the string. /// /// \returns The index of the last occurrence of \p Str, or npos if not /// found. size_t rfind(StringRef Str) const; + /// Search for the last string \p Str in the string, ignoring case. + /// + /// \returns The index of the last occurrence of \p Str, or npos if not + /// found. + size_t rfind_lower(StringRef Str) const; + /// Find the first character in the string that is \p C, or npos if not /// found. Same as find. size_t find_first_of(char C, size_t From = 0) const { @@ -393,6 +417,18 @@ namespace llvm { LLVM_ATTRIBUTE_ALWAYS_INLINE bool contains(char C) const { return find_first_of(C) != npos; } + /// Return true if the given string is a substring of *this, and false + /// otherwise. + LLVM_ATTRIBUTE_ALWAYS_INLINE + bool contains_lower(StringRef Other) const { + return find_lower(Other) != npos; + } + + /// Return true if the given character is contained in *this, and false + /// otherwise. + LLVM_ATTRIBUTE_ALWAYS_INLINE + bool contains_lower(char C) const { return find_lower(C) != npos; } + /// @} /// @name Helpful Algorithms /// @{ |

