llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.16k stars 12.03k forks source link

[clang-format] unexpected array align when ColumnLimit: 0 #100935

Open fcying opened 3 months ago

fcying commented 3 months ago

I wanted to achieve more flexibility by setting ColumnLimit:0, but the array being formatted with one element per line.

before:
const uint8_t data[] = {
    0x0,  0x3, 0x2, 0x1, 0x0, 0x1,  0x7,  0x0,  0x6e, 0xf4, 0xff,
    0xff, 0xe, 0xe, 0x4, 0x0, 0xdb, 0xf2, 0xff, 0xff, 0xd7,
};
after:
const uint8_t data[] = {
    0x0,
    0x3,
    0x2,
    0x1,
    0x0,
    0x1,
    0x7,
    0x0,
    0x6e,
    0xf4,
    0xff,
    0xff,
    0xe,
    0xe,
    0x4,
    0x0,
    0xdb,
    0xf2,
    0xff,
    0xff,
    0xd7,
};

config

---
Language: Cpp
IndentWidth: 4
ColumnLimit: 0
UseTab: Never

version

clangd version 18.1.3 (https://github.com/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu
llvmbot commented 3 months ago

@llvm/issue-subscribers-bug

Author: fcying (fcying)

I wanted to achieve more flexibility by setting ColumnLimit:0, but the array being formatted with one element per line. ``` before: const uint8_t data[] = { 0x0, 0x3, 0x2, 0x1, 0x0, 0x1, 0x7, 0x0, 0x6e, 0xf4, 0xff, 0xff, 0xe, 0xe, 0x4, 0x0, 0xdb, 0xf2, 0xff, 0xff, 0xd7, }; after: const uint8_t data[] = { 0x0, 0x3, 0x2, 0x1, 0x0, 0x1, 0x7, 0x0, 0x6e, 0xf4, 0xff, 0xff, 0xe, 0xe, 0x4, 0x0, 0xdb, 0xf2, 0xff, 0xff, 0xd7, }; ``` config ``` --- Language: Cpp IndentWidth: 4 ColumnLimit: 0 UseTab: Never ``` version ``` clangd version 18.1.3 (https://github.com/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0) Features: linux+grpc Platform: x86_64-unknown-linux-gnu ```