<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 changes semantics of code on '#define keyword(x)'"
   href="https://llvm.org/bugs/show_bug.cgi?id=31738">31738</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format changes semantics of code on '#define keyword(x)'
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.8
          </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>abigail.buccaneer@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For certain keywords, '#define keyword(x)' will erroneously insert an extra
space, causing the function-like macro to instead become an object-like macro.
This can change the semantics of the compiled code, which should never happen.

    $ echo '#define if(x)' | clang-format
    #define if (x)

The full list of affected C++ keywords seems to be:

and, and_eq, bitor, case, catch, delete, for, if, new, not_eq, or, or_eq,
return, switch, try, while, xor, xor_eq. Additionally, the MSVC-specific
__except is affected, and __try is not (but I haven't exhaustively tested all
of MSVC's keywords.)

Note that this is not the same as the list of keywords which should be followed
by a space when used normally according to the current style, or the list of
keywords which are recognised by the preprocessor, or the list of keywords
which it's grammatically valid for them to be followed by an open-parenthesis.
In particular, note that bitor is affected, but bitand is not.

    $ clang-format -version
    clang-format version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)</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>