Issue 142178
Summary clang-format regression with spaces around trailing-return-type
Labels clang-format
Assignees
Reporter brevzin
    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. 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to