https://github.com/devajithvs updated https://github.com/llvm/llvm-project/pull/187725
>From 21705e2536a6a484181b693f8c5caca89bfcaf3e Mon Sep 17 00:00:00 2001 From: Devajith Valaparambil Sreeramaswamy <[email protected]> Date: Fri, 20 Mar 2026 16:42:25 +0100 Subject: [PATCH] [clang][AST] Fix assertion in getFullyQualifiedType for DecltypeType This is similar to 86c4e96, asserts "Unhandled type node" when the input QualType is a DecltypeType. This was exposed by clang-repl's value printer: ``` clang-repl> namespace N { struct D {}; } clang-repl> decltype(N::D()) x; x // asserts ``` --- clang/lib/AST/QualTypeNames.cpp | 11 +++++++++++ clang/test/Interpreter/pretty-print.cpp | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp index 9e3885e100c6b..b84ae6dd69e52 100644 --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -444,6 +444,17 @@ QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, QT = Ctx.getQualifiedType(QT, Quals); } + // Try to get to the underlying type for DecltypeType + while (const auto *DT = dyn_cast<DecltypeType>(QT.getTypePtr())) { + // Get the qualifiers. + Qualifiers Quals = QT.getQualifiers(); + QualType Underlying = DT->getUnderlyingType(); + if (Underlying.isNull() || Underlying->isDependentType()) + break; + // Add back the qualifiers. + QT = Ctx.getQualifiedType(Underlying, Quals); + } + if (const auto *TST = dyn_cast<const TemplateSpecializationType>(QT.getTypePtr())) { diff --git a/clang/test/Interpreter/pretty-print.cpp b/clang/test/Interpreter/pretty-print.cpp index f0548358d65db..abb80dcbefb35 100644 --- a/clang/test/Interpreter/pretty-print.cpp +++ b/clang/test/Interpreter/pretty-print.cpp @@ -69,6 +69,18 @@ namespace Outer { template<class T> struct Bar {}; } auto y = Outer::Bar<int>(); y // CHECK-NEXT: (Outer::Bar<int> &) @0x{{[0-9a-f]+}} +// Check printing of DecltypeTypes (this used to assert) +namespace N { struct D {}; } +decltype(N::D()) decl1; decl1 +// CHECK-NEXT: (N::D &) @0x{{[0-9a-f]+}} + +// double-nested DecltypeType +decltype(decl1) decl2; decl2 +// CHECK-NEXT: (N::D &) @0x{{[0-9a-f]+}} + +const decltype(N::D()) decl3; decl3 +// CHECK-NEXT: (const N::D &) @0x{{[0-9a-f]+}} + // int i = 12; // int &iref = i; // iref _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
