This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] BraceWrapping.BeforeElse is incorrect for BS_Linux
ClosedPublic

Authored by ksuther on Dec 13 2015, 7:47 PM.

Details

Summary

The BraceWrapping of the Linux style is incorrect. This appeared in r248802 when the custom BraceWrapping options were added.

This is what r248801 looked like:

clang-format -style="{BasedOnStyle: google, BreakBeforeBraces: Linux}" ~/Desktop/format.m
void main()
{

if (blah) {
  stuff();
} else {
  more();
}

}

This is what r248802 (and trunk) looks like:

clang-format -style="{BasedOnStyle: google, BreakBeforeBraces: Linux}" ~/Desktop/format.m
void main()
{

if (blah) {
  stuff();
}
else {
  more();
}

}

The behavior before r248802 is correct based on the documentation:

BS_Linux (in configuration: Linux) Like Attach, but break before braces on function, namespace and class definitions.

I changed BraceWrapping.BeforeElse to false for Linux and added and else statement to the Linux brace test.

Diff Detail

Event Timeline

ksuther updated this revision to Diff 42680.Dec 13 2015, 7:47 PM
ksuther retitled this revision from to [clang-format] BraceWrapping.BeforeElse is incorrect for BS_Linux.
ksuther updated this object.
ksuther added reviewers: cfe-commits, djasper.
djasper accepted this revision.Dec 14 2015, 12:38 AM
djasper edited edge metadata.

Submitted as r255484 and r255485.

This revision is now accepted and ready to land.Dec 14 2015, 12:38 AM
djasper closed this revision.Dec 14 2015, 12:38 AM