<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 fails with multi-line comments"
   href="https://bugs.llvm.org/show_bug.cgi?id=35262">35262</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang-Format fails with multi-line comments
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>5.0
          </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>alex@grundis.de
          </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=19392" name="attach_19392" title="File to test">attachment 19392</a> <a href="attachment.cgi?id=19392&action=edit" title="File to test">[details]</a></span>
File to test

Clang-format fails when using multi-line comments in a define where it should
align the escaped newlines.

There are 2 possible failures: 

- It fails to format the code in question completely (mostly untouched)
- It adds another escaped newline. And again on next format, and again, and
again...

Testcase that triggers both:

        #define FOO \
         /* \
         * Multi-line-comment: \
         */

#define BAR \
/*\
* Multi-line-comment\
*/


Save as clangFormat.cpp (see attachment) and run `clang-format.exe
-style="{AlignEscapedNewlines: Left}" clangFormat.cpp`

Result:

#define FOO                \
  /* \                     \
   * Multi-line-comment: \ \
   */

#define BAR \
/*\
* Multi-line-comment\
*/


On a related note: It will also add an extra newline before an opening brace in
a define and again fail to align the escaped newlines:

#define BAR \
{\
}

->

#define BAR \
  \
{\
}</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>