llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.77k stars 11.89k forks source link

save-temps causes new bitwise parenthesis warning #34726

Open llvmbot opened 6 years ago

llvmbot commented 6 years ago
Bugzilla Link 35378
Version trunk
OS All
Attachments test.cc
Reporter LLVM Bugzilla Contributor
CC @dwblaikie,@rnk

Extended Description

Building the above code with -Wall -Wextra -Werror -O2 -g -fno-exceptions -o test.o -c test.cc

emits no warnings

however, with: -Wall -Wextra -Werror -O2 -g -save-temps -fno-exceptions -o test.o -c test.cc

We get: test.cc:16:101: error: '&' within '|' [-Werror,-Wbitwise-op-parentheses] if ((dbg_buffer[i] & ~(0xFFFF)) == (uint32)(((uint32)0xC1 << 24) | (((module_id) & 0xFF) << 16) & ~(0xFFFF))) ~ ~~~~~~~^~~~~ test.cc:16:101: note: place parentheses around the '&' expression to silence this warning if ((dbg_buffer[i] & ~(0xFFFF)) == (uint32)(((uint32)0xC1 << 24) | (((module_id) & 0xFF) << 16) & ~(0xFFFF))) ^ ( )

When looking into this further I noticed that in the case of -save-temps the sourceLocation for the expression is not being considered as a macro.

dwblaikie commented 6 years ago

Sounds like -save-temps should pre-process with -frewrite-includes.

Maybe - but users could have pipelines using save-temps expecting a fully preprocessed file.

Maybe we could produce a foo.included.cpp file or something as well as foo.ii, foo.bc, and foo.s

rnk commented 6 years ago

Sounds like -save-temps should pre-process with -frewrite-includes.