Issue 180215
Summary [clang-format] Unexpected line continuation indent formatting
Labels clang-format
Assignees
Reporter JWTheDBA
    I'm not sure if this is expected behavior, or a bug, so asking...

I have clang-format configured to emulate BSD KNF style.  As it relates to indentation that means line continuation is a 4 character indent and block indentation is 8 character indent.  I've tried various UseTab settings and get the same result whether spaces or tabs are used.  

Assume for a moment that the entire 'if' statement doesn't fit within clang-formats ColumnLimit value and must to be split.

void function(void)
{
        if (check(parameter1, parameter2, parameter3, parameter4)) {
                // First statement
                // Second statement
        }
}

I expected clang-format to produce this.  Parameters of check() indented 4 characters from the previous indent level (the indent level of the if statement)

void function(void)
{
        if (check(
 parameter1,
            parameter2,
            parameter3,
 parameter4)) {
                // First statement
                // Second statement
        }
}

What I actually got was the following.  Parameter of check() indented 8 characters from the previous indent level.  What I assume is happening is there is an indent level for the if statement, which is unused because the if statement isn't the statement being continued, then a second indent is applied to the check() statement which is what's pushing the parameters out 8 characters instead of 4. 

void function(void)
{
 if (check(
                parameter1,
                parameter2,
 parameter3,
                parameter4)) {
                // First statement
                // Second statement
        }
}

Which of the outputs is correct?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to