[clang-tools-extra] r226810 - [clang-tidy] Minor cleanups in readability-container-size-empty checker

Alexander Kornienko alexfh at google.com
Thu Jan 22 04:27:10 PST 2015


Author: alexfh
Date: Thu Jan 22 06:27:09 2015
New Revision: 226810

URL: http://llvm.org/viewvc/llvm-project?rev=226810&view=rev
Log:
[clang-tidy] Minor cleanups in readability-container-size-empty checker

  * Removed an unused header
  * Simplified the custom ast_matchers

http://reviews.llvm.org/D7088

Patch by Gábor Horváth!


Modified:
    clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmpty.cpp

Modified: clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmpty.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmpty.cpp?rev=226810&r1=226809&r2=226810&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmpty.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmpty.cpp Thu Jan 22 06:27:09 2015
@@ -13,7 +13,6 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
@@ -46,12 +45,7 @@ bool isContainer(llvm::StringRef ClassNa
 
 namespace clang {
 namespace ast_matchers {
-AST_MATCHER_P(QualType, unqualifiedType, internal::Matcher<Type>,
-              InnerMatcher) {
-  return InnerMatcher.matches(*Node, Finder, Builder);
-}
-
-AST_MATCHER(Type, isBoolType) { return Node.isBooleanType(); }
+AST_MATCHER(QualType, isBoolType) { return Node->isBooleanType(); }
 
 AST_MATCHER(NamedDecl, stlContainer) {
   return isContainer(Node.getQualifiedNameAsString());
@@ -78,19 +72,18 @@ void ContainerSizeEmptyCheck::registerMa
                                 hasLHS(integerLiteral(equals(1)))))))
               .bind("SizeBinaryOp")),
       hasParent(implicitCastExpr(
-          hasImplicitDestinationType(unqualifiedType(isBoolType())),
+          hasImplicitDestinationType(isBoolType()),
           anyOf(
               hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize")),
               anything()))),
-      hasParent(
-          explicitCastExpr(hasDestinationType(unqualifiedType(isBoolType())))));
+      hasParent(explicitCastExpr(hasDestinationType(isBoolType()))));
 
   Finder->addMatcher(
       memberCallExpr(
           on(expr(anyOf(hasType(namedDecl(stlContainer())),
-                        hasType(qualType(pointsTo(namedDecl(stlContainer())))),
-                        hasType(qualType(references(
-                            namedDecl(stlContainer())))))).bind("STLObject")),
+                        hasType(pointsTo(namedDecl(stlContainer()))),
+                        hasType(references(namedDecl(stlContainer())))))
+                 .bind("STLObject")),
           callee(methodDecl(hasName("size"))), WrongUse).bind("SizeCallExpr"),
       this);
 }






More information about the cfe-commits mailing list