Skip to content

Commit 18760ce

Browse files
authored
[Clang][AST] Fix PackIndexingExpr AST printout (#117947)
Fixes #116486 Also added a test
1 parent 9b5b3ed commit 18760ce

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ Bug Fixes to AST Handling
771771
and ``relatedalso`` comment commands.
772772
- Clang now uses the location of the begin of the member expression for ``CallExpr``
773773
involving deduced ``this``. (#GH116928)
774+
- Fixed printout of AST that uses pack indexing expression. (#GH116486)
774775

775776
Miscellaneous Bug Fixes
776777
^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/AST/StmtPrinter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,10 @@ void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
25142514
}
25152515

25162516
void StmtPrinter::VisitPackIndexingExpr(PackIndexingExpr *E) {
2517-
OS << E->getPackIdExpression() << "...[" << E->getIndexExpr() << "]";
2517+
PrintExpr(E->getPackIdExpression());
2518+
OS << "...[";
2519+
PrintExpr(E->getIndexExpr());
2520+
OS << "]";
25182521
}
25192522

25202523
void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -ast-print -std=c++2c %s | FileCheck %s
2+
3+
template <class... T, unsigned N>
4+
auto foo(T ...params) {
5+
return params...[N];
6+
}
7+
8+
// CHECK: template <class ...T, unsigned int N> auto foo(T ...params) {
9+
// CHECK-NEXT: return params...[N];

0 commit comments

Comments
 (0)