llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tidy Author: Tom (t-a-james) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/185875.diff 2 Files Affected: - (modified) clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp (+5-1) - (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/derived-method-shadowing-base-method.cpp (+7) ``````````diff diff --git a/clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp index 7c5867619cf4e..a49dd0c0e2622 100644 --- a/clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp @@ -83,6 +83,10 @@ AST_MATCHER(CXXMethodDecl, nameCollidesWithMethodInBase) { // similar matchers are used elsewhere in LLVM AST_MATCHER(CXXMethodDecl, isOutOfLine) { return Node.isOutOfLine(); } +AST_MATCHER(CXXMethodDecl, isTemplate) { + return Node.getDescribedFunctionTemplate() != nullptr; +} + } // namespace DerivedMethodShadowingBaseMethodCheck::DerivedMethodShadowingBaseMethodCheck( @@ -97,7 +101,7 @@ void DerivedMethodShadowingBaseMethodCheck::registerMatchers( cxxConstructorDecl(), isOverride(), isPrivate(), // isFinal(), //included with isOverride, // Templates are not handled yet - ast_matchers::isTemplateInstantiation(), + isTemplate(), ast_matchers::isTemplateInstantiation(), ast_matchers::isExplicitTemplateSpecialization())), ofClass(cxxRecordDecl(isDerivedFrom(cxxRecordDecl())) .bind("derived_class")), diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/derived-method-shadowing-base-method.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/derived-method-shadowing-base-method.cpp index c22598d84d1b2..c615646251470 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/derived-method-shadowing-base-method.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/derived-method-shadowing-base-method.cpp @@ -137,3 +137,10 @@ class Q : public Base void methodWithArg(MyInt *I); void methodWithArg(MyInt const* I); }; + +class R: public Base +{ +public: + template <typename T> + Base* getThis(); +}; `````````` </details> https://github.com/llvm/llvm-project/pull/185875 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
