<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: /**/ before macro removes line breaks and runs 200x slower"
   href="https://bugs.llvm.org/show_bug.cgi?id=41483">41483</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format: /**/ before macro removes line breaks and runs 200x slower
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>8.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>bjehlert@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=21770" name="attach_21770" title="Code to repo the issue">attachment 21770</a> <a href="attachment.cgi?id=21770&action=edit" title="Code to repo the issue">[details]</a></span>
Code to repo the issue

Given this code (C++):

  #define FOO(a, b, c) class a { static const char* b() const { return c; } };

  /**/ FOO(a,        aa,            "aaa")
  FOO(aah,        aahed,            "aahing")
  FOO(aahs,        aal,            "aalii")

  FOO(aaliis,        aals,            "aam")
  FOO(aani,        aardvark,            "aardvarks")

The comment block /**/ before the first FOO() causes all subsequent calls to
FOO() to be merged into a single line:

  /**/ FOO(a, aa, "aaa") FOO(aah, aahed, "aahing") FOO(aahs, aal, "aalii")

      FOO(aaliis, aals, "aam") FOO(aani, aardvark, "aardvarks")

When a file contains ~1000 of these calls to FOO(), the results are completely
unreadable as it generates lines which are several thousand columns wide.
Simply removing the /**/ fixes the issue, leaving each FOO() on its own line
but removes all the extra spaces.

Additionally, when run on a file with ~1000 calls to FOO(), clang-format takes
200x longer to run when the file contains a /**/ before the first call to FOO()
(0.20 vs. 40 seconds on i7-5820K).

I've attached a file containing a repro which is the above code with 1000 calls
to FOO() each on their own line. Removing the /**/ before the first call to
FOO() on line 4 to see the behavior changes.

Repro: clang-format -style=llvm foo1000.cpp

The behavior I'd expect is each call to FOO() remain on its own line, with the
first one still containing the comment block and the performance to be
generally equivalent.

Expected:

  /**/ FOO(a, aa, "aaa")
  FOO(aah, aahed, "aahing")
  FOO(aahs, aal, "aalii")

  FOO(aaliis, aals, "aam")
  FOO(aani, aardvark, "aardvarks")

First noticed this issue on 7.0.0, still occurs on 8.0.0.</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>