Skip to content

Commit b58fabe

Browse files
committed
rearranged some code
1 parent eeea1b3 commit b58fabe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

clang-tools-extra/clang-tidy/misc/VisibilityChangeToVirtualFunctionCheck.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ using namespace clang::ast_matchers;
1515
using namespace clang;
1616

1717
namespace {
18+
1819
AST_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

2628
namespace 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) {

0 commit comments

Comments
 (0)