https://github.com/anuragGupta08 updated 
https://github.com/llvm/llvm-project/pull/219769

>From daabe4373df243055b9760e83e5d0eb37ac228a3 Mon Sep 17 00:00:00 2001
From: Anurag <[email protected]>
Date: Sun, 30 Aug 2026 11:13:55 +0530
Subject: [PATCH] [clang-tidy] Fix crash in readability-identifier-naming with
 forward-declared base

IdentifierNamingCheck::findStyleKind() calls
CXXRecordDecl::hasMemberName() on each base class of a method's
enclosing class to detect same-named base methods (e.g. CRTP). If a
base class is only forward-declared and not yet defined -- which can
happen for nested classes of a class template, since base-class
completeness isn't required until instantiation -- hasMemberName()'s
underlying CXXBasePaths::lookupInBases() assumes the base is complete
Fixes #213948
---
 .../clang-tidy/readability/IdentifierNamingCheck.cpp |  2 +-
 clang-tools-extra/docs/ReleaseNotes.md               |  3 +++
 .../checkers/readability/identifier-naming.cpp       | 12 ++++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 4ac23948c5e01..b8df914743889 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -1259,7 +1259,7 @@ StyleKind IdentifierNamingCheck::findStyleKind(
     // necessary even if it's not an override. e.g. CRTP.
     for (const CXXBaseSpecifier &Base : Decl->getParent()->bases())
       if (const auto *RD = Base.getType()->getAsCXXRecordDecl();
-          RD && RD->hasMemberName(Decl->getDeclName()))
+          RD && RD->hasDefinition() && RD->hasMemberName(Decl->getDeclName()))
         return SK_Invalid;
 
     if (Decl->isConstexpr() && NamingStyles[SK_ConstexprMethod])
diff --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index e81a4b7139106..a7166a30a67a8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -162,6 +162,9 @@ infrastructure are described first, followed by 
tool-specific sections.
 
   - Fixed {option}`DefaultHungarianPrefix` being incorrectly diagnosed as an
     invalid option.
+    
+  - Fixed a crash when a method's enclosing class inherits from a base
+    class that is only forward-declared and not yet defined.
 
 - Improved {doc}`readability-named-parameter
   <clang-tidy/checks/readability/named-parameter>` check by ignoring
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
index f0a72ee31bc21..0a0c77c21fc8d 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
@@ -834,3 +834,15 @@ Some_struct g_s1{ .SomeMember = 1 };
 // CHECK-FIXES: Some_struct g_s1{ .some_member = 1 };
 Some_struct g_s2{.SomeMember=1};
 // CHECK-FIXES: Some_struct g_s2{.some_member=1};
+
+// Regression test for https://github.com/llvm/llvm-project/issues/213948:
+// a base class that is only forward-declared must not be dereferenced
+// as if it were complete.
+
+template<class t_t>
+struct Issue_213948_outer {
+  struct Issue_213948_base;
+  struct Issue_213948_derived : public Issue_213948_base {
+    virtual void v_Foo() { }
+  };
+};

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

Reply via email to