<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 - clang-format assignment with bitwise operators: Keep line breaks if necessary"
   href="https://bugs.llvm.org/show_bug.cgi?id=49125">49125</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format assignment with bitwise operators: Keep line breaks if necessary
          </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>andi.schulz@me.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>There is currently no way of keeping a multi line assignment with bitwise
operators the way it is. It would be nice if clang-format could allow an option
to recognize unnecessary "merging" when there is an bitwise operator.

.clang-format file:
BasedOnStyle: LLVM
ColumnLimit: 80



Example input:



// This needs no formatting and will be kept this way
int i1 = 10000 | 10001 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008;

// This exceeds the ColumnLimit: 80 and will get formatted
int k1 = 10000 | 10001 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008
| 10009;

// This is manually formatted, but clang-format will force it into two lines
int m1 = 10000 |
         10001 |
         10002 |
         10003 |
         10004 |
         10005 |
         10006 |
         10007 |
         10008 |
         10009;

// This needs no formatting and will be kept this way
int i2 = get_int() | get_int() | get_int() | get_int() | get_int() | get_int();

// This exceeds the ColumnLimit: 80 and will get formatted
int k2 = get_int() | get_int() | get_int() | get_int() | get_int() | get_int()
| get_int();

// This is manually formatted, but clang-format will force it into two lines
int m2 = get_int() |
         get_int() |
         get_int() |
         get_int() |
         get_int() |
         get_int() |
         get_int();



Example output:



// This needs no formatting and will be kept this way
int i1 = 10000 | 10001 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008;

// This exceeds the ColumnLimit: 80 and will get formatted
int k1 = 10000 | 10001 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008
|
         10009;

// This is manually formatted, but clang-format will force it into two lines
int m1 = 10000 | 10001 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008
|
         10009;

// This needs no formatting and will be kept this way
int i2 = get_int() | get_int() | get_int() | get_int() | get_int() | get_int();

// This exceeds the ColumnLimit: 80 and will get formatted
int k2 = get_int() | get_int() | get_int() | get_int() | get_int() | get_int()
|
         get_int();

// This is manually formatted, but clang-format will force it into two lines
int m2 = get_int() | get_int() | get_int() | get_int() | get_int() | get_int()
|
         get_int();</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>