[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant
Shivam Gupta via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 6 21:59:12 PST 2023
xgupta marked 5 inline comments as done.
xgupta added inline comments.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:13635
+ if (ECDHS && ECDHS->getInitVal() != 0 && ECDHS->getInitVal() != 1)
+ EnumConstantInBoolContext = true;
+ }
----------------
nickdesaulniers wrote:
> Hmm...I wonder if we now care about which `ExprResult` contained an enum constant in bool context?
IIUC you mean EnumConstantInBoolContext is not required, but then test cases start failing if I will not use it in diagnoseLogicalInsteadOfBitwise above.
Like this -
$ build/bin/llvm-lit -v clang/test/Sema
Command Output (stderr):
--
error: 'warning' diagnostics seen but not expected:
File /home/xgupta/compiler/llvm-project/clang/test/Sema/warn-int-in-bool-context.c Line 52: use of logical '||' with constant operand
File /home/xgupta/compiler/llvm-project/clang/test/Sema/warn-int-in-bool-context.c Line 56: use of logical '||' with constant operand
File /home/xgupta/compiler/llvm-project/clang/test/Sema/warn-int-in-bool-context.c Line 68: use of logical '&&' with constant operand
error: 'note' diagnostics seen but not expected:
File /home/xgupta/compiler/llvm-project/clang/test/Sema/warn-int-in-bool-context.c Line 52: use '|' for a bitwise operation
File /home/xgupta/compiler/llvm-project/clang/test/Sema/warn-int-in-bool-context.c Line 56: use '|' for a bitwise operation
File /home/xgupta/compiler/llvm-project/clang/test/Sema/warn-int-in-bool-context.c Line 68: use '&' for a bitwise operation
File /home/xgupta/compiler/llvm-project/clang/test/Sema/warn-int-in-bool-context.c Line 68: remove constant to silence this warning
7 errors generated.
--
Failed Tests (1):
Clang :: Sema/warn-int-in-bool-context.c
Testing Time: 0.04s
Failed: 1
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