[PATCH] D146809: [clang-repl] Implement Value pretty printing

Jun Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 1 08:42:54 PDT 2023


junaire added inline comments.


================
Comment at: clang/test/Interpreter/pretty-print.cpp:107
+p2
+// CHECK-NEXT: (std::_MakeUniq<int>::__single_object &) std::unique_ptr -> [[Addr:@0x.*]]
+
----------------
junaire wrote:
> Hi @mizvekov, do you have a clue about why it doesn't print the correct type? So in `ValuePrinter.cpp:50` I dumped the type it shows:
> ```
> AutoType 0x62d000533c00 'typename _MakeUniq<int>::__single_object' sugar
> `-ElaboratedType 0x62d000450500 'typename _MakeUniq<int>::__single_object' sugar
>   `-TypedefType 0x62d0004501e0 'std::_MakeUniq<int>::__single_object' sugar
>     |-Typedef 0x62d000450160 '__single_object'
>     `-ElaboratedType 0x62d000450100 'unique_ptr<int>' sugar
>       `-TemplateSpecializationType 0x62d0004500b0 'unique_ptr<int>' sugar unique_ptr
>         |-TemplateArgument type 'int':'int'
>         | `-SubstTemplateTypeParmType 0x62d00044fd50 'int' sugar typename depth 0 index 0 _Tp
>         |   |-ClassTemplateSpecialization 0x62d00044fa08 '_MakeUniq'
>         |   `-BuiltinType 0x621000019220 'int'
>         `-RecordType 0x62d000450080 'class std::unique_ptr<int>'
>           `-ClassTemplateSpecialization 0x62d00044ff70 'unique_ptr'
> ```
> 
> But in Cling it only has the RecordType. Do you think it's affected by your type resugaring patches?
Looks like below diff fixes this:
```
diff --git a/clang/lib/Interpreter/InterpreterUtils.cpp b/clang/lib/Interpreter/InterpreterUtils.cpp
index 05e6be0e9df2..da5da55e8e95 100644
--- a/clang/lib/Interpreter/InterpreterUtils.cpp
+++ b/clang/lib/Interpreter/InterpreterUtils.cpp
@@ -425,7 +425,7 @@ QualType GetFullyQualifiedType(QualType QT, const ASTContext &Ctx) {
   // Strip deduced types.
   if (const auto *AutoTy = dyn_cast<AutoType>(QT.getTypePtr())) {
     if (!AutoTy->getDeducedType().isNull())
-      return GetFullyQualifiedType(AutoTy->getDeducedType(), Ctx);
+      return GetFullyQualifiedType(AutoTy->getDeducedType().getDesugaredType(Ctx), Ctx);
   }
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146809/new/

https://reviews.llvm.org/D146809



More information about the cfe-commits mailing list