[clang] [clang-format] Add AlignConsecutiveEnums (PR #194154)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 5 06:50:25 PDT 2026
aaronsms wrote:
> You need to:
>
> * Run `clang/docs/dump_format_style.py`
> * Add a release note
> * Add parsing tests
> * Most importantly: Add tests for your option
>
> Does this really need to be a complete new option and alignment call, or could one just add a suboption and check that in aligning the assignments? If it gets its own function, the option should be disabled when aligning assignments is also turned on, so that we don't run a second time over the equals and don't change anything.
We are presented with two alternatives: (1) add an option for AlignConsecutiveEnumAssignments, and (2) add an sub-option under AlignConsecutiveAssignment to distinguish between enums and variable assignments.
Following #76663, I am expecting there will be future requests for more granularity, so I am leaning towards the latter option. What do you think?
Our target semantics can be achieved by the following configuration:
```yaml
AlignConsecutiveAssignments:
Enabled:
VariableAssignments: true
EnumAssignments: true
AcrossEmptyLines: true
AcrossComments: true
AlignCompound: true
PadOperators: true
```
And, of course, we should maintain the backwards compatibility where `Enabled: true` respects the existing behaviour of including all assignments.
Will follow up the changes after confirming this config interface change is appropriate.
https://github.com/llvm/llvm-project/pull/194154
More information about the cfe-commits
mailing list