https://github.com/Serosh-commits created https://github.com/llvm/llvm-project/pull/199403
`CXXRecordDecl::forallBases()` can be called during template instantiation for a record that has no definition so in that case calling `bases()` asserts because the record's `DefinitionData` is null , so fix this by checking `hasDefinition()` before iterating over the record's bases. If the record has no definition, return `false`, matching the existing behavior for cases where the base classes cannot be computed Fixes #195133 >From 5e00093dc1bb444e51449a093020f747529975b3 Mon Sep 17 00:00:00 2001 From: Serosh-commits <[email protected]> Date: Sun, 24 May 2026 07:32:40 +0530 Subject: [PATCH] Fix dependent qualified base member lookup crash --- clang/lib/AST/CXXInheritance.cpp | 3 +++ clang/test/SemaTemplate/current-instantiation.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index 29f5916284ebb..23a9f112f9bcd 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -127,6 +127,9 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches) const { const CXXRecordDecl *Record = this; while (true) { + if (!Record->hasDefinition()) + return false; + for (const auto &I : Record->bases()) { const auto *Base = I.getType()->getAsCXXRecordDecl(); if (!Base || !(Base->isBeingDefined() || Base->isCompleteDefinition())) diff --git a/clang/test/SemaTemplate/current-instantiation.cpp b/clang/test/SemaTemplate/current-instantiation.cpp index 9214bbeb973d6..fdc98638b3923 100644 --- a/clang/test/SemaTemplate/current-instantiation.cpp +++ b/clang/test/SemaTemplate/current-instantiation.cpp @@ -247,3 +247,18 @@ namespace RebuildDependentScopeDeclRefExpr { // FIXME: We should issue a typo-correction here. template<typename T> N<X<T>::think> X<T>::foo() {} // expected-error {{no member named 'think' in 'RebuildDependentScopeDeclRefExpr::X<T>'}} } + +namespace GH195133 { + template <typename T> struct A { + void f(); + }; + + template <typename T> struct X { + struct S : A<int> {}; + static void f(S *p) { + p->template A<int>::f(); + } + }; + + void g() { X<int>::f(nullptr); } +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
