[PATCH] D130510: Missing tautological compare warnings due to unary operators
Bevin Hansson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 27 00:12:57 PDT 2022
ebevhan added a comment.
Hi! A bit of late feedback on this patch. We found a failure in our downstream testing likely originating from here.
The failing case is:
void f(int a)
{
(0 != (a | !0LL));
}
built with `clang -cc1 -emit-llvm-bc -O2 -v -o foo.bc -x c foo.c`
================
Comment at: clang/lib/Analysis/CFG.cpp:1044
+ case UO_LNot:
+ return llvm::APInt(Value.getBitWidth(), !Value);
+ default:
----------------
This isn't returning an APInt of the right width. It will construct an APInt with a width of the input value, but that isn't the same as the required width of what a logical not produces; that should have a width of 'int'.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130510/new/
https://reviews.llvm.org/D130510
More information about the cfe-commits
mailing list