Add StringRef::contains()
authorZachary Turner <zturner@google.com>
Tue, 30 Aug 2016 17:29:46 +0000 (17:29 +0000)
committerZachary Turner <zturner@google.com>
Tue, 30 Aug 2016 17:29:46 +0000 (17:29 +0000)
llvm-svn: 280113

llvm/include/llvm/ADT/StringRef.h

index 17a428c..c753b7f 100644 (file)
@@ -337,6 +337,11 @@ namespace llvm {
     /// Complexity: O(size() + Chars.size())
     size_t find_last_not_of(StringRef Chars, size_t From = npos) const;
 
+    /// Return true if the given string is a substring of *this, and false
+    /// otherwise.
+    LLVM_ATTRIBUTE_ALWAYS_INLINE
+    bool contains(StringRef Other) const { return find(Other) != npos; }
+
     /// @}
     /// @name Helpful Algorithms
     /// @{