https://bugs.llvm.org/show_bug.cgi?id=45512

            Bug ID: 45512
           Summary: BraceWrapping: AfterControlStatement: MultiLine Not
                    work when ColumnLimit = 0
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangb...@nondot.org
          Reporter: ujif...@yandex.ru
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@lists.llvm.org

Created attachment 23344
  --> https://bugs.llvm.org/attachment.cgi?id=23344&action=edit
full .clang-format config

Summary shows the main problem. 
When ColumnLimit = 0

.clang-format part:
```
BraceWrapping:
  AfterCaseLabel:  true
  AfterClass:      true
  AfterControlStatement: MultiLine
BreakBeforeBinaryOperators: None
ColumnLimit:     0
```

BreakBeforeBinaryOperators is none beacuse clang-format remove all line breaks
in `if ()` statement in other case. I want to save line breaks that are made by
human.
So with such config one get this:

```
// Input
if (someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpression &&
        someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpressionAgain &&
        someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpressionAndOneMoreTime) {
    someCodeHere();
    anotherCall();
    int someAssignment = 0;
}


// Result, that makes readability very poor
if (someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpression &&
    someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpressionAgain &&
    someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpressionAndOneMoreTime) {
    someCodeHere();
    anotherCall();
    int someAssignment = 0;
}


// Expected result
if (someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpression &&
    someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpressionAgain &&
    someVeryVeryVeryVeryVeryVeryVeryVeryVeryLongExpressionAndOneMoreTime) 
{
    someCodeHere();
    anotherCall();
    int someAssignment = 0;
}
```

It looks like multiline is detected only when ColumnLimit is on and if content
exceeds this limit.
Mechanism doesn't see places that are already multilines.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to