Skip to content

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Sep 21, 2025

Backport 90a6b00

Requested by: @zyn0217

@llvmbot
Copy link
Member Author

llvmbot commented Sep 21, 2025

@cor3ntin What do you think about merging this PR to the release branch?

@llvmbot llvmbot requested a review from cor3ntin September 21, 2025 14:03
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Sep 21, 2025
@llvmbot
Copy link
Member Author

llvmbot commented Sep 21, 2025

@llvm/pr-subscribers-clang

Author: None (llvmbot)

Changes

Backport 90a6b00

Requested by: @zyn0217


Full diff: https://github.com/llvm/llvm-project/pull/159980.diff

2 Files Affected:

  • (modified) clang/lib/Sema/SemaExprCXX.cpp (+2)
  • (modified) clang/test/SemaTemplate/destructor-template.cpp (+15)
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 25afa2f4dfe7a..a08971c6526fe 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -347,6 +347,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'}}
+
+}

@github-project-automation github-project-automation bot moved this from Needs Triage to Needs Merge in LLVM Release Status Sep 21, 2025
d1a80de 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 llvm#159630

(cherry picked from commit 90a6b00)
@tstellar tstellar merged commit db70369 into llvm:release/21.x Sep 23, 2025
5 of 10 checks passed
@github-project-automation github-project-automation bot moved this from Needs Merge to Done in LLVM Release Status Sep 23, 2025
Copy link

@zyn0217 (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
Development

Successfully merging this pull request may close these issues.

4 participants