diff --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp index 1c47f17d8a6423..96d93a1d041379 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp @@ -100,10 +100,11 @@ void StringConstructorCheck::registerMatchers(MatchFinder *Finder) { // Check the literal string constructor with char pointer. // [i.e. string (const char* s);] Finder->addMatcher( + traverse(TK_AsIs, cxxConstructExpr(hasDeclaration(cxxMethodDecl(hasName("basic_string"))), hasArgument(0, expr().bind("from-ptr")), hasArgument(1, unless(hasType(isInteger())))) - .bind("constructor"), + .bind("constructor")), this); } diff --git a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp index 815062618a9789..b533db760d5eb5 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp @@ -49,8 +49,8 @@ void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) { // Detect passing a suspicious string literal to a string constructor. // example: std::string str = "abc\0def"; - Finder->addMatcher( - cxxConstructExpr(StringConstructorExpr, hasArgument(0, StrLitWithNul)), + Finder->addMatcher(traverse(TK_AsIs, + cxxConstructExpr(StringConstructorExpr, hasArgument(0, StrLitWithNul))), this); // Detect passing a suspicious string literal through an overloaded operator. diff --git a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp index 78bf744eba8d48..e5825bc4f0e331 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp @@ -96,8 +96,9 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) { const auto StringType = hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(cxxRecordDecl(hasStringTypeName))))); - const auto EmptyStringInit = expr(ignoringImplicit( - anyOf(EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries))); + const auto EmptyStringInit = + traverse(ast_type_traits::TK_AsIs, expr(ignoringImplicit( + anyOf(EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries)))); // Match a variable declaration with an empty string literal as initializer. // Examples: