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

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] Incorrect Formatting Between clang-format off and clang-format on
        </td>
    </tr>

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

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

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

<pre>
    ### Title: Incorrect Formatting Between clang-format off and clang-format on

Here is a snippet of isolated and formatted C++ code, but in my configuration, it causes the section between "clang-format off" and "clang-format on" to be formatted. It seems that the SeparateDefinitionBlocks option doesn't prevent formatting and still triggers it before the // clang-format on section.

```cpp
// clang-format off
void function()
{

}
// clang-format on
```

The formatting result adds an extra line between the function and the // clang-format on comment:
```cpp
// clang-format off
void function()
{

}

// clang-format on
```

My environment:
* clang-format version 17.0.6 and version 18.1.4

.clang-format configuration:
```
Language: Cpp
SeparateDefinitionBlocks: Always
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0lNFu2zoMhp9GviFqWLQTJxe-SBoEp8A5V6cvIMuUo02WDElOl7cfZKdt0q3DgGGAAEMif5IfLVGEoHtL1LDVnq0OmZjiyfnGO6mmrHXdpWFYLguedTTEyh08Wem8Jxnh6PwgYtS2hz3FFyIL0gjbP6jZAE4pELb7cGhZsWPF7h_yBDqAgGD1OFJyBx2cEZG6WbYI0u6R4Z7hHqTriOEjtFMEbWG4gHRW6X7yImpnk0lHkGIKFCCeCALJZID2Wh5D_FghQ5yz_WCyyRIdtPReSQ5PEQLRkMKLOOf4n0bhRaQDKW11Src3Tn4N4MY5d-coWIZ1hNHTmWx8DZf6ljKHqI2B6HXfkw-JoCXlPM3RGR4ZHj-28BUsX3rJ1sWy5Dim7c80SrFid3a6AzVZubRrw3Cb_Ov9NU59-Exub9Ms3s8nukXxFCYTQXRdAGGBvkUvwGhLb91PPK_JZ_JfAEo3DGQjK_8C3-8j_ncBsmftnb0pBnf3wjP5kIh4nRf5egZ7O9rkPK-WWPmd6P7i3lOyYvevsP0k-vnBPc7Qn12z5LEzL-ISbkNkXVN223IrMmp4veJYY7Xm2anhmxLrcourqivWvFuvCs6rquOKOqU4qkw3WOCqWJdFsSkr5Lmgray55CgUx7IQrCpoENrkxpyH3Pk-0yFM1PBqXfI6M6IlE-aJcv-iGGKaMb5Juod26gOrCqNDDO-RYhoySXsnXB3-fOhkkzfNKcYxNWz5_b2Op6nNpRsYHlMJ18_D6N0XkpHhcSYLDI9XuHOD3wMAAP__8FitaA">