Author: Devajith Date: 2026-03-22T13:19:41+01:00 New Revision: 720abd76e71f722f546c58af11049c773a583058
URL: https://github.com/llvm/llvm-project/commit/720abd76e71f722f546c58af11049c773a583058 DIFF: https://github.com/llvm/llvm-project/commit/720abd76e71f722f546c58af11049c773a583058.diff LOG: [clang][AST] Fix assertion in getFullyQualifiedType for DecltypeType (#187725) Added: Modified: clang/lib/AST/QualTypeNames.cpp clang/test/Interpreter/pretty-print.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp index 7cdee52acce3f..066c5de35bba9 100644 --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -450,6 +450,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 ef0ee8e233c28..852c4117197d8 100644 --- a/clang/test/Interpreter/pretty-print.cpp +++ b/clang/test/Interpreter/pretty-print.cpp @@ -73,6 +73,18 @@ auto y = Outer::Bar<int>(); y const auto z = Outer::Foo(); z // CHECK-NEXT: (const Outer::Foo &) @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
