llvm / llvm-project

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

clang-format UseTab is broken for array initializer #57681

Open Zero-Tang opened 1 year ago

Zero-Tang commented 1 year ago

Suppose you have the following C code, creating a global array variable:

int array[]=
{
1,/**/
2/**/
};

When I use clang-format --style="{UseTab: Always}" command, four spaces are inserted like

int array[] = {
    1, /**/
    2  /**/
};

instead of a tab character I was expecting.

By the way, I think clang-format should provide a style preset that may satisfy Linux Kernel checkpatch. The entire reason I am submitting this issue is because I cannot adapt both my original code and clang-format style which satisfy the script without warning.

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-format