Index: clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp +++ clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp @@ -23,10 +23,15 @@ ast_matchers::internal::Matcher InheritsVirtualMethod = hasAnyBase(hasType(cxxRecordDecl(has(cxxMethodDecl(isVirtual()))))); + ast_matchers::internal::Matcher BaseHasPublicVirtualDtor = + hasAnyBase(hasType( + cxxRecordDecl(has(cxxDestructorDecl(isPublic(), isVirtual()))))); + Finder->addMatcher( cxxRecordDecl( anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod), unless(anyOf( + BaseHasPublicVirtualDtor, has(cxxDestructorDecl(isPublic(), isVirtual())), has(cxxDestructorDecl(isProtected(), unless(isVirtual())))))) .bind("ProblematicClassOrStruct"), Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp @@ -202,3 +202,12 @@ void m(); }; // inherits virtual method + +// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'TemplatedDerived' is public and non-virtual [cppcoreguidelines-virtual-class-destructor] +template +struct TemplatedDerived : PublicVirtualBaseStruct { +}; + +void test_templates() { + TemplatedDerived x; +}