Skip to content

clang-format, Inconsistent formatting with BraceWrapping.AfterControlStatement: MultiLine for single-line and multi-line if conditions #140220

Open
@halcyonx

Description

@halcyonx

Tested with: clang-format version 20.1.3 (https://github.com/llvm/llvm-project 923a5c4)

Using BraceWrapping.AfterControlStatement: MultiLine leads to inconsistent formatting between single-line and multi-line if statements, which creates a visual inconsistency in codebases that use the compact if (cond) {} style.

BraceWrapping:
  AfterControlStatement: MultiLine
if (!flag1) {
	return;
}

if (flag2)
{
	return;
}

If a codebase uses AfterControlStatement: Never and all if statements were consistent, it may still be desirable to apply AfterControlStatement: MultiLine for multi-line if conditions only, while keeping AfterControlStatement: Never for all other cases.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions