[clang-format] fix conflict between FormatStyle::BWACS_MultiLine and BeforeCatch...
authorMitchell Balan <mitchell@stellarscience.com>
Mon, 6 Jan 2020 14:21:41 +0000 (09:21 -0500)
committerMitchell Balan <mitchell@stellarscience.com>
Mon, 6 Jan 2020 14:21:41 +0000 (09:21 -0500)
commitd45aafa2fbcf66f3dafdc7c5e0a0ce3709914cbc
treeafa25c852bd5b4db55025aaa116b9f027ee4764d
parentde735247c8b638efa8ce5783ac8c7c2e0b7cf3eb
[clang-format] fix conflict between FormatStyle::BWACS_MultiLine and BeforeCatch/BeforeElse

Summary:
Found a bug introduced with BraceWrappingFlags AfterControlStatement MultiLine. This feature conflicts with the existing BeforeCatch and BeforeElse flags.

For example, our team uses BeforeElse.

if (foo ||
    bar) {
  doSomething();
}
else {
  doSomethingElse();
}

If we enable MultiLine (which we'd really love to do) we expect it to work like this:

if (foo ||
    bar)
{
  doSomething();
}
else {
  doSomethingElse();
}

What we actually get is:

if (foo ||
    bar)
{
  doSomething();
}
else
{
  doSomethingElse();
}

Reviewers: MyDeveloperDay, Bouska, mitchell-stellar

Patch by: pastey

Subscribers: Bouska, cfe-commits

Tags: clang

Differential Revision: https://reviews.llvm.org/D71939
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp