[clang-tools-extra] [clang-tidy] Support find for string-like classes in readability-container-contains (PR #157243)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 8 13:06:55 PDT 2025
================
@@ -458,3 +454,41 @@ void testOperandPermutations(std::map<int, int>& Map) {
// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
// CHECK-FIXES: if (!Map.contains(0)) {};
}
+
+void testStringNpos(std::string Str1, std::string Str2, std::string_view StrView) {
+ if (Str1.find(Str2) == std::string::npos) {};
----------------
localspook wrote:
Nit: stray semicolons after all the `if`s in this function
https://github.com/llvm/llvm-project/pull/157243
More information about the cfe-commits
mailing list