[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)
Nicolas van Kempen via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 5 10:37:11 PDT 2024
================
@@ -30,9 +32,15 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
ofClass(cxxRecordDecl(HasContainsMatchingParamType)))))
.bind("call");
+ const auto Literal0 = integerLiteral(equals(0));
+ const auto Literal1 = integerLiteral(equals(1));
+
const auto FindCall =
cxxMemberCallExpr(
- argumentCountIs(1),
+ anyOf(argumentCountIs(1),
+ allOf(argumentCountIs(2), // string::find takes two arguments
----------------
nicovank wrote:
```suggestion
// `find` for string-like classes often has a second parameter,
// indicating where to start the search. We match if it's
// the default zero or explicitly equal to zero.
allOf(argumentCountIs(2),
```
I think a little more detail is good here.
https://github.com/llvm/llvm-project/pull/110351
More information about the cfe-commits
mailing list