aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/performance
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2018-11-25 02:41:01 +0000
committerAlexander Kornienko <alexfh@google.com>2018-11-25 02:41:01 +0000
commit2e0ee616b96fa2ec09e5e2cae185b444c34ee482 (patch)
treef10294cd01ba13031b2944b527c28e84d4c0c9a0 /clang-tidy/performance
parentd9fc15699e52eb02ead015f701fe4234ab3570e6 (diff)
A bit of AST matcher cleanup, NFC.
Removed the uses of the allOf() matcher inside node matchers that are implicit allOf(). Replaced uses of allOf() with the explicit node matcher where it makes matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more efficient and readable hasAnyName(). git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347520 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/performance')
-rw-r--r--clang-tidy/performance/MoveConstructorInitCheck.cpp14
-rw-r--r--clang-tidy/performance/UnnecessaryCopyInitialization.cpp14
-rw-r--r--clang-tidy/performance/UnnecessaryValueParamCheck.cpp4
3 files changed, 13 insertions, 19 deletions
diff --git a/clang-tidy/performance/MoveConstructorInitCheck.cpp b/clang-tidy/performance/MoveConstructorInitCheck.cpp
index 055e4f0a..52283fb2 100644
--- a/clang-tidy/performance/MoveConstructorInitCheck.cpp
+++ b/clang-tidy/performance/MoveConstructorInitCheck.cpp
@@ -35,14 +35,12 @@ void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
cxxConstructorDecl(
- unless(isImplicit()),
- allOf(isMoveConstructor(),
- hasAnyConstructorInitializer(
- cxxCtorInitializer(
- withInitializer(cxxConstructExpr(hasDeclaration(
- cxxConstructorDecl(isCopyConstructor())
- .bind("ctor")))))
- .bind("move-init")))),
+ unless(isImplicit()), isMoveConstructor(),
+ hasAnyConstructorInitializer(
+ cxxCtorInitializer(
+ withInitializer(cxxConstructExpr(hasDeclaration(
+ cxxConstructorDecl(isCopyConstructor()).bind("ctor")))))
+ .bind("move-init"))),
this);
}
diff --git a/clang-tidy/performance/UnnecessaryCopyInitialization.cpp b/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index ef6bcd6f..6f310573 100644
--- a/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -39,10 +39,6 @@ UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
auto ConstReference = referenceType(pointee(qualType(isConstQualified())));
- auto ConstOrConstReference =
- allOf(anyOf(ConstReference, isConstQualified()),
- unless(allOf(pointerType(), unless(pointerType(pointee(
- qualType(isConstQualified())))))));
// Match method call expressions where the `this` argument is only used as
// const, this will be checked in `check()` part. This returned const
@@ -63,11 +59,11 @@ void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
declStmt(
has(varDecl(hasLocalStorage(),
hasType(qualType(
- allOf(hasCanonicalType(
- matchers::isExpensiveToCopy()),
- unless(hasDeclaration(namedDecl(
- matchers::matchesAnyListedName(
- AllowedTypes))))))),
+ hasCanonicalType(
+ matchers::isExpensiveToCopy()),
+ unless(hasDeclaration(namedDecl(
+ matchers::matchesAnyListedName(
+ AllowedTypes)))))),
unless(isImplicit()),
hasInitializer(
cxxConstructExpr(
diff --git a/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
index ac76cea3..ff3674fe 100644
--- a/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ b/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -79,11 +79,11 @@ void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
const auto ExpensiveValueParamDecl = parmVarDecl(
- hasType(qualType(allOf(
+ hasType(qualType(
hasCanonicalType(matchers::isExpensiveToCopy()),
unless(anyOf(hasCanonicalType(referenceType()),
hasDeclaration(namedDecl(
- matchers::matchesAnyListedName(AllowedTypes)))))))),
+ matchers::matchesAnyListedName(AllowedTypes))))))),
decl().bind("param"));
Finder->addMatcher(
functionDecl(hasBody(stmt()), isDefinition(), unless(isImplicit()),