https://github.com/eiytoq updated 
https://github.com/llvm/llvm-project/pull/180442

>From e1ee028eb207917d052beaa4e0588b8cef55c1f7 Mon Sep 17 00:00:00 2001
From: eiytoq <[email protected]>
Date: Mon, 9 Feb 2026 05:32:06 +0800
Subject: [PATCH 1/2] [clang][Sema] Guard polymorphic check in
 TransformCXXTypeidExpr for incomplete record types

---
 clang/docs/ReleaseNotes.rst                   |  1 +
 clang/lib/Sema/TreeTransform.h                |  2 +-
 .../SemaCXX/typeid-incomplete-local-crash.cpp | 39 +++++++++++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/typeid-incomplete-local-crash.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a1bb1bd2467b7..e8570901ea154 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -262,6 +262,7 @@ Bug Fixes to C++ Support
 - Fixed a crash when instantiating ``requires`` expressions involving 
substitution failures in C++ concepts. (#GH176402)
 - Fixed a crash when a default argument is passed to an explicit object 
parameter. (#GH176639)
 - Fixed a crash when diagnosing an invalid static member function with an 
explicit object parameter (#GH177741)
+- Fixed a crash on ``typeid`` of incomplete local types during template 
instantiation. (#GH63242), (#GH176397)
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 6a4d88b28c614..9ba853d8408f4 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -14547,7 +14547,7 @@ 
TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
   auto EvalCtx = Sema::ExpressionEvaluationContext::Unevaluated;
   if (E->isGLValue())
     if (auto *RD = Op->getType()->getAsCXXRecordDecl();
-        RD && RD->isPolymorphic())
+        RD && RD->hasDefinition() && RD->isPolymorphic())
       EvalCtx = SemaRef.ExprEvalContexts.back().Context;
 
   EnterExpressionEvaluationContext Unevaluated(SemaRef, EvalCtx,
diff --git a/clang/test/SemaCXX/typeid-incomplete-local-crash.cpp 
b/clang/test/SemaCXX/typeid-incomplete-local-crash.cpp
new file mode 100644
index 0000000000000..5d7922257b15c
--- /dev/null
+++ b/clang/test/SemaCXX/typeid-incomplete-local-crash.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+namespace std {
+class type_info;
+}
+
+namespace gh176397 {
+auto recursiveLambda = [](auto, int) {
+  struct S; // expected-note {{member is declared here}}
+  typeid(*static_cast<S *>(nullptr)); // expected-error {{implicit 
instantiation of undefined member 'S'}}
+};
+
+void test() {
+  recursiveLambda(recursiveLambda, 10); // expected-note {{in instantiation of 
function template specialization}}
+}
+} // namespace gh176397
+
+namespace gh63242 {
+struct scoped {
+  enum class scoped2 {
+    RED,
+    YELLOW,
+    GREEN
+  };
+};
+
+template <auto N>
+struct scoped_struct {
+  void f() {
+    class scoped2 e = scoped::scoped2::RED; // expected-error {{implicit 
instantiation of undefined member 'scoped2'}} expected-note {{member is 
declared here}}
+    (void)typeid(e);
+  }
+};
+
+void test() {
+  scoped_struct<scoped::scoped2::RED> s;
+  s.f(); // expected-note {{in instantiation of member function 
'gh63242::scoped_struct<gh63242::scoped::scoped2::RED>::f' requested here}}
+}
+} // namespace gh63242

>From b6c7fec977e74e15e2fc3dfeb4194b0c746a160c Mon Sep 17 00:00:00 2001
From: eiytoq <[email protected]>
Date: Wed, 11 Feb 2026 20:27:03 +0800
Subject: [PATCH 2/2] Re-run CI


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

Reply via email to