[llvm-bugs] [Bug 31738] New: clang-format changes semantics of code on '#define keyword(x)'
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 24 09:08:03 PST 2017
https://llvm.org/bugs/show_bug.cgi?id=31738
Bug ID: 31738
Summary: clang-format changes semantics of code on '#define
keyword(x)'
Product: clang
Version: 3.8
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: abigail.buccaneer at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Classification: Unclassified
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)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170124/5dcbfd90/attachment.html>
More information about the llvm-bugs
mailing list