[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else...
authorPaul Hoad <mydeveloperday@gmail.com>
Wed, 13 Mar 2019 08:26:39 +0000 (08:26 +0000)
committerPaul Hoad <mydeveloperday@gmail.com>
Wed, 13 Mar 2019 08:26:39 +0000 (08:26 +0000)
commit15000a127a31e0321e58b34b78a042b37cfc0eac
tree91f2a4f4c2c65dbe1fc792ec642c3462ecd28d72
parentd74c055fe640d85d5fb22e261770601567c769ee
[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

Summary:
Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

```
    if(true) var++;
    else  {
        var--;
    }
```

is reformatted to be

```
  if (true)
    var++;
  else {
    var--;
  }
```

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a compound else

Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
Reviewed By: reuk
Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59087

llvm-svn: 356031
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestSelective.cpp