[clang] [Clang] add -Wshift-bool warning to handle shifting of bool (PR #127336)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 19 13:08:34 PST 2025
================
@@ -11246,6 +11246,12 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS,
if (S.getLangOpts().OpenCL)
return;
+ if (LHS.get()->IgnoreParenImpCasts()->getType()->isBooleanType()) {
+ S.Diag(Loc, diag::warn_shift_bool)
+ << (Opc == BO_Shr) /*left|right*/ << LHS.get()->getSourceRange();
----------------
a-tarasyuk wrote:
@AaronBallman Yes, there are some cases related to left shift, however, I haven't found any for the right shift. Should we handle only the left shift?
https://github.com/llvm/llvm-project/pull/127336
More information about the cfe-commits
mailing list