[clang-tools-extra] 223a43e - [clang-tidy] [NFC] Remove unnecessary matchers
Nathan James via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 9 00:38:26 PDT 2020
Author: Nathan James
Date: 2020-03-09T07:38:15Z
New Revision: 223a43ee8d899a0522bebe8291470b77e7dc7ab1
URL: https://github.com/llvm/llvm-project/commit/223a43ee8d899a0522bebe8291470b77e7dc7ab1
DIFF: https://github.com/llvm/llvm-project/commit/223a43ee8d899a0522bebe8291470b77e7dc7ab1.diff
LOG: [clang-tidy] [NFC] Remove unnecessary matchers
Reviewers: aaron.ballman, alexfh, gribozavr2
Reviewed By: aaron.ballman
Subscribers: wuzish, nemanjai, xazax.hun, kbarton, cfe-commits
Tags: #clang, #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D75803
Added:
Modified:
clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/clang-tidy/utils/Matchers.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp b/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
index f43d9496994d..188d44da51d8 100644
--- a/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
+++ b/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
@@ -61,11 +61,10 @@ void ComparisonInTempFailureRetryCheck::registerMatchers(MatchFinder *Finder) {
// we need to not complain about things like TEMP_FAILURE_RETRY(foo(x == 1)),
// so we just match the assignment of `y = (x)` and inspect `x` from there.
Finder->addMatcher(
- binaryOperator(
- hasOperatorName("="),
- hasRHS(ignoringParenCasts(
- binaryOperator(matchers::isComparisonOperator()).bind("binop"))),
- isRHSATempFailureRetryArg()),
+ binaryOperator(hasOperatorName("="),
+ hasRHS(ignoringParenCasts(
+ binaryOperator(isComparisonOperator()).bind("binop"))),
+ isRHSATempFailureRetryArg()),
this);
}
diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
index 98a1a0c37ecb..d5f392b592b8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
@@ -48,8 +48,7 @@ void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(callExpr(hasAnyArgument(Cast)), this);
Finder->addMatcher(binaryOperator(hasOperatorName("="), hasRHS(Cast)), this);
Finder->addMatcher(
- binaryOperator(matchers::isComparisonOperator(), hasEitherOperand(Cast)),
- this);
+ binaryOperator(isComparisonOperator(), hasEitherOperand(Cast)), this);
}
static unsigned getMaxCalculationWidth(const ASTContext &Context,
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
index 8de64608a3c2..cad4072b0849 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
@@ -84,8 +84,7 @@ void SuspiciousStringCompareCheck::storeOptions(
void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
// Match relational operators.
const auto ComparisonUnaryOperator = unaryOperator(hasOperatorName("!"));
- const auto ComparisonBinaryOperator =
- binaryOperator(matchers::isComparisonOperator());
+ const auto ComparisonBinaryOperator = binaryOperator(isComparisonOperator());
const auto ComparisonOperator =
expr(anyOf(ComparisonUnaryOperator, ComparisonBinaryOperator));
@@ -143,10 +142,9 @@ void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
// Detect suspicious operator with string compare function as operand.
Finder->addMatcher(
- binaryOperator(
- unless(anyOf(matchers::isComparisonOperator(), hasOperatorName("&&"),
- hasOperatorName("||"), hasOperatorName("="))),
- hasEitherOperand(StringCompareCallExpr))
+ binaryOperator(unless(anyOf(isComparisonOperator(), hasOperatorName("&&"),
+ hasOperatorName("||"), hasOperatorName("="))),
+ hasEitherOperand(StringCompareCallExpr))
.bind("suspicious-operator"),
this);
@@ -158,7 +156,7 @@ void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
has(ignoringParenImpCasts(integerLiteral(unless(equals(0)))))),
characterLiteral(), cxxBoolLiteral()));
- Finder->addMatcher(binaryOperator(matchers::isComparisonOperator(),
+ Finder->addMatcher(binaryOperator(isComparisonOperator(),
hasEitherOperand(StringCompareCallExpr),
hasEitherOperand(InvalidLiteral))
.bind("invalid-comparison"),
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
index 2b7726292dc2..905aee916d67 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
@@ -91,8 +91,7 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) {
// Matching assignment to owners, with the rhs not being an owner nor creating
// one.
- Finder->addMatcher(binaryOperator(matchers::isAssignmentOperator(),
- hasLHS(IsOwnerType),
+ Finder->addMatcher(binaryOperator(isAssignmentOperator(), hasLHS(IsOwnerType),
hasRHS(unless(ConsideredOwner)))
.bind("owner_assignment"),
this);
@@ -119,7 +118,7 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) {
// Matching on assignment operations where the RHS is a newly created owner,
// but the LHS is not an owner.
- Finder->addMatcher(binaryOperator(matchers::isAssignmentOperator(),
+ Finder->addMatcher(binaryOperator(isAssignmentOperator(),
hasLHS(unless(IsOwnerType)),
hasRHS(CreatesOwner))
.bind("bad_owner_creation_assignment"),
diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
index 99214ccf2e79..aeef4a7df4ba 100644
--- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -836,9 +836,8 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) {
binaryOperator(anyOf(hasOperatorName("-"), hasOperatorName("/"),
hasOperatorName("%"), hasOperatorName("|"),
hasOperatorName("&"), hasOperatorName("^"),
- matchers::isComparisonOperator(),
- hasOperatorName("&&"), hasOperatorName("||"),
- hasOperatorName("=")),
+ isComparisonOperator(), hasOperatorName("&&"),
+ hasOperatorName("||"), hasOperatorName("=")),
operandsAreEquivalent(),
// Filter noisy false positives.
unless(isInTemplateInstantiation()),
diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
index 6f5cc1861666..6f2402416f23 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -41,7 +41,7 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
const auto WrongUse = anyOf(
hasParent(binaryOperator(
- matchers::isComparisonOperator(),
+ isComparisonOperator(),
hasEitherOperand(ignoringImpCasts(anyOf(
integerLiteral(equals(1)), integerLiteral(equals(0))))))
.bind("SizeBinaryOp")),
diff --git a/clang-tools-extra/clang-tidy/utils/Matchers.h b/clang-tools-extra/clang-tidy/utils/Matchers.h
index e19c82731f89..348ab758f3d4 100644
--- a/clang-tools-extra/clang-tidy/utils/Matchers.h
+++ b/clang-tools-extra/clang-tidy/utils/Matchers.h
@@ -16,20 +16,12 @@ namespace clang {
namespace tidy {
namespace matchers {
-AST_MATCHER(BinaryOperator, isAssignmentOperator) {
- return Node.isAssignmentOp();
-}
-
AST_MATCHER(BinaryOperator, isRelationalOperator) {
return Node.isRelationalOp();
}
AST_MATCHER(BinaryOperator, isEqualityOperator) { return Node.isEqualityOp(); }
-AST_MATCHER(BinaryOperator, isComparisonOperator) {
- return Node.isComparisonOp();
-}
-
AST_MATCHER(QualType, isExpensiveToCopy) {
llvm::Optional<bool> IsExpensive =
utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
More information about the cfe-commits
mailing list