<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 - ClangFormat - Brace initializer syntax is formatted inconsistently and confusingly when dealing with #ifdef"
   href="https://bugs.llvm.org/show_bug.cgi?id=37230">37230</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ClangFormat - Brace initializer syntax is formatted inconsistently and confusingly when dealing with #ifdef
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>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>andi@mozilla.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>Given the following input:

<span class="quote">>>template<class T>
>>class NonNull
>>{
>>public:
>>  NonNull()
>>    : ptr{ nullptr }
>>  #ifdef DEBUG
>>, inited(false)
>> #endif
>>  {
>>  }
>>};</span >

Using the Mozilla style the output is:

<span class="quote">>>template<class T>
>>class NonNull
>>{
>>public:
>>  NonNull()
>>    : ptr
>>  {
>>    nullptr
>>  }
>>#ifdef DEBUG
>>  , inited(false)
>>#endif
>>  {}
>>};</span >

We can see two issues here:
1. The initialisation of ptr is strange, it's being split on several lines.
Most likely this is because Mozilla cs also uses 'BreakConstructorInitializers'
with FormatStyle::BCIS_BeforeComma
2. inited is not indented properly


Using the Google style the output is:

<span class="quote">>>template <class T>
>>class NonNull {
>> public:
>>  NonNull() : ptr { nullptr }
>>#ifdef DEBUG
>>  , inited(false)
>>#endif
>>  {
>>  }
>>};</span >

This time the format looks almost accurate except variable inited is not
properly aligned. 

Using the LLVM style the output is identical with the Google style.</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>