[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.
This commit is contained in:
Devajith 2026-03-12 14:23:50 +01:00 committed by GitHub
parent e99f35beb4
commit 86c4e96856
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View file

@ -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())) {

View file

@ -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