[llvm-branch-commits] [clang] release/22.x: [clang][AST] Fix assertion in `getFullyQualifiedType` for AutoType (#186105) (PR #186882)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Mar 16 13:56:58 PDT 2026
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/186882
Backport 86c4e96
Requested by: @devajithvs
>From 56bf6b4ba84ccfaf3325dced797a1a9f45ebb677 Mon Sep 17 00:00:00 2001
From: Devajith <devajith.valaparambil.sreeramaswamy at cern.ch>
Date: Thu, 12 Mar 2026 14:23:50 +0100
Subject: [PATCH] [clang][AST] Fix assertion in `getFullyQualifiedType` for
AutoType (#186105)
getFullyQualifiedType() asserts "Unhandled type node" when the input
QualType is an AutoType.
This was exposed by clang-repl's value printer:
```
clang-repl> namespace N { struct D {}; }
clang-repl> auto x = N::D(); x // asserts
```
Strip AutoType early before the type-specific handling.
(cherry picked from commit 86c4e96856a645a4015adf0e4d1a779e5662c6ca)
---
clang/lib/AST/QualTypeNames.cpp | 5 +++++
clang/test/Interpreter/pretty-print.cpp | 9 +++++++++
2 files changed, 14 insertions(+)
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 191841649a86f..9e3885e100c6b 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -369,6 +369,11 @@ NestedNameSpecifier createNestedNameSpecifier(const ASTContext &Ctx,
/// versions of any template parameters.
QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
bool WithGlobalNsPrefix) {
+ // Use the underlying deduced type for AutoType
+ if (const auto *AT = dyn_cast<AutoType>(QT.getTypePtr()))
+ if (AT->isDeduced())
+ QT = AT->getDeducedType();
+
// In case of myType* we need to strip the pointer first, fully
// qualify and attach the pointer once again.
if (isa<PointerType>(QT.getTypePtr())) {
diff --git a/clang/test/Interpreter/pretty-print.cpp b/clang/test/Interpreter/pretty-print.cpp
index bad71cdd48f0b..f0548358d65db 100644
--- a/clang/test/Interpreter/pretty-print.cpp
+++ b/clang/test/Interpreter/pretty-print.cpp
@@ -60,6 +60,15 @@ struct S5 { int foo() { return 42; }};
&S5::foo
// CHECK-NEXT: (int (S5::*)()) Function @0x{{[0-9a-f]+}}
+// Namespaced types deduced via auto
+namespace Outer { struct Foo {}; }
+auto x = Outer::Foo(); x
+// CHECK-NEXT: (Outer::Foo &) @0x{{[0-9a-f]+}}
+
+namespace Outer { template<class T> struct Bar {}; }
+auto y = Outer::Bar<int>(); y
+// CHECK-NEXT: (Outer::Bar<int> &) @0x{{[0-9a-f]+}}
+
// int i = 12;
// int &iref = i;
// iref
More information about the llvm-branch-commits
mailing list