From 6bcbe6e04d0ff61e3eec9eb01d3c535fd2f78a38 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 3 Sep 2014 13:30:28 +0000 Subject: [PATCH] [clang-tidy] Eliminate inline copies of InTemplateInstantiation matcher. llvm-svn: 217036 --- .../clang-tidy/google/AvoidCStyleCastsCheck.cpp | 5 +---- .../clang-tidy/google/ExplicitMakePairCheck.cpp | 4 +--- .../clang-tidy/google/NamedParameterCheck.cpp | 8 +------- .../clang-tidy/misc/UndelegatedConstructor.cpp | 4 +--- clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp | 13 +++++-------- 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp index 102b5bb99662..bb015abd3d86 100644 --- a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp @@ -28,10 +28,7 @@ AvoidCStyleCastsCheck::registerMatchers(ast_matchers::MatchFinder *Finder) { // FIXME: Remove this once this is fixed in the AST. unless(hasParent(substNonTypeTemplateParmExpr())), // Avoid matches in template instantiations. - unless(hasAncestor(decl( - anyOf(recordDecl(ast_matchers::isTemplateInstantiation()), - functionDecl(ast_matchers::isTemplateInstantiation())))))) - .bind("cast"), + unless(isInTemplateInstantiation())).bind("cast"), this); } diff --git a/clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.cpp b/clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.cpp index 1331c57142a0..d09be299ebc2 100644 --- a/clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.cpp @@ -30,9 +30,7 @@ ExplicitMakePairCheck::registerMatchers(ast_matchers::MatchFinder *Finder) { // Look for std::make_pair with explicit template args. Ignore calls in // templates. Finder->addMatcher( - callExpr(unless(hasAncestor(decl(anyOf( - recordDecl(ast_matchers::isTemplateInstantiation()), - functionDecl(ast_matchers::isTemplateInstantiation()))))), + callExpr(unless(isInTemplateInstantiation()), callee(expr(ignoringParenImpCasts( declRefExpr(hasExplicitTemplateArgs(), to(functionDecl(hasName("::std::make_pair")))) diff --git a/clang-tools-extra/clang-tidy/google/NamedParameterCheck.cpp b/clang-tools-extra/clang-tidy/google/NamedParameterCheck.cpp index 4a06dc8d6bb6..62f3096cab03 100644 --- a/clang-tools-extra/clang-tidy/google/NamedParameterCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/NamedParameterCheck.cpp @@ -19,13 +19,7 @@ namespace tidy { namespace readability { void NamedParameterCheck::registerMatchers(ast_matchers::MatchFinder *Finder) { - Finder->addMatcher( - functionDecl( - unless(hasAncestor(decl( - anyOf(recordDecl(ast_matchers::isTemplateInstantiation()), - functionDecl(ast_matchers::isTemplateInstantiation())))))) - .bind("decl"), - this); + Finder->addMatcher(functionDecl(unless(isInstantiated())).bind("decl"), this); } void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.cpp b/clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.cpp index 7e31e1bd9a75..143c27a98b05 100644 --- a/clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.cpp +++ b/clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.cpp @@ -60,9 +60,7 @@ void UndelegatedConstructorCheck::registerMatchers(MatchFinder *Finder) { constructExpr(hasDeclaration(constructorDecl(ofClass( recordDecl(baseOfBoundNode("parent")))))) .bind("construct"))), - unless(hasAncestor(decl( - anyOf(recordDecl(ast_matchers::isTemplateInstantiation()), - functionDecl(ast_matchers::isTemplateInstantiation())))))), + unless(isInTemplateInstantiation())), this); } diff --git a/clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp b/clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp index 1aabf6a10bab..41327b65bb52 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedRAII.cpp @@ -29,14 +29,11 @@ void UnusedRAIICheck::registerMatchers(MatchFinder *Finder) { // those returned from a call. auto BindTemp = bindTemporaryExpr(unless(has(callExpr()))).bind("temp"); Finder->addMatcher( - exprWithCleanups( - unless(hasAncestor(decl( - anyOf(recordDecl(ast_matchers::isTemplateInstantiation()), - functionDecl(ast_matchers::isTemplateInstantiation()))))), - hasParent(compoundStmt().bind("compound")), - hasType(recordDecl(hasUserDeclaredDestructor())), - anyOf(has(BindTemp), has(functionalCastExpr(has(BindTemp))))) - .bind("expr"), + exprWithCleanups(unless(isInTemplateInstantiation()), + hasParent(compoundStmt().bind("compound")), + hasType(recordDecl(hasUserDeclaredDestructor())), + anyOf(has(BindTemp), has(functionalCastExpr( + has(BindTemp))))).bind("expr"), this); }