Issue 161973
Summary [clang-format] Misaligned trailing comment on default case with `AlignConsecutiveShortCaseStatements`
Labels clang-format
Assignees
Reporter Alunderin
    With this config:
```yaml
AllowShortCaseLabelsOnASingleLine: true
AlignConsecutiveShortCaseStatements:
  Enabled: true
```

Trailing comments on "short default statements" are misaligned if other trailing comments are present.
For this to occur *at least one* case label has to be longer than the `default` label.

```cpp
switch (state) {
case State::Idle:    return 1; // Aligned
case State::Running: return 2; // Aligned
default:             return 3;             // Oops!
};
```

Interestingly, the alignment is only affected by the length of the case label, not the whole statement.

*Tested with version `18.1.3 (Ubuntu)` and `22.0.0git (commit 3c39187)`*
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to