aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/hicpp
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/hicpp
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/hicpp')
-rw-r--r--clang-tidy/hicpp/ExceptionBaseclassCheck.cpp31
-rw-r--r--clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp9
-rw-r--r--clang-tidy/hicpp/SignedBitwiseCheck.cpp38
3 files changed, 37 insertions, 41 deletions
diff --git a/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp b/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
index b299151c..890a56f7 100644
--- a/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
+++ b/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
@@ -23,22 +23,21 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
cxxThrowExpr(
- allOf(
- unless(has(expr(anyOf(isTypeDependent(), isValueDependent())))),
- // The thrown value is not derived from 'std::exception'.
- has(expr(unless(hasType(
- qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
- isSameOrDerivedFrom(hasName("::std::exception")))))))))),
- // This condition is always true, but will bind to the
- // template value if the thrown type is templated.
- anyOf(has(expr(hasType(
- substTemplateTypeParmType().bind("templ_type")))),
- anything()),
- // Bind to the declaration of the type of the value that
- // is thrown. 'anything()' is necessary to always suceed
- // in the 'eachOf' because builtin types are not
- // 'namedDecl'.
- eachOf(has(expr(hasType(namedDecl().bind("decl")))), anything())))
+ unless(has(expr(anyOf(isTypeDependent(), isValueDependent())))),
+ // The thrown value is not derived from 'std::exception'.
+ has(expr(unless(
+ hasType(qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+ isSameOrDerivedFrom(hasName("::std::exception")))))))))),
+ // This condition is always true, but will bind to the
+ // template value if the thrown type is templated.
+ anyOf(has(expr(
+ hasType(substTemplateTypeParmType().bind("templ_type")))),
+ anything()),
+ // Bind to the declaration of the type of the value that
+ // is thrown. 'anything()' is necessary to always suceed
+ // in the 'eachOf' because builtin types are not
+ // 'namedDecl'.
+ eachOf(has(expr(hasType(namedDecl().bind("decl")))), anything()))
.bind("bad_throw"),
this);
}
diff --git a/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
index f4cad2e9..03f4edba 100644
--- a/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
+++ b/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
@@ -26,7 +26,7 @@ void MultiwayPathsCoveredCheck::storeOptions(
void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
switchStmt(
- hasCondition(allOf(
+ hasCondition(expr(
// Match on switch statements that have either a bit-field or
// an integer condition. The ordering in 'anyOf()' is
// important because the last condition is the most general.
@@ -43,10 +43,9 @@ void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) {
// This option is noisy, therefore matching is configurable.
if (WarnOnMissingElse) {
- Finder->addMatcher(
- ifStmt(allOf(hasParent(ifStmt()), unless(hasElse(anything()))))
- .bind("else-if"),
- this);
+ Finder->addMatcher(ifStmt(hasParent(ifStmt()), unless(hasElse(anything())))
+ .bind("else-if"),
+ this);
}
}
diff --git a/clang-tidy/hicpp/SignedBitwiseCheck.cpp b/clang-tidy/hicpp/SignedBitwiseCheck.cpp
index 5c76b8e5..97383693 100644
--- a/clang-tidy/hicpp/SignedBitwiseCheck.cpp
+++ b/clang-tidy/hicpp/SignedBitwiseCheck.cpp
@@ -26,42 +26,40 @@ void SignedBitwiseCheck::registerMatchers(MatchFinder *Finder) {
// as signed types. Exclude these types from diagnosing for bitwise or(|) and
// bitwise and(&). Shifting and complementing such values is still not
// allowed.
- const auto BitmaskType = namedDecl(anyOf(
- hasName("::std::locale::category"), hasName("::std::ctype_base::mask"),
- hasName("::std::ios_base::fmtflags"), hasName("::std::ios_base::iostate"),
- hasName("::std::ios_base::openmode")));
+ const auto BitmaskType = namedDecl(
+ hasAnyName("::std::locale::category", "::std::ctype_base::mask",
+ "::std::ios_base::fmtflags", "::std::ios_base::iostate",
+ "::std::ios_base::openmode"));
const auto IsStdBitmask = ignoringImpCasts(declRefExpr(hasType(BitmaskType)));
// Match binary bitwise operations on signed integer arguments.
Finder->addMatcher(
- binaryOperator(
- allOf(anyOf(hasOperatorName("^"), hasOperatorName("|"),
- hasOperatorName("&"), hasOperatorName("^="),
- hasOperatorName("|="), hasOperatorName("&=")),
+ binaryOperator(anyOf(hasOperatorName("^"), hasOperatorName("|"),
+ hasOperatorName("&"), hasOperatorName("^="),
+ hasOperatorName("|="), hasOperatorName("&=")),
- unless(allOf(hasLHS(IsStdBitmask), hasRHS(IsStdBitmask))),
+ unless(allOf(hasLHS(IsStdBitmask), hasRHS(IsStdBitmask))),
- hasEitherOperand(SignedIntegerOperand),
- hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger()))))
+ hasEitherOperand(SignedIntegerOperand),
+ hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger())))
.bind("binary-no-sign-interference"),
this);
// Shifting and complement is not allowed for any signed integer type because
// the sign bit may corrupt the result.
Finder->addMatcher(
- binaryOperator(
- allOf(anyOf(hasOperatorName("<<"), hasOperatorName(">>"),
- hasOperatorName("<<="), hasOperatorName(">>=")),
- hasEitherOperand(SignedIntegerOperand),
- hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger()))))
+ binaryOperator(anyOf(hasOperatorName("<<"), hasOperatorName(">>"),
+ hasOperatorName("<<="), hasOperatorName(">>=")),
+ hasEitherOperand(SignedIntegerOperand),
+ hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger())))
.bind("binary-sign-interference"),
this);
// Match unary operations on signed integer types.
- Finder->addMatcher(unaryOperator(allOf(hasOperatorName("~"),
- hasUnaryOperand(SignedIntegerOperand)))
- .bind("unary-signed"),
- this);
+ Finder->addMatcher(
+ unaryOperator(hasOperatorName("~"), hasUnaryOperand(SignedIntegerOperand))
+ .bind("unary-signed"),
+ this);
}
void SignedBitwiseCheck::check(const MatchFinder::MatchResult &Result) {