[clang-tools-extra] r217035 - [clang-tidy] Use new ASTMatchers to identify template instantiations instead of copying it everywhere.

Benjamin Kramer benny.kra at googlemail.com
Wed Sep 3 06:21:51 PDT 2014


Author: d0k
Date: Wed Sep  3 08:21:51 2014
New Revision: 217035

URL: http://llvm.org/viewvc/llvm-project?rev=217035&view=rev
Log:
[clang-tidy] Use new ASTMatchers to identify template instantiations instead of copying it everywhere.

No intended functionality change.

Modified:
    clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.cpp
    clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp
    clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.cpp?rev=217035&r1=217034&r2=217035&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.cpp Wed Sep  3 08:21:51 2014
@@ -21,15 +21,12 @@ namespace runtime {
 
 void
 MemsetZeroLengthCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
-  auto InTemplateInstantiation = hasAncestor(
-      decl(anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),
-                 functionDecl(ast_matchers::isTemplateInstantiation()))));
   // Look for memset(x, y, 0) as those is most likely an argument swap.
   // TODO: Also handle other standard functions that suffer from the same
   //       problem, e.g. memchr.
   Finder->addMatcher(
       callExpr(callee(functionDecl(hasName("::memset"))), argumentCountIs(3),
-               unless(InTemplateInstantiation)).bind("decl"),
+               unless(isInTemplateInstantiation())).bind("decl"),
       this);
 }
 

Modified: clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp?rev=217035&r1=217034&r2=217035&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp Wed Sep  3 08:21:51 2014
@@ -26,12 +26,8 @@ void StringReferenceMemberCheck::registe
   auto ConstString = qualType(isConstQualified(), hasDeclaration(String));
 
   // Ignore members in template instantiations.
-  auto InTemplateInstantiation = hasAncestor(
-      decl(anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),
-                 functionDecl(ast_matchers::isTemplateInstantiation()))));
-
   Finder->addMatcher(fieldDecl(hasType(references(ConstString)),
-                               unless(InTemplateInstantiation)).bind("member"),
+                               unless(isInstantiated())).bind("member"),
                      this);
 }
 

Modified: clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.cpp?rev=217035&r1=217034&r2=217035&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.cpp Wed Sep  3 08:21:51 2014
@@ -24,9 +24,6 @@ AST_MATCHER(QualType, isBoolean) { retur
 namespace tidy {
 
 void BoolPointerImplicitConversion::registerMatchers(MatchFinder *Finder) {
-  auto InTemplateInstantiation = hasAncestor(
-      decl(anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),
-                 functionDecl(ast_matchers::isTemplateInstantiation()))));
   // Look for ifs that have an implicit bool* to bool conversion in the
   // condition. Filter negations.
   Finder->addMatcher(
@@ -36,7 +33,7 @@ void BoolPointerImplicitConversion::regi
                            hasType(pointerType(pointee(isBoolean()))),
                            ignoringParenImpCasts(declRefExpr().bind("expr")))),
                        isPointerToBoolean())))),
-             unless(InTemplateInstantiation)).bind("if"),
+             unless(isInTemplateInstantiation())).bind("if"),
       this);
 }
 





More information about the cfe-commits mailing list