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

    <tr>
        <th>Summary</th>
        <td>
            clang-format: misformatted method body when declared with trailing return type syntax followed by a 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>
          elevendroids
      </td>
    </tr>
</table>

<pre>
    `clang-format` incorrectly formats methods declared with the trailing return type syntax followed by a `requires` clause.

Tested version:
```
clang-format version 15.0.0 (https://github.com/llvm/llvm-project.git e8716179eb0b57ad6d767bb17f349f32f387c7bd)
```

Platform:
Arch Linux, x86_64

---

Consider this example:

```c++
template<typename T>
struct Foo
{
    auto bar() -> int
    requires(is_integral_v<T>)
    {
        call_something();
        return 0;
    }
};
```

Reformatting it with `clang-format` (using the default configuration) leads to badly indented function body:
```c++
template <typename T> struct Foo {
  auto bar() -> int requires(is_integral_v<T>) {
                      call_something();
                      return 0;
                    }
};
```

When using the regular return type syntax... :
```c++
template<typename T>
struct Foo
{
    int bar()
    requires(is_integral_v<T>)
    {
        call_something();
        return 0;
    }
};
```

... the method is formatted as expected:
```c++
template <typename T> struct Foo {
  int bar()
    requires(is_integral_v<T>)
  {
    call_something();
    return 0;
  }
};
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVlUuP2jAQxz9NchkRhYQ8OOSwXbqnHqpqpR6REw-JK2NT2-Hx7TsOARaWqvRxqRUFbI8949_8M641P1RBHjeSqXay0mbNHHVBqEYbg42TBziOWlij6zS3wJGsDXLYCdeB6xCcYUIK1YJB1xsF7rBBsAfl2J5WS6l3ZF0fgAHtbfB7Lwxa74Y26i1GQbwI4qfj-xWtI-stGiu0CtJxmKzHZ-i-jfdkC9MsiqMYgqTsnNtYvzZ5oaelOPs6avSaOlJuTz-TjdHf6IwRGQCWxTSfFnOs4zorGM95kRd1PS1W6Wy-SpNVWhZNUfMgmd-N6Pj-LJnzUZ3jfjJNB5-E6vdB8gz7Ml_ms7cLJpPJ2-6zVlZwNIRVWMA9W28kXiBcO26C5IN_hlGHZMocGT97_IqtEV6D9ONx1jrTNw5etB73KMZlQI31TkPNDIGj08GEVpEA3MXgnLKkFHZJU9gaJpdb8jW4OCHxtlc7-9YwKZdWe_WQRI4-gvTGaBROfDURFItTtIvzxF3sX_AoBedFSMkclHlH1uS9t97Gq5bjivXSQaPVSrS9Yc4LjgBIZCTzgQkn_QvFUXlNrnrVeBuo6at5r8y76YDbfMAlFW9Z_SQHD6B_T_y6PcT_ut3Nxm17PDtfO1Rw4W6w7amA3CkWURTBg1z_QOYe55nwfyRuT8VzO9ZfoLowip0kyXyR2FANQ_6PBfnXtK5Y_ZLTHUaPEAp5lfJ5OmehE05idfXBp0-wFvYCawTov17YeU3e3GQP32InCOP9FfZGVr935VBXWNt7ji8ZXTt52FUFFtm0pvuHN9OYrYqymeVxkee8zqcZZxhKVqO0VZBRVhOFOxi2oP9BtghFlcRJEudJOk2yeJZEHFPOZgXDuixnSZMFsxjXdMLIxxFp04amGkKq-9bSpBTW2csks1a0CnFwR_tTgeq0qVDiFhU3WnAbDv6rIf4fa0Fnlw">