[clang] [Clang] Fix an error-recovery crash after d1a80dea (PR #159976)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 21 01:35:00 PDT 2025
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/159976
That patch tried to ensure a TypeSourceInfo for a destructor name. However, we don't actually have one during error recovery, so we should bail in that case.
No release note, since it's a regression and a backport could improve the stability of clangd.
Fixes https://github.com/llvm/llvm-project/issues/159630
>From 7ecf104fa8e67c983fa5744994b8f82ef5d28175 Mon Sep 17 00:00:00 2001
From: Younan Zhang <zyn7109 at gmail.com>
Date: Sun, 21 Sep 2025 16:29:46 +0800
Subject: [PATCH] [Clang] Fix an error-recovery crash after d1a80dea
That patch tried to ensure a TypeSourceInfo for a destructor name.
However, we don't actually have one during error recovery, so we should
bail in that case.
No release note, since it's a regression and a backport could improve
the stability of clangd.
---
clang/lib/Sema/SemaExprCXX.cpp | 2 ++
clang/test/SemaTemplate/destructor-template.cpp | 15 +++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 5a9279d928465..0c04d01e77024 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -354,6 +354,8 @@ ParsedType Sema::getDestructorName(const IdentifierInfo &II,
CheckTypenameType(ElaboratedTypeKeyword::None, SourceLocation(),
SS.getWithLocInContext(Context), II, NameLoc, &TSI,
/*DeducedTSTContext=*/true);
+ if (T.isNull())
+ return ParsedType();
return CreateParsedType(T, TSI);
}
diff --git a/clang/test/SemaTemplate/destructor-template.cpp b/clang/test/SemaTemplate/destructor-template.cpp
index 7a3398308bbee..734269e854e5d 100644
--- a/clang/test/SemaTemplate/destructor-template.cpp
+++ b/clang/test/SemaTemplate/destructor-template.cpp
@@ -104,3 +104,18 @@ struct T : S {
~T() = default;
};
} // namespace PR38671
+
+namespace GH159630 {
+
+struct X {
+ template<typename T>
+ struct typo { // expected-note {{'typo' declared here}}
+ ~typo();
+ };
+};
+
+template<typename T>
+X::typo<T>::typ0::~typ0() {} // expected-error {{no member named 'typ0'}} \
+ // expected-error {{no type named 'typ0'}}
+
+}
More information about the cfe-commits
mailing list