| Issue |
52993
|
| Summary |
clang-format -lines removes a line outside of its range
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
argothiel
|
After running clang-format on my file, and then git-clang-format, I'm receiving a discrepancy. After short investigation, it looks like the clang-format -lines option modifies the file outside of the given range.
Steps to reproduce (no .clang-format file):
```
$ cat > MyFile.h
namespace myns
{
enum class MyEnum {
FIRST,
SECOND,
THIRD,
LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};
}
^D
$ clang-format -lines=3:8 MyFile.h
$ cat MyFile.h
```
Output:
```
namespace myns
{
enum class MyEnum
{
FIRST,
SECOND,
THIRD,
LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};
}
```
Expected output:
```
namespace myns
{
enum class MyEnum
{
FIRST,
SECOND,
THIRD,
LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};
}
```
It's especially problematic for the git flow like this:
```
$ cat MyFile.h
namespace myns
{
enum class MyEnum {
FIRST,
SECOND,
THIRD,
LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};
}
$ clang-format -i MyFile.h
$ cat MyFile.h
namespace myns
{
enum class MyEnum {
FIRST,
SECOND,
THIRD,
LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};
}
$ git add MyFile.h
$ [[ $(git clang-format -q --diff) ]] && echo "Invalid formatting"
Invalid formatting
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs