[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! llvm-svn: 226810
This commit is contained in:
parent
b4b6b74079
commit
febfd3453e
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include "clang/AST/ASTContext.h"
|
#include "clang/AST/ASTContext.h"
|
||||||
#include "clang/ASTMatchers/ASTMatchers.h"
|
#include "clang/ASTMatchers/ASTMatchers.h"
|
||||||
#include "clang/ASTMatchers/ASTMatchersInternal.h"
|
|
||||||
#include "clang/Lex/Lexer.h"
|
#include "clang/Lex/Lexer.h"
|
||||||
|
|
||||||
using namespace clang::ast_matchers;
|
using namespace clang::ast_matchers;
|
||||||
|
@ -46,12 +45,7 @@ bool isContainer(llvm::StringRef ClassName) {
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
namespace ast_matchers {
|
namespace ast_matchers {
|
||||||
AST_MATCHER_P(QualType, unqualifiedType, internal::Matcher<Type>,
|
AST_MATCHER(QualType, isBoolType) { return Node->isBooleanType(); }
|
||||||
InnerMatcher) {
|
|
||||||
return InnerMatcher.matches(*Node, Finder, Builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
AST_MATCHER(Type, isBoolType) { return Node.isBooleanType(); }
|
|
||||||
|
|
||||||
AST_MATCHER(NamedDecl, stlContainer) {
|
AST_MATCHER(NamedDecl, stlContainer) {
|
||||||
return isContainer(Node.getQualifiedNameAsString());
|
return isContainer(Node.getQualifiedNameAsString());
|
||||||
|
@ -78,19 +72,18 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
|
||||||
hasLHS(integerLiteral(equals(1)))))))
|
hasLHS(integerLiteral(equals(1)))))))
|
||||||
.bind("SizeBinaryOp")),
|
.bind("SizeBinaryOp")),
|
||||||
hasParent(implicitCastExpr(
|
hasParent(implicitCastExpr(
|
||||||
hasImplicitDestinationType(unqualifiedType(isBoolType())),
|
hasImplicitDestinationType(isBoolType()),
|
||||||
anyOf(
|
anyOf(
|
||||||
hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize")),
|
hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize")),
|
||||||
anything()))),
|
anything()))),
|
||||||
hasParent(
|
hasParent(explicitCastExpr(hasDestinationType(isBoolType()))));
|
||||||
explicitCastExpr(hasDestinationType(unqualifiedType(isBoolType())))));
|
|
||||||
|
|
||||||
Finder->addMatcher(
|
Finder->addMatcher(
|
||||||
memberCallExpr(
|
memberCallExpr(
|
||||||
on(expr(anyOf(hasType(namedDecl(stlContainer())),
|
on(expr(anyOf(hasType(namedDecl(stlContainer())),
|
||||||
hasType(qualType(pointsTo(namedDecl(stlContainer())))),
|
hasType(pointsTo(namedDecl(stlContainer()))),
|
||||||
hasType(qualType(references(
|
hasType(references(namedDecl(stlContainer())))))
|
||||||
namedDecl(stlContainer())))))).bind("STLObject")),
|
.bind("STLObject")),
|
||||||
callee(methodDecl(hasName("size"))), WrongUse).bind("SizeCallExpr"),
|
callee(methodDecl(hasName("size"))), WrongUse).bind("SizeCallExpr"),
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue