[clang] [clang-format] Support fine-grained alignment of variable declarations (PR #160270)

via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 5 23:34:18 PDT 2025


owenca wrote:

> This allows disabling variable alignment declarations while still having function alignment. It also distinguishes between class member variables and other variables (e.g. function local variables).

See https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options. I'm more interested in the first two bullets there. If we decide to go forward with enabling finer controls of aligning consecutive declarations of variables, we probably want to add an enum/struct option to `AlignConsecutiveDeclarations`.

An enum example:
```
AlignConsecutiveDeclarations:
  # excluding function pointers?
  AlignVariableDeclarations: Always # or DataMembers or Never
```

A struct example:
```
AlignConsecutiveDeclarations:
  AlignVariableDeclarations: # including function pointers?
    GlobalVariables: true
    LocalVariables: true
    DataMembers: true
```

https://github.com/llvm/llvm-project/pull/160270


More information about the cfe-commits mailing list