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

    <tr>
        <th>Summary</th>
        <td>
            clang-format RemoveBracesLLVM changes the pairing of `else` to wrong `if`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format,
            invalid-code-generation
      </td>
    </tr>

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

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

<pre>
    ```
$ cat bug.cpp
if (a)
  if (b)
    c;
  else {
    if (d)
      e;
  }
else
  g;

if (a)
  if (b)
    c;
  else {
    if (d)
      e;
    else if (f)
      g;
  }
else
  h;
$ clang-format -version
clang-format version 14.0.3
$ clang-format -style="{RemoveBracesLLVM: true}" bug.cpp
if (a)
  if (b)
    c;
  else if (d)
    e;
  else
    g;

if (a)
  if (b)
    c;
  else if (d)
    e;
  else if (f)
    g;
  else
    h;
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9Uk1v4yAQ_TX4gmwRbOz4wKHZqKf2soe9YxhjVsRYgFP13y-Ok82HWu0eqkoImHlvNG8-OqfeOarJ-ZA9Ik-IVliKiLtZF3KaVqfpMaJbgWi72hivnu7Gg7FE5e5igQ2AUbO7omuEuotIvJsY1OzX7xJ8ceq_hO-Uco5aif0DUf9L83DVvHTTilHnvfOH1Nb8CD4YN67wHXRG8KYqSFF-Fh_iu01K94jSVNNPOLgj7LyQEF5efr2i8glHP8Mii9IvGeJHzYIH0hX5onH9T9IPp6M_VXYzlMvGZ4qXqi1bkUUTLfC7Tj-2FsshoRBwHABPwngzauyShJqcEtUER4ffvEvuZJh-STB7y4cYp5AGg-hzOtrEYe4K6Q7JsPZ4efLJu98gYzJNCDOE9GGsIXU28K2Qraw2Smxp01a1qppWsaasetn1LF2ZFV3SwBHbpanfVrFsCf2R2kTNeBTWqFw6BbmGEbyIyx4mAttnhlNCKWG0JhvalHVBlGKM1NsNa1qQFaCKwEEYWyxaC-d15vlJdlqxkEBrQgxXUIRg9AhwluTeYJTinEvMcXCer77sVCw_VfoHTds52w">