File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,14 @@ using namespace clang::ast_matchers;
1515using namespace clang ;
1616
1717namespace {
18+
1819AST_MATCHER (NamedDecl, isOperatorDecl) {
1920 DeclarationName::NameKind NK = Node.getDeclName ().getNameKind ();
2021 return NK != DeclarationName::Identifier &&
2122 NK != DeclarationName::CXXConstructorName &&
2223 NK != DeclarationName::CXXDestructorName;
2324}
25+
2426} // namespace
2527
2628namespace clang ::tidy {
@@ -94,16 +96,16 @@ void VisibilityChangeToVirtualFunctionCheck::check(
9496 return ;
9597
9698 const auto *ParentClass = Result.Nodes .getNodeAs <CXXRecordDecl>(" class" );
97- const auto *OverriddenFunction =
98- Result.Nodes .getNodeAs <FunctionDecl>(" base_func" );
9999 const auto *BaseClass = Result.Nodes .getNodeAs <CXXRecordDecl>(" base" );
100+ CXXBasePaths Paths;
101+ if (!ParentClass->isDerivedFrom (BaseClass, Paths))
102+ return ;
100103
104+ const auto *OverriddenFunction =
105+ Result.Nodes .getNodeAs <FunctionDecl>(" base_func" );
101106 AccessSpecifier ActualAccess = MatchedFunction->getAccess ();
102107 AccessSpecifier OverriddenAccess = OverriddenFunction->getAccess ();
103108
104- CXXBasePaths Paths;
105- if (!ParentClass->isDerivedFrom (BaseClass, Paths))
106- return ;
107109 const CXXBaseSpecifier *InheritanceWithStrictVisibility = nullptr ;
108110 for (const CXXBasePath &Path : Paths) {
109111 for (const CXXBasePathElement &Elem : Path) {
You can’t perform that action at this time.
0 commit comments