<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Braced-init-list misformatted with AlignAfterOpenBracket=AlwaysBreak"
   href="https://llvm.org/bugs/show_bug.cgi?id=31115">31115</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Braced-init-list misformatted with AlignAfterOpenBracket=AlwaysBreak
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>griwes@griwes.info
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17633" name="attach_17633" title="an example">attachment 17633</a> <a href="attachment.cgi?id=17633&action=edit" title="an example">[details]</a></span>
an example

It seems that AlwaysBreak is disregarded for braced-init-lists, and instead
Align is used when either Align or AlwaysBreak are specified for
AlignAfterOpenBracket.

An example is attached. The config I'm using to run clang-format (reduced to
the necessary options) is:

    -style='{BasedOnStyle: WebKit, AlignAfterOpenBracket: AlwaysBreak,
ColumnLimit: 80, BinPackArguments: false, Cpp11BracedListStyle: true}'

(Cpp11BracedListStyle doesn't matter; the only thing it changes is that with
it, the BinPackArguments option is respected. It'd be nice if it was possible
to respect it *without* removing the spaces from within the braces, but that's
not important here.)

The second line in main() in the example yields the expected result:

    std::vector<int> foo(
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname,
        verylongname);

(This is obviously invalid code, but it illustrates the point.) The first line,
however, completely disregards AlignAfterOpenBracket=AlwaysBreak:

    std::vector<int> foo{verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname,
                         verylongname};

while the expected result is the same as for the second line, only with braces
instead of parentheses.

It wouldn't be *very* bad if not for some of my test files that construct
literals corresponding to an AST parsed by the tested code, which causes it to
be completely unreadable with Align. I *could* (and I guess I'll have to, for
now) run two configs, one for the tests that disables this and one for normal
code where this bug doesn't hurt readability that much (but does hurt it
nevertheless), but it's not very nice.</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>