https://github.com/t-a-james updated 
https://github.com/llvm/llvm-project/pull/185875

>From 9bea273bda890c0b7d591f8a5fd8f84b6c6c18f3 Mon Sep 17 00:00:00 2001
From: Tom James <[email protected]>
Date: Wed, 11 Mar 2026 13:15:35 +0000
Subject: [PATCH] [clang-tidy] Correctly ignore function templates in
 derived-method-shadowing-base-method (#185741)

---
 .../bugprone/DerivedMethodShadowingBaseMethodCheck.cpp     | 6 +++++-
 .../bugprone/derived-method-shadowing-base-method.cpp      | 7 +++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

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();
+};

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to