Warn on operations "b << x" and "b >> x"
Github issue #28334
Differential D141414
[clang] add warning on shifting boolean type angelomatnigoogle on Jan 10 2023, 11:06 AM. Authored by
Diff Detail
Event TimelineComment Actions Hey @aaron.ballman I made some suggestions in the bug report: https://github.com/llvm/llvm-project/issues/28334 do you think this is a reasonable approach? Comment Actions Thank you for working on this! It seems that precommit CI found valid failures that should be addressed: Clang :: AST/Interp/shifts.cpp Clang :: Analysis/svalbuilder-simplify-no-crash.c Clang :: CXX/over/over.built/p18.cpp Clang :: Misc/warning-flags.c Please be sure to also add a release note to clang/docs/ReleaseNotes.rst for the new warning flag. Also, can you try running this new diagnostic against some larger C and C++ code bases to see if it discovers any false or true positives?
Comment Actions Consolidated shift-bool warning; fixed relevant unit tests Thank you for the feedback, and pardon me for not getting back to this work sooner. I have adopted your code change suggestions with minor tweeks to get it working and passing the previously failing tests. Later this week I will double back and attempt to use FixItHint on this as well as to update ReleaseNotes and run clang against some larger code bases Comment Actions Thank you for pinging this! I took a quick pass over the changes and they're moving in the right direction, but there are some new test failures that need addressing and some unfinished comments from the previous review.
Comment Actions Pardon me for losing sight on this change. Within the week, I will revisit this change based on the current outstanding comments. |
Reworded and combined into one diagnostic. I also changed the diagnostic group because "dependent" has specific meaning to C++ folks.