Index: clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp =================================================================== --- clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp +++ clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp @@ -19,7 +19,13 @@ namespace { AST_MATCHER(CXXRecordDecl, hasMethods) { - return std::distance(Node.method_begin(), Node.method_end()) != 0; + for (const auto &Method : Node.methods()) { + if (Method->isImplicit()) + continue; + + return true; + } + return false; } AST_MATCHER(CXXRecordDecl, hasNonStaticMethod) { Index: docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst =================================================================== --- docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst +++ docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst @@ -6,7 +6,7 @@ `cppcoreguidelines-non-private-member-variables-in-classes` redirects here as an alias for this check. -Finds classes that contain non-static data members in addition to non-static +Finds classes that contain non-static data members in addition to explicit non-static member functions and diagnose all data members declared with a non-``public`` access specifier. The data members should be declared as ``private`` and accessed through member functions instead of exposed to derived classes or Index: test/clang-tidy/misc-non-private-member-variables-in-classes.cpp =================================================================== --- test/clang-tidy/misc-non-private-member-variables-in-classes.cpp +++ test/clang-tidy/misc-non-private-member-variables-in-classes.cpp @@ -35,6 +35,18 @@ int S1_v3; }; +// Only data and implicit methods, do not warn + +class C { +public: + C() {} + ~C() {} +}; + +struct S1Implicit { + C S1Implicit_v0; +}; + //----------------------------------------------------------------------------// // All functions are static, do not warn.