<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 - Wrong alignment in #elif/#else branch for #define blocks"
   href="https://bugs.llvm.org/show_bug.cgi?id=47995">47995</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong alignment in #elif/#else branch for #define blocks
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>11.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>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>simon.nuebler@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>Hello,

I have encountered a bug in clang-format-11.0.0 (valid at least for v10 too)

Default configuration with

    "AlignConsecutiveMacros = true"
    "IndentPPDirectives = BeforeHash"


When there are #define blocks in an #elif/#else branch and there is a comment
in between #define blocks, all #defines, their values and comments are aligned
based on the last block, which is incorrect. If the comments in between the
blocks are removed or the blocks are in an #if branch, this error does not
occur.

Example how it looks:

#if defined(SOMETHING)

#elif defined(SOMETHING_ELSE)

    // A comment.
    #define a     1      // A comment.
    #define b     2      // A comment.
    #define c     3      // A comment.

    // A comment.
    #define aa    1111   // A comment.
    #define bb    2222   // A comment.
    #define cc    3333   // A comment.

    // A comment.
    #define aaaaa 111111 // A comment.
    #define bbbbb 222222 // A comment.
    #define ccbbc 333333 // A comment.

#endif



This is how it should look:

#if defined(SOMETHING)

#elif defined(SOMETHING_ELSE)

    // A comment.
    #define a 1 // A comment.
    #define b 2 // A comment.
    #define c 3 // A comment.

    // A comment.
    #define aa 1111 // A comment.
    #define bb 2222 // A comment.
    #define cc 3333 // A comment.

    // A comment.
    #define aaaaa 111111 // A comment.
    #define bbbbb 222222 // A comment.
    #define ccbbc 333333 // A comment.

#endif

Best regards</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>