llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Devajith (devajithvs)

<details>
<summary>Changes</summary>

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&gt; namespace N { struct D {}; }
clang-repl&gt; decltype(N::D()) x; x // asserts
```

---
Full diff: https://github.com/llvm/llvm-project/pull/187725.diff


2 Files Affected:

- (modified) clang/lib/AST/QualTypeNames.cpp (+11) 
- (modified) clang/test/Interpreter/pretty-print.cpp (+9) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/187725
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to