<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63200>63200</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format with lines option removes whitespace from a prior line
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
emosy
</td>
</tr>
</table>
<pre>
The option lines in clang-format should limit the edits that are made to just the lines specified. However, if the last non-whitespace line before the first line specified in the lines option has trailing whitespace, then this whitespace will be deleted.
Example (whitespace.cpp):
```
// Trailing whitespace example
void whitespace()
{
int four = 4;
int five = 5 ;
}
```
Note that there is whitespace after line 4. After running `clang-format --style=LLVM --lines=5:5 -i whitespace.cpp`, the file is modified as such:
```
// Trailing whitespace example
void whitespace()
{
int four = 4;
int five = 5;
}
```
Note that there is no longer any whitespace after the semicolon on line 4.
When telling clang-format to only work on line 5, it modifies line 4. This causes issues with `git clang-format` as it is intended to only format lines that were changed, but it ends up formatting additional lines.
This is in clang-format version 15.0.7 on Windows 11 64-bit.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVE2TozYQ_TXypQsKI4PtA4edOK4cNjlNZc8CNdAbIVFSY8f_PiXkmQk7ySWXVLlsg_rrvddPKgQaLGIjqhdRXXZq4dH5BicXHrvW6UfzOiK4mclZMGQxAFnojLJD1js_KYYwusVoMDQRA48IqIkD8KgYlEeYlEZgB9-XkM5TmTBjRz2hzuEXd8cbelH-BNSnEBUYrLPZfSTGMKsupUGLvfO4xvTkA6e377XicB8tnmOPKgB7RYbsAB8FYzseMSZQ-Nt7uJMx0CJoNMioc1FcRPElff_8p5pmgyDK00dG3s2zKM9CPoNEXTw_6bG8ivIKr59HAEzlUtzNkd7Md4pFU4njS_oDAECWoXeLByEvcBDyBX44oxuuZxUI-fJW4PKPs_3mGJNUPKJH2DKhekafKD7k8GV98ou1EYWoi80aZFngh0EhL1-__v4rZNmqgZCXSsgvFWQEPxBWF08FoCezdp6cTiqqAGHpxv-N0H_j87_QaR0YZwf0oOzjM7kRf8CJOmechafJ4LBZum_rlqJZwW5IZwfOmgfcnf_jPblajcRvdIZ3AV_jondqCdHFISwY4E48RikH4k1lURdRBeIIgSyj1ajf2z27J5etcO8RbTcqO6CO7duFYzJaHWCZnwkc51daU7SlMil_g3SdkD7fMTf0IVp5X-VFfoxIv5HV7h5gv4f6kLXE-U43Up_lWe2w2denuqxkcZS7sTloqbuqLfu21WqPClHqU10dT_vuWOIJd9SURSmLujjtz_JYybzqD9ifW6lKecSyq8WhwEmRyY25Tbnzw26lr6llWRQ7o1o04e0G9U0MytplCOJQGAocPtKY2GCzgbYqsLmvPE7uhhsj9t5NoGD25JIfd4s3zcg8h2iS1Q8D8bi0eecmUV5jx-dPNnv3HTsW5TWJLsrrOvhfAQAA___ilvBI">