[llvm-bugs] [Bug 43531] New: clang-format damages "alternative representations" for operators
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 1 16:05:09 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43531
Bug ID: 43531
Summary: clang-format damages "alternative representations" for
operators
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: sfinae at hotmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
compl 5 means ~5. When clang-format sees this, it's so eager to smash away the
space, that it emits compl5 which damages the code.
C:\Temp>type woof.cpp
#include <ciso646>
#include <cstdio>
int main()
{
unsigned int x = 7;
x &= ~5;
printf("Should be 2: %u\n", x);
unsigned int y = 7;
y and_eq compl 5;
printf("Should be 2: %u\n", y);
}
C:\Temp>cl /EHsc /nologo /W4 woof.cpp && woof
woof.cpp
Should be 2: 2
Should be 2: 2
C:\Temp>clang-cl -m64 /EHsc /nologo /W4 woof.cpp && woof
Should be 2: 2
Should be 2: 2
C:\Temp>clang-format -i woof.cpp
C:\Temp>type woof.cpp
#include <ciso646>
#include <cstdio>
int main() {
unsigned int x = 7;
x &= ~5;
printf("Should be 2: %u\n", x);
unsigned int y = 7;
y and_eq compl5;
printf("Should be 2: %u\n", y);
}
C:\Temp>cl /EHsc /nologo /W4 woof.cpp && woof
woof.cpp
woof.cpp(10): error C2065: 'compl5': undeclared identifier
C:\Temp>clang-cl -m64 /EHsc /nologo /W4 woof.cpp && woof
woof.cpp(10,12): error: use of undeclared identifier 'compl5'
y and_eq compl5;
^
1 error generated.
C:\Temp>clang-format -version
clang-format version 8.0.1 (tags/RELEASE_801/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/20191001/07840c9d/attachment-0001.html>
More information about the llvm-bugs
mailing list