https://github.com/devajithvs created
https://github.com/llvm/llvm-project/pull/187725
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
```
>From 95e090635fbc0fa2b2b43c2397c7126852d815f3 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 | 9 +++++++++
2 files changed, 20 insertions(+)
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 9e3885e100c6b..c3bb80deb13c2 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 actual resolved 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..680a2d7243ccc 100644
--- a/clang/test/Interpreter/pretty-print.cpp
+++ b/clang/test/Interpreter/pretty-print.cpp
@@ -69,6 +69,15 @@ 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
+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]+}}
+
// int i = 12;
// int &iref = i;
// iref
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits