<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 - trailing comma in inializer list confuses formatter"
   href="https://bugs.llvm.org/show_bug.cgi?id=36460">36460</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>trailing comma in inializer list confuses formatter
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>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>andy.somerville@gmail.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>Created <span class=""><a href="attachment.cgi?id=19917" name="attach_19917" title="minimal example of trailing comma issue">attachment 19917</a> <a href="attachment.cgi?id=19917&action=edit" title="minimal example of trailing comma issue">[details]</a></span>
minimal example of trailing comma issue

including trailing comma in initializer list causes formatter to switch
indentation style and splits short parameters one per line.


////////////////// BEGIN minimal example input //////////////////
#include <set>


void someFunction( std::set<int> & someSet )
{
    // initializer lists inside a constructor

    std::set<std::set<int >> firstSet{
        { 1, 2, 3, 5,}, // final comma internal initializer
        { 6, 7, 8,9}
    };

    std::set<std::set<int >> otherSet = {
        { 1, 2, 3, 5}, // no final comma internal initializer
        { 6, 7, 8,9}
    };

    auto middleSet = std::set<std::set<int >>{ 
        { 1, 2, 3, 5, }, // final comma external initializer
        { 6, 7, 8,9}, 
    };

    auto finalSet = std::set<std::set<int >>({ 
        { 1, 2, 3, 5 }, // final comma external initializer
        { 6, 7, 8,9}, 
    });
}
////////////////// END minimal example input //////////////////


$ clang-format-5.0 -style=llvm ./minimal_initializer_test.cpp 

////////////////// BEGIN minimal example output //////////////////
#include <set>

void someFunction(std::set<int> &someSet) {
  // initializer lists inside a constructor

  std::set<std::set<int>> firstSet{{
                                       1,
                                       2,
                                       3,
                                       5,
                                   }, // final comma internal initializer
                                   {6, 7, 8, 9}};

  std::set<std::set<int>> otherSet = {
      {1, 2, 3, 5}, // no final comma internal initializer
      {6, 7, 8, 9}};

  auto middleSet = std::set<std::set<int>>{
      {
          1,
          2,
          3,
          5,
      }, // final comma external initializer
      {6, 7, 8, 9},
  };

  auto finalSet = std::set<std::set<int>>({
      {1, 2, 3, 5}, // final comma external initializer
      {6, 7, 8, 9},
  });
}
////////////////// END minimal example output //////////////////</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>