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

    <tr>
        <th>Summary</th>
        <td>
            clang-format regression with spaces around trailing-return-type
        </td>
    </tr>

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

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

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

<pre>
    Here is my clang-format file:
```
BasedOnStyle: llvm

AccessModifierOffset: -4
AlignConsecutiveBitFields: Consecutive
AlignEscapedNewlines: Right
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BraceWrapping:
  BeforeElse: true
  BeforeCatch: true
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: true
IndentWidth: 4
InsertBraces: true
NamespaceIndentation: None
PenaltyBreakAssignment: 60
PenaltyBreakBeforeFirstCallParameter: 175
PointerAlignment: Left
QualifierAlignment: Custom
QualifierOrder: ['static', 'inline', 'constexpr', 'type', 'const', 'volatile']
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpacesBeforeTrailingComments: 2
SpacesInSquareBrackets: false
```

On clang 17.0.6, I get this formatting:
```cpp
#define DEFINE_CHECKED(name, op) \
    template <typename R, std::integral A, std::integral B>                                        \
 constexpr auto checked_##name(A a, B b) -> CheckedResult<R> { \
        return something_interesting(a, b); \
    }

DEFINE_CHECKED(add, +)
```
On clang 18.1.4 and later, I started getting this formatting:
```cpp
#define DEFINE_CHECKED(name, op) \
    template <typename R, std::integral A, std::integral B>                                        \
 constexpr auto checked_##name(A a, B b)->CheckedResult<R> { \
        return something_interesting(a, b); \
    }

DEFINE_CHECKED(add, +)
```

The spaces around the trailing-return-type are now absent, as if the formatter things this is class member access instead of being a function declaration. I'm not sure exactly when the change happened, those are just two versions I have handy. 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkVtFv27gP_muUF6KBYydx-pAHx22wYP01_bU77HFgbNrWKks-iW6W_fUHyWmTdN3hHg-4YMBg8hNFfh_FEp2TtSZaitlKzG5G2HNj7HJn6eWn1KOdKQ_LT2QJpIP2AIVCXV9VxrbIUElFIslElIl5dPwXZSt0VG71Ex-CF5R6aT0kyrKiIOf-Z0pZSbLbqnLEHnE19U4la50b7ajoWb7QSvJakiqdR5zZX6G3rsCOynvaK6kpoB5l3XDwK7PPlHpAiy0xWbetbqhQaJGl0Vt9Tz_4TuqQXoXK0euhp8ZYXilTPLutzp6krhX9HrjudeED_opl219Cc3R0hztSf4Pd48GtLOHzF2o7hUxnObsz5ErqByyeM1v3LWl258kdfafKL5w--IoqY2klNdrDtiOLbAbUvdFZaAYf9B3aYjFQnPeOTfvq9bKw7Qs2dqMlS1Ty5_HO4WBu2hZf0RvdkJWMuqA76fgjFBb01WLXSV0PjQVHyK2v4ETBqzlHLpoze25U3-o72coQfhJFwfhRlplSW73VQYat3Wp6IPtOko0uSfNXWXK4YxpMjiyf-Dgi77El12FBw5Eg2ZFT734gjYoPgYUzjpMMwos5dw91raV1nONZC4dy0plHG6nZ538W5o4qL9n_e1ThbV043zR7c29tOUT0jz5OnU-4EHEq4hxEnErtn9Tpu_AE0o_Onkx86N4DTp8vRiH72RCnYnYjouzJWN7oQvXlBWve_IeTuv5Noz95RrOKyeZhmuQ4dM0v7tcH85kOe2PL9xg3kPrFolRS177dXt9N_IbZ6Kc_exx6_ZkuX9X5eBNRttXDHIRJOo7Gc1_1Bmpi4EY6GIYjv7Xw2-Gi6_xnnJRUSU1wc7ve3N9-yz_d5p9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