Skip to content

Undesired AST printout for PackIndexingExprΒ #116486

@zyn0217

Description

@zyn0217

Given

template <class... T, unsigned N>
auto foo(T ...params) {
  return params...[N];
}

Running clang -std=c++2c -fsyntax-only -Xclang -ast-print on it results in

template <class ...T, unsigned int N> auto foo(T ...params) {
    return 0xd3cffc0...[0xd3cffe0];
}

https://compiler-explorer.com/z/czchqqj1s

The cause is due to the inadvertent use of operator << in clang/lib/AST/StmtPrinter.cpp:

void StmtPrinter::VisitPackIndexingExpr(PackIndexingExpr *E) {
OS << E->getPackIdExpression() << "...[" << E->getIndexExpr() << "]";
}

Any PackIndexingExpr would be printed as their addresses rather than intelligible source codes, contrary to the behavior for any other expressions.

We should use PrintExpr() anyway.

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions