Issue 145391
Summary clang-format: AlignConsecutiveBitFields doesn't work with bit field length specified by template argument
Labels clang-format
Assignees
Reporter mathcounts4
    clang-format version 19.1.7

`_clang-format:`
```
BasedOnStyle: LLVM
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
```

`myfile.hpp`:
```
template <int Bits>
struct ABC {
    std::size_t fAName : Bits;
    std::size_t fB : 1;
    std::size_t fCOtherName   : 63 - Bits;
};
```

Output:
```
>clang-format myfile.hpp
template <int Bits> struct ABC {
  std::size_t fAName : Bits;
  std::size_t fB          : 1;
 std::size_t fCOtherName : 63 - Bits;
};
```

In the output, the `:` and `Bits` on `fAName` are not vertically aligned with the `:` and bit field lengths on `fB` and `fCOtherName`.

Workaround: change `fAName : Bits;` to `fAName : 0 + Bits;`, which `clang-format` then aligns properly.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to