rtrieu added a comment.

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);
  }



================
Comment at: clang/lib/Analysis/CFG.cpp:58
 #include <cassert>
+#include <iostream>
 #include <memory>
----------------
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.


================
Comment at: clang/lib/Analysis/CFG.cpp:1023
+  // as -12.
+  llvm::APInt getIntegerLiteralSubexpressionValue(const Expr *E) {
+    // UnaryOperator identification.
----------------
Is this any better than just having the callers use EvaluateAsInt themselves?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130510/new/

https://reviews.llvm.org/D130510

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to