[llvm-bugs] [Bug 45512] New: BraceWrapping: AfterControlStatement: MultiLine Not work when ColumnLimit = 0

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 13 11:43:43 PDT 2020


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: unassignedclangbugs at nondot.org
          Reporter: ujifman at yandex.ru
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200413/a78480bc/attachment.html>


More information about the llvm-bugs mailing list