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

    <tr>
        <th>Summary</th>
        <td>
            Formatting breaks for a member function with both a reference qualifier and a trailing requires clause
        </td>
    </tr>

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

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

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

<pre>
    From clang-format 19, member functions containing *both* a reference qualifier and a trailing requires clause, results in broken formatting until the closing brace of the following member function.
> cat test.cpp
```
template <int n> struct S
{
 void f() & requires(n == 1) {}

  // some comment
  void g() {}
};
```
> clang-format-19 test.cpp
```
template <int n> struct S
{
  void f() & requires(n == 1) {}

      // some comment
      void g()
  {
  }
};
```
Note the indentation of the `// some comment` and `void g()`, which is obviously incorrect. (Additional custom brace wrapping options are also ignored after the definition of `f`, but the above is just a simplified example without a custom .clang-format).

The expected output is what clang-format 18 gives:
> clang-format-18 test.cpp
```
template <int n> struct S
{
  void f() &
  requires(n == 1)
  {
  }

  // some comment
  void g() {}
};
```
This bug doesn't manifest when using explicit object parameters, so there *is* a workaround for now, but it would nice to avoid that change.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vc1u2zgQfhr6MoggU45-Djok8fq4l-0LkNRIYkORKjm00rdfkLYbb9AWi91WMGB7OD_fp_k4I0LQk0Xs2eMzezzuRKTZ-V5NVpMI80664Wt_8m4BZYSdHkbnF0Gw7xh_gQUXiR7GaBVpZwMoZ0loq-0EjD9JRzPjTyDA44gerUL4EoXRo0YPwg4ggLzQJvl7_BK1x5DqxIApvccQDQXQFqR3r2jhUp2Sf7SkDdCMoIwLySK9UAhuzMbRGeO2ZP4AsmDlkZVPrPoDlCAgDFSodb1a6_L6yX8Jl9UIQmDVi7YENkUF8lER_HWNaJ4vP-Ds9AAj4y3jHTBef2PEe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