Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

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

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR25069
Status NEW
Importance P normal
Reported by Vittorio Romeo (vittorio.romeo@outlook.com)
Reported on 2015-10-06 05:19:24 -0700
Last modified on 2016-06-17 03:48:57 -0700
Version unspecified
Hardware PC Linux
CC D.Bahadir@GMX.de, klimek@google.com, matthias.scholz@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

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/

Quuxplusone commented 8 years ago

Error still exists in clang version 3.9.0 (trunk 272270)