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

    <tr>
        <th>Summary</th>
        <td>
            Clang-format - Formatting of nested structures/arrays
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    The latest clang-format 14.0.6, does not seem to have the option to properly format nested array/struct.

A question about formatting the structures, multi-level assignments, etc.

When a comma is added to the last element of a struct/array initializer, it no longer formats any part of the structure assignments (aligning separate assignments, aligning comments, etc.)

This makes nice formatting of structures impossible, they are always jammed on the initial line, so there is no option to go from:

```
MDL_X_config_S MDL_X_config = { .nMessages = (uint32_t) CFG_CAN_MSG_COUNT,
    .nSensors  = (uint32_t) MDL_BATT_SUBCAN_RX_uiSensorIndex_COUNT,
    .nSwitches = (uint32_t) MDL_BATT_SUBCAN_RX_switchIndex_COUNT
};
```

to:
```
MDL_X_config_S MDL_X_config = { 
    .nMessages = (uint32_t) CFG_CAN_MSG_COUNT,
    .nSensors  = (uint32_t) MDL_BATT_SUBCAN_RX_uiSensorIndex_COUNT,
    .nSwitches = (uint32_t) MDL_BATT_SUBCAN_RX_switchIndex_COUNT
};
```

Unless we intentionally add a newline to separate the two, like:

```
MDL_X_config_S MDL_X_config = {
 
    .nMessages = (uint32_t) CFG_CAN_MSG_COUNT,
    .nSensors  = (uint32_t) MDL_BATT_SUBCAN_RX_uiSensorIndex_COUNT,
    .nSwitches = (uint32_t) MDL_BATT_SUBCAN_RX_switchIndex_COUNT
};
```

But then adding a comma to the last element disables formatting.





</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlVU2P2zYQ_TXSZbCCTFnW6qCDvcYWRbsJ0PWiuRm0NJKYpUiXpNZxfn2HlJOVG1-CHmMIlCnOvHnzwZmDbs7VrkeQ3KF1UEuuurtWm4E7WCyTNFlF7AEajRaUdmARB3Aaev6G4EhPH53Qyn86Gn1EI89w0VaEhw1wY_g5Yo_WmbF2SZRuo3Q9rWv4ZyQhr88PenQXTSdUF7AnldGg9RyGUTpxJ_ENJXBrRacGVC4coauvgP_ukSCh1sPAQVjgTUNMiKMLnpKfKNFrg25JbrJDHANXEEo4waX4isaDC3JFg9SqQ3NhSIjqDEduAsAV1Tk1iNg94XTKO2SR5CnI_-X-XcCzvXKIlXOfdj05MvBXnwhR4zxWxOE9VCCGoyYTB4keicidKQdkVp742cJnTlYa8Ckj2hdXQQoVpG0IEUkLn-5ZcjsNrdFDlK3nnKJVennC9mn75_7TvtaqFd3-GeZbiLItRMUGEvWE1vKOiIZP7H4UymVsT_Ev4eHxt_3D-sP-6ZneH18-7IjUhA30S9QzKquNhVu63txmvdvtn182HuOvT_tRTAq_qwa_3AY8CVf3t8ncALRBfA43xaHYRtnmZkym1en3yP18zOaEf8XovShJXsPJ16ujK0I1ySU1GrrWdHsVnnz5-ir9fsd8bbuT9iUtxSv-77K9OP2rJ2JDPdqF3to0vvF8a7G3OmsjLKceZGeN6qpH_7jGWC1WK5YVq3TJ4qbKmjIreeyEk1g9zAfTHTxedb_LqJnPi6mX23g0suqdO1pfA-yRnk64fjwkxJw2Ur59e93RAPuMYQ4Ia8cAkhd5XsZ9tWjLMl2WiHleHzCrm5an5arOF0XGeNHyWPIDSltF-SZijCoSAgT9j_JtLCqWMpaWab5YpAVjScGy--K-XWZpvapbvoyWKQ5cyMTzSLTpYlMFSoexs3QohXX2_XCaIIjBHOHz0fXaVH9o6uzCjF-xfhVxIFAFB_4Fagh14w">