Issue 142818
Summary clang-format not respecting RequiresClausePosition with trailing-return-type
Labels clang-format
Assignees
Reporter brevzin
    This source file:
```cpp
template <class T, class P>
struct Pointer {
    P pointer_ = P();

    auto operator*() const -> auto& requires (not std::is_array_v<T>) { return *pointer_; }
    auto operator->() const -> auto* requires (not std::is_array_v<T>) { return std::to_address(pointer_); }
};
```
with this .clang-format:
```
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: Consecutive
AlignEscapedNewlines: Right
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowBreakBeforeNoexceptSpecifier: OnlyWithParen
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortCaseLabelsOnASingleLine: true
AllowShortLambdasOnASingleLine: All
AlwaysBreakTemplateDeclarations: true
BreakBeforeBraces: Custom
BraceWrapping:
   AfterClass: false
 BeforeElse: true
   BeforeCatch: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakConstructorInitializers: BeforeComma
BreakBeforeConceptDeclarations: true
BreakInheritanceList: BeforeComma
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
IndentWidth: 4
IndentWrappedFunctionNames: false
IndentRequires: true
InsertBraces: true
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 20
PenaltyBreakBeforeFirstCallParameter: 175
ContinuationIndentWidth: 4
RequiresClausePosition: OwnLine
PointerAlignment: Left
QualifierAlignment: Custom
QualifierOrder: ['static', 'inline', 'constexpr', 'type', 'const', 'volatile']
Standard: c++20
SpacesInAngles: Never
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
 AfterRequiresInClause: true
  AfterRequiresInExpression: true
SpacesBeforeTrailingComments: 2
IndentPPDirectives: AfterHash
PPIndentWidth: 2

ColumnLimit: 100
```
formats as
```cpp
template <class T, class P>
struct Pointer {
    P pointer_ = P();

    auto operator*() const -> auto&
        requires (not std::is_array_v<T>)
    {
        return *pointer_;
    }
    auto operator->() const
        -> auto* requires (not std::is_array_v<T>) { return std::to_address(pointer_); }
};
```
I would expect the `operator->()` to be formatted the same way as the `operator*()` immediately before it. Here, it's not even respecting the `RequiresClausePosition: OwnLine` parameter. 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to