[clang-tools-extra] [clangd] Avoid crash on pseudo-destructor selection (PR #195939)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 6 20:48:05 PDT 2026


nataliakokoromyti wrote:

> This expression is VALID.

yes yes good catch, changed the PR description. 

> Btw, do you known when `getNamedTypeInfo() == nullptr`, but `NameKind == CXXDestructorName`? Maybe we still need the check from this PR, but why `getNamedTypeInfo() == nullptr` for `y->~decltype(A())()` requires additional investigation.

I checked the `getNamedTypeInfo() == nullptr` case locally with current LLVM clang. For this input:

```cpp
struct A { ~A(); };
void b(const A *y) {
y->~decltype(A())();
}

the AST is a normal destructor member call, not a CXXPseudoDestructorExpr:

CXXMemberCallExpr ... 'void'
`-MemberExpr ... '<bound member function type>' ->~A

So this is one case where NameKind == CXXDestructorName but the original destructor spelling was ~decltype(A()), and the DeclarationNameInfo doesn't have NamedTypeInfo.

I agree that the null check is still reasonable because other callers already guard this. A Sema change to preserve source info for this spelling might be possible, but it seems broader than this crash fix.

https://github.com/llvm/llvm-project/pull/195939


More information about the cfe-commits mailing list