<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - FR: An option to continue binpack after a multiline string literal break"
   href="https://bugs.llvm.org/show_bug.cgi?id=50860">50860</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>FR: An option to continue binpack after a multiline string literal break
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Formatter
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kkm@pobox.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Currently, clang-format is unconditionally breaking the argument list after
splitting a C/C++ string into multiple lines. The justification for this
behavior is given near the very end of
ContinuationIndenter::breakProtrudingToken() in
clang/lib/Format/ContinuationIndenter.cpp (see
<a href="https://github.com/llvm/llvm-project/blob/d480f968a/clang/lib/Format/ContinuationIndenter.cpp#L2341-L2354">https://github.com/llvm/llvm-project/blob/d480f968a/clang/lib/Format/ContinuationIndenter.cpp#L2341-L2354</a>):

    // If we break the token inside a parameter list, we need to break before
    // the next parameter on all levels, so that the next parameter is clearly
    // visible. Line comments already introduce a break.

While it's generally a good idea, at times it leads to quite an ugly line
breaks, like this example

    fmt::print("The answer to life, the universe, and everything is "
               "{}",
               n);

While, of course, this particular example may be best formatted without
splitting the string at all and breaking the line after the opening '('
instead, this is just an example. Sometimes long log messages require breaking
into more than 2 lines (we use Google style and the hard limit of 80
characters), and are followed by just one short argument. Another soft
objection to this design decision is that nearly any modern text editor in fact
used for writing code (nano and notepad thus excluded) highlights language
syntax, so that the next argument is "clearly visible" even without a line
break: most default color schemes highlight string constants so that they stand
out well enough.

There are just too many cases in our codebase that carry over just one short
parameter to the next line, and the current unconditional behavior is not
really of much help to code readability. It may be argued that this particular
case is rather detrimental to it: both '"{},"' and 'n);' are "clearly visible",
in the above justification's sense, but the apparent intent is to make "clearly
visible" only the latter.

I propose a single Boolean option, for example,
'BreakBinPackAfterMultilineString', with the current behavior set by 'true';
'false' would not force this line break.

I can write implementation for the option; I'm opening this issue primarily to
discuss the proposal.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>