<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 AlignConsecutiveAssignments breaks based on line length and/or identifier length"
   href="https://bugs.llvm.org/show_bug.cgi?id=45388">45388</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang Format AlignConsecutiveAssignments breaks based on line length and/or identifier length
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>9.0
          </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>clappi77@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=23304" name="attach_23304" title="Clang format options used to recreate this issue">attachment 23304</a> <a href="attachment.cgi?id=23304&action=edit" title="Clang format options used to recreate this issue">[details]</a></span>
Clang format options used to recreate this issue

I found I have to run clang-format more than once sometimes for some reason. 
It appears that clang-format will inject a formatting error (probably because
it's confused about column alignment with adjoining lines) which is then
corrected by running a second time.

I was able to recreate the issue on the following snippet.

void Blah() {
    const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIFIER_NAME_HERE = (4 * 1024);
//My comment of a specific size 12345678901
    const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIF              = (4 * 1024);
// My comment of a specific size 12345678901
}

It seems that clang-format will unindent the second constant's assignment,
which then gets resolved if I re-run the formatter a second time. Here's the
output I get after I run clang-format the first time:

void Blah() {
    const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIFIER_NAME_HERE = (4 * 1024);
// My comment of a specific size 12345678901
    const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIF = (4 * 1024); // My comment
of a specific size 12345678901
}

Then if I run it a second time I get the desired output below:

void Blah() {
    const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIFIER_NAME_HERE = (4 * 1024);
// My comment of a specific size 12345678901
    const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIF              = (4 * 1024);
// My comment of a specific size 12345678901
}

Interestingly, this seems specific to the total line length of the first
constant (the line with the formatting error in the comment) and the constant
identifier length for the second constant. If I shorten either the comment of
the first constant or the name of the second constant at all the formatter
works properly the on the first run and no second run is necessary.

As far as I can tell, the line is still well within the column limit of 150
specified in the options, so I'm not sure why this is happening.</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>