[clang] [Clang][AST] Fix PackIndexingExpr AST printout (PR #117947)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 28 14:53:23 PST 2024
https://github.com/AlexErofeev updated https://github.com/llvm/llvm-project/pull/117947
>From b3f7e8bda1bd38ef9bf5794ed4a6cece2ef77621 Mon Sep 17 00:00:00 2001
From: Aleksandr Erofeev <a.p.erofeev at gmail.com>
Date: Thu, 28 Nov 2024 00:19:06 +0000
Subject: [PATCH 1/2] Fix PackIndexingExpr AST printout
---
clang/lib/AST/StmtPrinter.cpp | 5 ++++-
clang/test/AST/ast-print-packindexingexpr.cpp | 9 +++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
create mode 100644 clang/test/AST/ast-print-packindexingexpr.cpp
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index c8677d11b64e8d..7507c9d14327a0 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -2514,7 +2514,10 @@ void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
}
void StmtPrinter::VisitPackIndexingExpr(PackIndexingExpr *E) {
- OS << E->getPackIdExpression() << "...[" << E->getIndexExpr() << "]";
+ PrintExpr(E->getPackIdExpression());
+ OS << "...[";
+ PrintExpr(E->getIndexExpr());
+ OS << "]";
}
void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
diff --git a/clang/test/AST/ast-print-packindexingexpr.cpp b/clang/test/AST/ast-print-packindexingexpr.cpp
new file mode 100644
index 00000000000000..157abeb99436a2
--- /dev/null
+++ b/clang/test/AST/ast-print-packindexingexpr.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -ast-print -std=c++2c %s | FileCheck %s
+
+template <class... T, unsigned N>
+auto foo(T ...params) {
+ return params...[N];
+}
+
+// CHECK: template <class ...T, unsigned int N> auto foo(T ...params) {
+// CHECK-NEXT: return params...[N];
>From c13a33c86603c0f0759415277ef78203ef3ef91c Mon Sep 17 00:00:00 2001
From: Aleksandr Erofeev <a.p.erofeev at gmail.com>
Date: Thu, 28 Nov 2024 22:52:33 +0000
Subject: [PATCH 2/2] Updated release notes
---
clang/docs/ReleaseNotes.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 70227a6248afad..aa815a0195e3cd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -766,6 +766,7 @@ Bug Fixes to AST Handling
and ``relatedalso`` comment commands.
- Clang now uses the location of the begin of the member expression for ``CallExpr``
involving deduced ``this``. (#GH116928)
+- Fixed printout of AST that uses pack indexing expression. (#GH116486)
Miscellaneous Bug Fixes
^^^^^^^^^^^^^^^^^^^^^^^
More information about the cfe-commits
mailing list