summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
diff options
context:
space:
mode:
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