<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55663>55663</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-format RemoveBracesLLVM should handle else block containing an if block
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            enhancement,
            clang-format
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          owenca
      </td>
    </tr>
</table>

<pre>
    The `RemoveBracesLLVM` option doesn't remove the braces of an `else` block that contains a single `if` statement when the body of the `if` statement is a block:
```
$ cat test.cpp
void f() {
  if (a1)
    f1();
  else {
    if (a2)
      f2();
  }

  if (a3)
    f3();
  else {
    if (b) {
      g();
      h();
    }
  }
}
$ clang-format -version
clang-format version 15.0.0 (https://github.com/llvm/llvm-project 09865ae95dbf0322bbf3e7b3847b2b11373a0297)
$ clang-format -style="{InsertBraces: true, RemoveBracesLLVM: true}" test.cpp
void f() {
  if (a1)
    f1();
  else if (a2)
    f2();

  if (a3) {
    f3();
  } else {
    if (b) {
      g();
      h();
    }
  }
}
```
Expected output:
```
...
  if (a3) {
    f3();
  } else if (b) {
    g();
    h();
  }
...
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVMGOmzAQ_RpzsRYZO4Rw4LDbdKVK20tV9W7DAG6JjbDJdv--Y0ho2GSlrqqqyJLxzLzxG_t5lK1eiq8tULJlX-Bgj_AwyBLc09O3z2iitvfaGlpZcIbwzNNhCqIeIWqKpLam0gQ8dA4CRnW2_IER0tPSGi-1cVRSp03TTfvoOkQ5Lz0cwHj63IKZEyKZkM63N-N0SDMlJ-KesD1h9xhwGvOSb2iJ23pwPi77frYera5oTfiO8JyS7GG2UqprikaZoPlsorRO5kAilrhQ1yVuQfIVErH8Ckuy_YnaelOx3lT88abqVRHha67Q4WtvWBc6l8yWn3B6nTTNXW2HAx7j3REGh9c_u1euk4cmacxiFoi13vcuXAx_xNFo344qLu0BF113PE93_WC_Q-kpy3fbVEKeVqpmgnOlagGZErtNprhKEpEJyXieLed0zc75lw6I2BPO8UA-GQeDn9WLNKgfRiD8A71S9dmXBeC_kMpNdVxp44Yg1vd6QxTI-b8IY_3KPv7s8Qahonb0_ejfeoxxHP9VjW-Vdauo65IW8guNhV5UFaLKRS4jr30HxUpVr-VCXWvHrqKtNBW2r4nZ3OBOvQ3bWuh_yHYyR-PQFe97C7jUzo0oW_6YptutiNoizzmUuxqbaq7SGueNypNtLrIdrzbbOo86qZBLQdIHVDEYpFdOXTI8BlQ9TpdlBWu6j3TBGecs5YInSSp2sSpTSISsFduwtCwTsmFwkLqLA7_YDk00FBNVNTYOnZ123v12Sud0YwAmGphfjr61Q2GfwZQymooqpop-AdnuuOM">