Skip to content

[clang-format] AllowShortCompoundRequirementOnASingleLine conflicts with BraceWrapping #136266

@tuero

Description

@tuero

I'm not sure if this is an issue or expected behaviour. I have a minimal config file, with AllowShortCompoundRequirementOnASingleLine: true and with the BraceWrapping sub-option AfterControlStatement: MultiLine:

Language: Cpp
AccessModifierOffset: -4
AllowShortCompoundRequirementOnASingleLine: true # clang-format 18
BraceWrapping: # Requires BreakBeforeBraces: Custom
  AfterControlStatement: MultiLine  # comment me out
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
IndentRequiresClause: true
IndentWidth: 4
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope # clang-format 16
Standard: c++20
TabWidth: 4
UseTab: Never

This formats the following concept as such:

template <typename T>
concept IsDataset = requires(const T ct) {
    {
        ct.size()
    } -> std::same_as<int>;
};

However, if I remove AfterControlStatement: MultiLine, then I get what I would expect should be the correct formatting:

template <typename T>
concept IsDataset = requires(const T ct) {
    { ct.size() } -> std::same_as<int>;
};

Question: Is there a way to have both multi-line brace wrapping after control statements, along with single line short compound requirement clauses?

$ clang-format --version 
Ubuntu clang-format version 20.1.2 (++20250402124932+58df0ef89dd6-1~exp1~20250402004952.98)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions