llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Continuation indent width clang-format 14 regression

Open JohnC32 opened this issue 3 years ago • 1 comments

Given test.cpp:

void foo() {
    std::ostringstream outStream;
    json               outJSON = {
        {    "type",                                             "asdf"},
        {    "name",                         "asdfasdfasdfsadfasdfasdf"},
        {"callback", "asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfsadfasdf"},
        {   "items",                                             foobar}
    };
}

and _clang-format

---
BasedOnStyle: Google
IndentWidth: 4
AlignArrayOfStructures: Right
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveDeclarations: Consecutive
...

With clang-format 13, we get:

void foo() {
    std::ostringstream outStream;
    json outJSON = {
        {    "type",                                             "asdf"},
        {    "name",                         "asdfasdfasdfsadfasdfasdf"},
        {"callback", "asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfsadfasdf"},
        {   "items",                                             foobar}
    };
}

With clang-format 14, we get:

void foo() {
    std::ostringstream outStream;
    json               outJSON = {
                      {    "type",                                             "asdf"},
                      {    "name",                         "asdfasdfasdfsadfasdfasdf"},
                      {"callback", "asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfsadfasdf"},
                      {   "items",                                             foobar}
    };
}

Notice the continuation indent is wrong. Note, if you remove the AlignConsecutiveDeclarations: Consecutive specification, then clang-format 14 matches clang-format 13, which may be a clue as to the source of the regression.

JohnC32 avatar Aug 15 '22 12:08 JohnC32

@llvm/issue-subscribers-clang-format

llvmbot avatar Aug 15 '22 14:08 llvmbot