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

    <tr>
        <th>Summary</th>
        <td>
            clang-format creates wrong indentation when lines argument spans multiple if-else branches
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    `clang-format` will create an invalid indentation when you use the `-lines` argument and specify lines that span different if-else branches. This issue is especially noticable when using `git clang-format` because it is prone to specifying `-lines` arguments that trigger this problem.

### Steps to reproduce:

1. Clone this repo and checkout this branch: https://gitlab.freedesktop.org/Venemo/mesa/-/commits/clang_format_radv_gfx11_mesh_new_fast_launch 
2. Run the following command:
    `clang-format -i -lines=8676:8687 src/amd/vulkan/radv_cmd_buffer.c`
   Side note, the following also reproduces the problem:
   `git clang-format HEAD~`

### Expected outcome:

`clang-format` should produce the correct indentation as specified in the `.clang-format` file in that repo.

### Actual outcome:

An extra space is added, which is invalid.

### Potential workaround

The indentation of the same code is correct when running `clang-format` on the whole file (without `-lines`).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VMtu4zgQ_Br60rAgUbZsH3TwTkbY42JnsFejRbYkbihS4CNKLvvtC0pKJnEmgGEbfBSrq7sKvVe9IarZ8Q92fNhhDIN19T9kaLS71sqXmlW50Gj6fWfdiIFVOcxKaxCOMBCgAWWeUCsJykgyAYOyBuaBDLzYCNEThIGAVfleK0M-AaDr40gmABoJfiKhuhdYdiEMGMBPaECqriOXTqluT9oTtA6NGMhn8HNQHpT3kUB5oAUCtX4BY4MS2GpaGUSvTJ_e7lWA-zJaEpjoqZBAJmcNQbCvfLaLn0lvHINTfU8OwrBebjWNGcsfWH7dvnm5fuBHoMknaEeTszIKYuX1_dEig296eT6BOZrsoowYSDzaGNbltXpWXmEI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