[llvm-bugs] [Bug 38636] New: [Formatter/ObjC] Break after return statement worsen readability

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 20 06:21:09 PDT 2018


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

            Bug ID: 38636
           Summary: [Formatter/ObjC] Break after return statement worsen
                    readability
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jolesiak at google.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Current formatting (works fine when there is many elements):
return @{
  aaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
  aaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
};

Current formatting (works suboptimal when there is one element; lack of spaces
is a different bug: https://bugs.llvm.org/show_bug.cgi?id=36919):
return
    @{aaaaaaaaaaaaaaaaaaaa :
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa};

Should be (more readable and consistent with case when there is many elements):
return @{
    aaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
};

The same problem with array literals:
return
    @[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
];

instead of:
return @[
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
];


Maybe it makes sense to increase the penalty for breaking after "return" as I
believe it may touch other constructions as well.

-- 
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/20180820/9272aa45/attachment.html>


More information about the llvm-bugs mailing list