Skip to content

Commit f91f894

Browse files
author
Tom James
committed
Move template logic to the matcher
1 parent 30ca722 commit f91f894

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

clang-tools-extra/clang-tidy/bugprone/MethodHidingCheck.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "MethodHidingCheck.h"
1010
#include "clang/ASTMatchers/ASTMatchFinder.h"
11+
#include "clang/ASTMatchers/ASTMatchers.h"
1112
#include <stack>
1213

1314
using namespace clang::ast_matchers;
@@ -39,14 +40,6 @@ bool namesCollide(const CXXMethodDecl &Lhs, const CXXMethodDecl &Rhs) {
3940
for (unsigned int It = 0; It < Lhs.getNumParams(); ++It)
4041
if (!sameBasicType(Lhs.getParamDecl(It), Rhs.getParamDecl(It)))
4142
return false;
42-
// Templates are not handled yet
43-
if (Lhs.isTemplated() || Rhs.isTemplated())
44-
return false;
45-
if (Lhs.isTemplateInstantiation() || Rhs.isTemplateInstantiation())
46-
return false;
47-
if (Lhs.isFunctionTemplateSpecialization() ||
48-
Rhs.isFunctionTemplateSpecialization())
49-
return false;
5043
return true;
5144
}
5245

@@ -97,9 +90,11 @@ void MethodHidingCheck::registerMatchers(MatchFinder *Finder) {
9790
Finder->addMatcher(
9891
cxxMethodDecl(
9992
unless(anyOf(isOutOfLine(), isStaticStorageClass(), isImplicit(),
100-
cxxConstructorDecl(), isOverride(),
93+
cxxConstructorDecl(), isOverride(), isPrivate(),
10194
// isFinal(), //included with isOverride,
102-
isPrivate())),
95+
// Templates are not handled yet
96+
ast_matchers::isTemplateInstantiation(),
97+
ast_matchers::isExplicitTemplateSpecialization())),
10398
ofClass(cxxRecordDecl(
10499
isDerivedFrom(cxxRecordDecl(unless(isInStdNamespace()))))
105100
.bind("derived_class")),

0 commit comments

Comments
 (0)