Skip to content

Commit

Permalink
[Clang][AST] Fix PackIndexingExpr AST printout (llvm#117947)
Browse files Browse the repository at this point in the history
Fixes llvm#116486 
Also added a test
  • Loading branch information
AlexErofeev authored Nov 29, 2024
1 parent 9b5b3ed commit 18760ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,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
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/AST/StmtPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions clang/test/AST/ast-print-packindexingexpr.cpp
Original file line number Diff line number Diff line change
@@ -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];

0 comments on commit 18760ce

Please sign in to comment.