[clang-format] Regression: enumerator initializer continuation loses indent when wrapped (23 vs 22)
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
## Summary
In clang-format 23, when an enumerator's initializer is too long and must wrap
at a binary operator, the continuation line is emitted with no continuation
indentation — it is indented only to the enumerator's own level. In
clang-format 22 (and earlier) the continuation was correctly indented.
This only happens inside an `enum` body. The equivalent expression as a
namespace-scope or class-scope variable initializer still wraps correctly, so
the regression is specific to enumerator initializers.
## Steps to reproduce
Input (`enum_repro.cc`):
```c++
enum {
MyEnum = aaaaaaaaaaaaaaa + bbbbbbbbbbbbbbb
};
```
Command:
```
clang-format --style='{BasedOnStyle: LLVM, ColumnLimit: 40}' enum_repro.cc
```
## Actual vs expected
**clang-format 22.1.0-rc1 (expected):**
```c++
enum {
MyEnum =
aaaaaaaaaaaaaaa + bbbbbbbbbbbbbbb
};
```
**clang-format 23.1.0-rc1 (actual — buggy):**
```c++
enum {
MyEnum = aaaaaaaaaaaaaaa +
bbbbbbbbbbbbbbb
};
```
Contributor guide
Research direction
Start with enum_repro.cc and run clang-format with the LLVM style and ColumnLimit 40, comparing the output with the expected clang-format 22 result. Trace the clang-format formatting path for enum initializers and add regression coverage for the wrapped binary expression; done when the continuation is indented as expected without changing namespace- or class-scope initializer behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100