[llvm] [LLVM][ADT] Add some more `starts_with`, `ends_with`, and `contains` overloads to `SmallString` (PR #182692)
Victor Chernyakin via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 21 11:08:09 PST 2026
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/182692
None
>From 2490bc56c09acbcf38815dbce88cdaf7af36c2ff Mon Sep 17 00:00:00 2001
From: Victor Chernyakin <chernyakin.victor.j at outlook.com>
Date: Sat, 21 Feb 2026 11:02:59 -0800
Subject: [PATCH] [LLVM][ADT] Add some more `starts_with`, `ends_with`, and
`contains` overloads to `SmallString`
---
llvm/include/llvm/ADT/SmallString.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h
index be3193c6ef9be..a9344d572f48c 100644
--- a/llvm/include/llvm/ADT/SmallString.h
+++ b/llvm/include/llvm/ADT/SmallString.h
@@ -121,11 +121,25 @@ class SmallString : public SmallVector<char, InternalLen> {
return str().starts_with(Prefix);
}
+ /// starts_with - Check if this string starts with the given character \p C.
+ [[nodiscard]] bool starts_with(char C) const { return str().starts_with(C); }
+
/// ends_with - Check if this string ends with the given \p Suffix.
[[nodiscard]] bool ends_with(StringRef Suffix) const {
return str().ends_with(Suffix);
}
+ /// ends_with - Check if this string ends with the given character \p C.
+ [[nodiscard]] bool ends_with(char C) const { return str().ends_with(C); }
+
+ /// contains - Check if \p Other is a substring of this string.
+ [[nodiscard]] bool contains(StringRef Other) const {
+ return str().contains(Other);
+ }
+
+ /// contains - Check if this string contains the character \p C.
+ [[nodiscard]] bool contains(char C) const { return str().contains(C); }
+
/// @}
/// @name String Searching
/// @{
More information about the llvm-commits
mailing list