[clang-tools-extra] [clang-tidy] Fix bugprone-string-constructor FN with allocators. (PR #180337)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 7 21:22:41 PST 2026
================
@@ -81,7 +81,10 @@ void StringConstructorCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
cxxConstructExpr(
hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
- argumentCountIs(2), hasArgument(0, hasType(qualType(isInteger()))),
+ anyOf(argumentCountIs(2),
+ allOf(argumentCountIs(3),
+ hasArgument(2, unless(hasType(qualType(isInteger())))))),
----------------
localspook wrote:
I don't see an `(int, int, int)` constructor for `basic_string` (https://en.cppreference.com/w/cpp/string/basic_string/basic_string.html), so I think this `hasArgument(2, unless(hasType(qualType(isInteger()))))` part could be removed
https://github.com/llvm/llvm-project/pull/180337
More information about the cfe-commits
mailing list