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

Muhammad Usman Shahid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 3 21:34:46 PDT 2022


Codesbyusman added a comment.

In D130510#3698415 <https://reviews.llvm.org/D130510#3698415>, @rtrieu wrote:

> Can you add my earlier test case or something like it to SemaCXX/warn-bitwise-compare.cpp ?
>
>   template <int I, class T>
>   void foo(int x) {
>       bool b1 = (x & sizeof(T)) == 8;
>       bool b2 = (x & I) == 8;
>       bool b3 = (x & 4) == 8;  // only warn here
>   }
>   
>   void run(int x) {
>       foo<4, int>(8);
>   }

Yes sure, will update you



================
Comment at: clang/lib/Analysis/CFG.cpp:58
 #include <cassert>
+#include <iostream>
 #include <memory>
----------------
rtrieu wrote:
> For debugging?
> 
> Have you tried `llvm::errs() << "message";` ?  A few streams are provided by LLVM support which most places have already, so no extra header is needed to make it work.
> For debugging?
> 
Yes. I just forget to remove them. Will updaye them.

> Have you tried llvm::errs() << "message"; ? A few streams are provided by LLVM support which most places have already, so no extra header is needed to make it work.
> 
> okay, Great. Will use in future. Thank you.




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