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

    <tr>
        <th>Summary</th>
        <td>
            clang-format: Incorrect method body when combined with trailing return type  & `decltype` in `requires` clause
        </td>
    </tr>

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

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

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

<pre>
    Continuation of #56176 (@HazardyKnusperkeks).

Tweaking the original example in that issue by adding `&` to the trailing return and using `decltype(...)` in the requires statement breaks it:
```c++
  template<typename T>
  struct Foo
  {
    auto bar(T in) -> int& requires (is_integral_v<decltype(in)>) {
 call_something();
                             return 0;
 }
  };
```

Changing one of the following fixes the formatting again:
* `-> int&` to `-> int`
* `decltype(in)` to `T`
* `requires (...)` to `requires ...`

You need parens if you negate (`(!...)`), but I guess a (highly arbitrary looking) workaround is to change from
`requires (is_integral_v<decltype(in)>)`
to
`requires is_integral_v<decltype(in)> || true`
works (tested).


```
$ clang++ --version
Homebrew clang version 17.0.6
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2PozgQ_TXmUgoC833g0JOeaEZ77cueWgYq4Imxs3a5M9lfvzLJELp7V9qJkCNVvXouv_oQzslRI7as-MKK50h4moxtJ1Qzuh8m6sxwbfdGk9RekDQazBEYz4oyrUpgvGZ58k38Lexw_UN7d0Z7wpNjvIlZ8sySp9v5ckFxknoEmhCMlaPUQgH-FPNZIUgNNAkC6ZxH6K4ghiGAWZkwXrIyATJLJFkhVfBYJG81CD2Ad3fogL2i6xkZr-M4ZrwJgQs1gsW_vLTowJEgnFETdBbFyYEklt2TDNctX8_4l_AtVgDC-awEIcv2gV-LGeGFZV9_-R1Z3xMcjPllYdUaDCA8GeiEZbx-AakZb2DHsq8gNTFePlJjvJbuVWrC0Qr1-say_eZJS2C4lDcb-l4o9erMjDRJPYZqBNDm8v_83RVMHmhWPT_yf17tqyrbeu4nocegu9EYGiJofDRKmUswHuVPdHebnQVRMIpRSP3Qmj-Fmm2EuJd5a1zvvIE_qbFGvHyEbkV9NMMNvPqC4_2z_jQeNOIAZ2FRO5BHuC6mURAuzR46smY8XUnDyffQeYLvMHp0DkRATnKc1BWE7SRZYa-gjDktNWrgYuxJWOP1ANKFrPogJ8LRmnkV_ff7Yn0Mmc8s_4MCWLVn1R7Iely5Qq5LDoSOcPg42P_eIzyHXonw2DBHsNu9oXXS6Jv7m5mxs3i5YeDug7SKk7j8QBgNbTY0WSMibNMqKUqe8iKNprasMMmbruzqouh5lxd9kdRZlmKWDvyYd5FsecLzJE1rnuVJkcYD8rLkWV7kRdFkacPyBGchVazU2xwbO0bL_mmrusyLSIkOlVu2IudLortbMzPOw560bQjbdX50LE-UdOQeRCRJYfsuKnuC77o31mJPEObVDBB2K1wm1NCbuZMaB7hImj6tuVAngLAstlNw226bGgdLr4R3GHmr2ono7MLA8QPjh1HS5Lu4NzPjh5Do_W93tuYH9sT4YXm-Y_ywKPBPAAAA__9vYdG8">