[clang] [clang-tools-extra] [llvm] Add ``ignoringParenImpCasts`` in arguments of hasArgument (PR #89553)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Wed May 1 12:23:42 PDT 2024
================
@@ -41,14 +41,17 @@ void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
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()))));
+ cxxConstructExpr(
+ argumentCountIs(2),
+ hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+ hasArgument(1, ignoringParenImpCasts(cxxDefaultArgExpr())))));
// Detect passing a suspicious string literal to a string constructor.
// example: std::string str = "abc\0def";
- Finder->addMatcher(traverse(TK_AsIs,
- cxxConstructExpr(StringConstructorExpr, hasArgument(0, StrLitWithNul))),
+ Finder->addMatcher(
+ traverse(TK_AsIs, cxxConstructExpr(StringConstructorExpr,
+ hasArgument(0, ignoringParenImpCasts(
+ StrLitWithNul)))),
----------------
5chmidti wrote:
The `StrLitWithNul` already ignores these implicit nodes, so the `ignoringParenImpCasts` is not needed.
https://github.com/llvm/llvm-project/pull/89553
More information about the cfe-commits
mailing list