<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/116486>116486</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Undesired AST printout for PackIndexingExpr
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            good first issue,
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zyn0217
      </td>
    </tr>
</table>

<pre>
    Given

```cpp
template <class... T, unsigned N>
auto foo() {
  return T...[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`:

https://github.com/llvm/llvm-project/blob/e508bacce45d4fb2ba07d02c55391b858000c3b3/clang/lib/AST/StmtPrinter.cpp#L2519-L2521

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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlN-u2zYMxp9GviFiSLKdPxe-SJpmGFAUxU6G7ZaW6FidIrmSnCbn6Qc5aZcdrEAHCDYs0uLv-0gbYzQnR9SyZseafYFTGnxoX2-OS7EqOq9v7S_mQo7xPePbx3XJ70uN430n0Xm0mAhY9U5ZjLEsSzgy-Q4mNxfQ8JFV7-_JOCUPvfdMrpncAFvt7vsAgdIUHBzLsmTN7iNr9qx6BNlq_6b4M9Fvk3PGnSAzWXQnWMSkWbVXTO6Y3EkFiz7eXMLrwjt7g8WfjzSMaTEG4xJbcvAOTIJAcbIpgvlvzT8QDGVZ_luwcWkWDU96jzltxIDn-Eb6d_H8qivV94rfTXg8Ev95M4aUxsiqLZMHJg_Kn0djKSzoOlofKJTKn5k8vObYqxq-fPks4vPrx4FA4RQJTAQ9ESQPaSAwDvWFQiKXIEd9n-32IwVMPmQj8lpyMO57H5g8WNMxedi-HJk8vKRz-pTdzhTjmLmr7Y_RTyYNU_fgtfby7bYYg_9MKjF56KzPx1PD1x0qRXWj676THfKV5lI1TbUR3bpZc85V1VVZ809wyeqDbMRm8UE2Ujzzbd0ta_uE6q9fnaarcaf31zFk1V_9ZDV0BPM4kQaM2TYTALUOFCNFCJgGCpAGdHk8yFpzMp0liH4KikB5TTEPkfIuBQy3b953NODF-AC9D4DuBn4-iK5jPtl4F8tnzD8I4jDz5EZl4Mw0k87fXOZFd_uKt7LQbaU31QYLasWqEqsl33BRDG0tVL9CuapR4abBXjeiRuSi15sVLSssTCu5rIUQSyFrUYtyg2JJNaHoZFcJVKzmdEZjy9yz0odTYWKcqBViWa-XhcWObJx_PFKevNfQmxATzElMSibfMSnv7aq2ffAukdM50OyL0M6D0E2nyGpuTUzxnzLJJEvt705TNIE0bF-O9674Kc0Ovu1fMQXb_u_Zm0Ejk4eHoEsr_w4AAP__U02f2A">