[PATCH] D130510: Missing tautological compare warnings due to unary operators

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 28 11:24:24 PDT 2022


aaron.ballman added a comment.

In D130510#3817148 <https://reviews.llvm.org/D130510#3817148>, @ebevhan wrote:

> Hi! A bit of late feedback on this patch. We found a failure in our downstream testing likely originating from here.

Thank you for the feedback! I've addressed the issue in 96a79cb308d1b8c00a83b180d9fecc5d54bacb9c <https://reviews.llvm.org/rG96a79cb308d1b8c00a83b180d9fecc5d54bacb9c>.



================
Comment at: clang/lib/Analysis/CFG.cpp:1044
+        case UO_LNot:
+          return llvm::APInt(Value.getBitWidth(), !Value);
+        default:
----------------
ebevhan wrote:
> 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'.
Good catch, that is correct -- logical not always returns an `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