[clang-tools-extra] r217036 - [clang-tidy] Eliminate inline copies of InTemplateInstantiation matcher.

Benjamin Kramer benny.kra at googlemail.com
Wed Sep 3 06:30:28 PDT 2014


Author: d0k
Date: Wed Sep  3 08:30:28 2014
New Revision: 217036

URL: http://llvm.org/viewvc/llvm-project?rev=217036&view=rev
Log:
[clang-tidy] Eliminate inline copies of InTemplateInstantiation matcher.

Modified:
    clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
    clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp
    clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp
    clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
    clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp?rev=217036&r1=217035&r2=217036&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp Wed Sep  3 08:30:28 2014
@@ -28,10 +28,7 @@ AvoidCStyleCastsCheck::registerMatchers(
           // 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);
 }
 

Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp?rev=217036&r1=217035&r2=217036&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp Wed Sep  3 08:30:28 2014
@@ -30,9 +30,7 @@ ExplicitMakePairCheck::registerMatchers(
   // 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"))))

Modified: clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp?rev=217036&r1=217035&r2=217036&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp Wed Sep  3 08:30:28 2014
@@ -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) {

Modified: clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp?rev=217036&r1=217035&r2=217036&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp Wed Sep  3 08:30:28 2014
@@ -60,9 +60,7 @@ void UndelegatedConstructorCheck::regist
               constructExpr(hasDeclaration(constructorDecl(ofClass(
                                 recordDecl(baseOfBoundNode("parent"))))))
                   .bind("construct"))),
-          unless(hasAncestor(decl(
-              anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),
-                    functionDecl(ast_matchers::isTemplateInstantiation())))))),
+          unless(isInTemplateInstantiation())),
       this);
 }
 

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp?rev=217036&r1=217035&r2=217036&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp Wed Sep  3 08:30:28 2014
@@ -29,14 +29,11 @@ void UnusedRAIICheck::registerMatchers(M
   // 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);
 }
 





More information about the cfe-commits mailing list