Skip to content

clang-format BreakBeforeBraces behavior changes with Allow...OnASingleLine parameters #25443

@vittorioromeo

Description

@vittorioromeo
Bugzilla Link 25069
Version unspecified
OS Linux
CC @Bagira80

Extended Description

Consider the following code:

void foo()
{
while(true)
{
bar();
}
}


When calling

clang-format ./c.cpp -style="{BreakBeforeBraces: Allman}"

or

clang-format ./c.cpp -style="{BreakBeforeBraces: Allman, AllowShortLoopsOnASingleLine: true}"

the result is:

void foo()
{
while(true)
{
bar();
}
}

This is the intended result.


When calling

clang-format ./cf.cpp -style="{BreakBeforeBraces: Allman, AllowShortLoopsOnASingleLine: true, AllowShortBlocksOnASingleLine: true}"

the result is:

void foo()
{
while(true) {
bar();
}
}

For some reason, the combination of

BreakBeforeBraces: Allman
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: true

makes the braces for loops (and control statements, if the other AllowShort... flags are activated) be indented incorrectly.

Seems like a bug.


More information:
http://stackoverflow.com/questions/32907190/

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang-formatobsoleteIssues with old (unsupported) versions of LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions