[llvm-bugs] [Bug 46706] New: Inconsistency of BreakConstructorInitializers with respect to ColumnLimit

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 13 07:22:15 PDT 2020


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

            Bug ID: 46706
           Summary: Inconsistency of BreakConstructorInitializers with
                    respect to ColumnLimit
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: saket.rungta at tallysolutions.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Documentation for BreakConstructorInitializers at
https://clang.llvm.org/docs/ClangFormatStyleOptions.htm DOES NOT imply that the
behaviour is subject to ColumnLimit.

BreakConstructorInitializers was introduced in: https://reviews.llvm.org/D32479

A related request and differential is: https://reviews.llvm.org/D14484

What we currently have is inconsistent behaviour, which I propose to patch and
also offer to maintain, along the lines of earlier work either as suggested in
(a) https://reviews.llvm.org/D14484 or (b)
https://github.com/llvm-mirror/clang/pull/67 or (c) any other way.

Consider the following default LLVM style configuration at 'master' currently:

AllowAllConstructorInitializersOnNextLine: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
ColumnLimit:     80
ConstructorInitializerAllOnOneLineOrOnePerLine: false

And sample test file (same as official documentation referred above):
D:\>clang-format.exe test.cpp
Constructor() : initializer1(), initializer2()

Output with: BreakConstructorInitializers: BeforeColon
Constructor() : initializer1(), initializer2()
That is, no change.

Output with: BreakConstructorInitializers: AfterColon
Constructor() : initializer1(), initializer2()
That is, no change.

Output with: BreakConstructorInitializers: BeforeComma
Constructor()
    : initializer1()
    , initializer2()

That currently only the BeforeComma option works without consideration to
ColumnLimit.

This bug report is to make the three choices consistent with each other with
consideration to ColumnLimit, preferably with a choice to enforce line break
irrespective of ColumnLimit as others have requested earlier.

-- 
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/20200713/706e115a/attachment.html>


More information about the llvm-bugs mailing list