Index: clang-tidy/readability/IdentifierNamingCheck.cpp =================================================================== --- clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tidy/readability/IdentifierNamingCheck.cpp @@ -677,6 +677,15 @@ addUsage(NamingCheckFailures, Decl->getParent(), Decl->getNameInfo().getSourceRange()); + + for (const auto *Init : Decl->inits()) { + if (!Init->isWritten() || Init->isInClassMemberInitializer()) + continue; + if (const auto *FD = Init->getAnyMember()) + addUsage(NamingCheckFailures, FD, SourceRange(Init->getMemberLocation())); + // Note: delegating constructors and base class initializers are handled + // via the "typeLoc" matcher. + } return; } Index: test/clang-tidy/readability-identifier-naming.cpp =================================================================== --- test/clang-tidy/readability-identifier-naming.cpp +++ test/clang-tidy/readability-identifier-naming.cpp @@ -152,15 +152,20 @@ class my_class { // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_class' // CHECK-FIXES: {{^}}class CMyClass {{{$}} +public: my_class(); // CHECK-FIXES: {{^}} CMyClass();{{$}} + my_class(void*) : my_class() {} +// CHECK-FIXES: {{^}} CMyClass(void*) : CMyClass() {}{{$}} + ~ my_class(); // (space in destructor token test, we could check trigraph but they will be deprecated) // CHECK-FIXES: {{^}} ~{{$}} // CHECK-FIXES: {{^}} CMyClass();{{$}} +private: const int MEMBER_one_1 = ConstExpr_variable; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for constant member 'MEMBER_one_1' // CHECK-FIXES: {{^}} const int member_one_1 = const_expr_variable;{{$}} @@ -211,6 +216,34 @@ class CMyWellNamedClass {}; // No warning expected as this class is well named. +template +class CMyWellNamedClass2 : public my_class { + // CHECK-FIXES: {{^}}class CMyWellNamedClass2 : public CMyClass {{{$}} + t_t my_Bad_Member; + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'my_Bad_Member' + // CHECK-FIXES: {{^}} t_t __my_Bad_Member;{{$}} + int my_Other_Bad_Member = 42; + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'my_Other_Bad_Member' + // CHECK-FIXES: {{^}} int __my_Other_Bad_Member = 42;{{$}} +public: + CMyWellNamedClass2() = default; + CMyWellNamedClass2(CMyWellNamedClass2 const&) = default; + CMyWellNamedClass2(CMyWellNamedClass2 &&) = default; + CMyWellNamedClass2(t_t a_v, void *a_p) : my_class(a_p), my_Bad_Member(a_v) {} + // CHECK-FIXES: {{^}} CMyWellNamedClass2(t_t a_v, void *a_p) : CMyClass(a_p), __my_Bad_Member(a_v) {}{{$}} + + CMyWellNamedClass2(t_t a_v) : my_class(), my_Bad_Member(a_v), my_Other_Bad_Member(11) {} + // CHECK-FIXES: {{^}} CMyWellNamedClass2(t_t a_v) : CMyClass(), __my_Bad_Member(a_v), __my_Other_Bad_Member(11) {}{{$}} +}; +void InstantiateClassMethods() { + // Ensure we trigger the instantiation of each constructor + CMyWellNamedClass2 x; + CMyWellNamedClass2 x2 = x; + CMyWellNamedClass2 x3 = static_cast&&>(x2); + CMyWellNamedClass2 x4(42); + CMyWellNamedClass2 x5(42, nullptr); +} + template // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for type template parameter 'T' // CHECK-FIXES: {{^}}template{{$}}