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

    <tr>
        <th>Summary</th>
        <td>
            [clang-format]Adding comments in ternary expressions results in absurd formatting
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format
      </td>
    </tr>

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

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

<pre>
    Found in version: 0.1.28

Code Snippet 1: Before applying clang-format:
```
    test = testA ? 100 :
               testB ? 200 : // this is a comment
 300;
```

Code Snippet 2: After applying clang-format (with comment):
```
    test = testA ? 100 : testB ? 200
 : // this is a comment
 300;
```

However, if the comment is removed from Code Snippet 1, the following result is obtained:

Code Snippet 3: After applying clang-format (without comment):
```
    test = testA ? 100 : testB ? 200
                                            : 300;
```

Note: Code Snippet 3 is still not properly indented, but that's an issue that's already been raised in other 'Issues' requests.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VMuO2zgQ_Brq0hiDalmmddDBHq-xe9nL7g9QYttiQJEK2fLEfx9QdiZxMkAeSAhBz6oiq9RsnZI9e6JW1HtRHwo98xBi-9dk-_9jcG7bqKIL5toew-wNWA8XiskGL6odyFW5wq2QByF3t_NzMAT_eTtNxFBmzJ5OIRLoaXJX68_QO-3PT6cQR82iutPERt6P5REAgCkxiOqw3OxAVEcopYRXCjyOjNovKLyhQOBR4BF4sAlsAg19GEfyfKdXUopq_-b0b1jBrLg7McW3nYDA7Yvl4XUSbH7N3KORO-N32Pk7vNCFosBnsCfggT4JZLVIY7iQgVMMI3z1D_F5QZ-Cc-El-46UZrfQQsfaejKfrX6bXPWDyYWZ_0x4PzGyxHeD_DcwZeCjyxxHYusc-MAwxTBRdFew3pBnMjnFbmbgQbNAlUB7sCnN9MUbF0mbK3REHqK2iZbtFnigCALVPxmeBCqI9H6mxGlVmLYyTdXogtpSlQ0iqq0shraXum8ac2pUWeMaN40qFZqacNPUZb3BwrYocS03uJZNXUm5kr1SpKjpFaluqzZiLWnU1q2cu4yrEM_Fsty22axVWTjdkUtLz0B82NGIuYvENtOeuvmcxFo6mxf7KsSW3dJvHoj1YWfMUhy3IkjZPFP0Ol6BPkyRUm476V5-y2fdpTkauCmw9edijq4dmKeUC2jZMWfLw9yt-jAKPOY13C9PUwzvqGeBR3tP9ngzd2nxYwAAAP__vxl_Cw">