================
@@ -35,15 +35,16 @@ void
StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
const auto StrLitWithNul =
ignoringParenImpCasts(stringLiteral(containsNul()).bind("truncated"));
- // Match string constructor.
- const auto StringConstructorExpr = expr(anyOf(
- cxxConstructExpr(argumentCountIs(1),
- hasDeclaration(cxxMethodDecl(hasName("basic_string")))),
- // If present, the second argument is the alloc object which must not
- // be present explicitly.
- cxxConstructExpr(argumentCountIs(2),
- hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
- hasArgument(1, cxxDefaultArgExpr()))));
+ // Match string and string-view constructors.
+ const auto StringConstructorExpr = expr(
+ anyOf(cxxConstructExpr(argumentCountIs(1),
+ hasDeclaration(cxxMethodDecl(hasAnyName(
+ "basic_string", "basic_string_view")))),
----------------
zeyi2 wrote:
Nit:
```c++
hasDeclaration(cxxConstructorDecl(
ofClass(cxxRecordDecl(hasName("::std::basic_string_view")))))
```
Could we restrict this matcher to `std::basic_string_view` only to `std::`?
https://github.com/llvm/llvm-project/pull/234722
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits