summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
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
commit976e0c07a04ff2e6df2a1b527cdcc95b9a961041 (patch)
tree899946035bd578160f6df8ac522fcc5e5c4aacde /clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
parenta2ada4d1ce415efe9a4535ddcd1a5d7e9b8f637a (diff)
downloadbcm5719-llvm-976e0c07a04ff2e6df2a1b527cdcc95b9a961041.tar.gz
bcm5719-llvm-976e0c07a04ff2e6df2a1b527cdcc95b9a961041.zip
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(). llvm-svn: 347520
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
index 273fe7bf410..c0bdbfbfe04 100644
--- a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
@@ -59,13 +59,6 @@ void NonPrivateMemberVariablesInClassesCheck::registerMatchers(
allOf(boolean(IgnoreClassesWithAllMemberVariablesBeingPublic),
unless(hasNonPublicMemberVariable()));
- // We only want the records that not only contain the mutable data (non-static
- // member variables), but also have some logic (non-static member functions).
- // We may optionally ignore records where all the member variables are public.
- auto RecordIsInteresting =
- allOf(anyOf(isStruct(), isClass()), hasMethods(), hasNonStaticMethod(),
- unless(ShouldIgnoreRecord));
-
// There are three visibility types: public, protected, private.
// If we are ok with public fields, then we only want to complain about
// protected fields, else we want to complain about all non-private fields.
@@ -73,7 +66,12 @@ void NonPrivateMemberVariablesInClassesCheck::registerMatchers(
auto InterestingField = fieldDecl(
IgnorePublicMemberVariables ? isProtected() : unless(isPrivate()));
- Finder->addMatcher(cxxRecordDecl(RecordIsInteresting,
+ // We only want the records that not only contain the mutable data (non-static
+ // member variables), but also have some logic (non-static member functions).
+ // We may optionally ignore records where all the member variables are public.
+ Finder->addMatcher(cxxRecordDecl(anyOf(isStruct(), isClass()), hasMethods(),
+ hasNonStaticMethod(),
+ unless(ShouldIgnoreRecord),
forEach(InterestingField.bind("field")))
.bind("record"),
this);
OpenPOWER on IntegriCloud