| Issue |
183845
|
| Summary |
clang-format 22 Regression with minimal repro: Adding an empty '---' section to _clang-format resets some settings
|
| Labels |
clang-format
|
| Assignees |
|
| Reporter |
Psycho900
|
Minimal Repro Steps:
Step 1) Create a _clang-format file with these contents:
```
---
AlignAfterOpenBracket: false
# --- # Uncomment these 2 lines to repro
# Language: Cpp
```
Step 2) Use this to re-format this C++ file:
```
void MyMethod(int whyDoesThisChangeLines) noexcept {
DoThing(whyDoesThisChangeLines,
"Adding 2nd '---' section in _clang-format moves whyDoesThisChangeLines");
}
```
Step 3) Observe that the resulting format has `DoThing(whyDoesThisChangeLines,` all on the same line.
Step 4) Uncomment the 2 lines in the _clang-format file:
```
---
AlignAfterOpenBracket: false
--- # Uncomment these 2 lines to repro
Language: Cpp
```
Step 5) Re-format the C++ file
BUG!
[EXPECTED]: The resulting file should still look like...
```
void MyMethod(int whyDoesThisChangeLines) noexcept {
DoThing(whyDoesThisChangeLines,
"Adding 2nd '---' section in _clang-format moves whyDoesThisChangeLines");
}
```
because our new "Language: Cpp" section doesn't add or overwrite any _clang-format options, so that section should not be producing a different output.
[ACTUAL]: The resulting file looks like this now:
```
void MyMethod(int whyDoesThisChangeLines) noexcept {
DoThing(
whyDoesThisChangeLines,
"Adding 2nd '---' section in _clang-format moves whyDoesThisChangeLines");
}
```
Notice that `DoThing(` and `whyDoesThisChangeLines,` are now on 2 different lines!
This is a recent regression in clang-format version 22 (It did not repro in version 21, even if you used the previously allowed values for `AlignAfterOpenBracket` )
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs