[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 10:46:04 PST 2023


nickdesaulniers added inline comments.


================
Comment at: clang/test/SemaCXX/expressions.cpp:146-148
   #define Y2 2
   bool r2 = X || Y2; // expected-warning {{use of logical '||' with constant operand}} \
                      // expected-note {{use '|' for a bitwise operation}}
----------------
nickdesaulniers wrote:
> So I think we'll want to change this test.
> 
> See commit d6eb2b9f4d4fc236376e3a5a7b8faa31e8dd427d that introduced it.
> 
> If we have a constant that was defined via macro, we DONT want to warn for it.
Another related issue is that sometimes we set these constants via `-D` flags. I wonder if that's a clang bug that those aren't considered as having a valid macro id?

See also https://github.com/ClangBuiltLinux/linux/issues/1806


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609



More information about the cfe-commits mailing list