[clang] [Clang][AST][NFC] Fix printing of dependent PackIndexTypes (PR #88146)

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 9 09:09:36 PDT 2024


https://github.com/sdkrystian created https://github.com/llvm/llvm-project/pull/88146

Dependent `PackIndexType`s currently print the memory address of the index `Expr*` rather than pretty printing the expression. This patch fixes that.

>From 04869abc01117c6f4f270b9b9b61cdb2a7e1acc6 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Tue, 9 Apr 2024 12:06:51 -0400
Subject: [PATCH] [Clang][AST] Fix printing of dependent PackIndexTypes

---
 clang/lib/AST/TypePrinter.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 075c8aba11fcb9..9602f448e94279 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1213,10 +1213,13 @@ void TypePrinter::printDecltypeBefore(const DecltypeType *T, raw_ostream &OS) {
 
 void TypePrinter::printPackIndexingBefore(const PackIndexingType *T,
                                           raw_ostream &OS) {
-  if (T->hasSelectedType())
+  if (T->hasSelectedType()) {
     OS << T->getSelectedType();
-  else
-    OS << T->getPattern() << "...[" << T->getIndexExpr() << "]";
+  } else {
+    OS << T->getPattern() << "...[";
+    T->getIndexExpr()->printPretty(OS, nullptr, Policy);
+    OS << "]";
+  }
   spaceBeforePlaceHolder(OS);
 }
 



More information about the cfe-commits mailing list