[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-09-29 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment. In D130510#3821641 , @aaron.ballman wrote: > In D130510#3817148 , @ebevhan wrote: > >> Hi! A bit of late feedback on this patch. We found a failure in our >> downstream testing likely or

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-09-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D130510#3817148 , @ebevhan wrote: > Hi! A bit of late feedback on this patch. We found a failure in our > downstream testing likely originating from here. Thank you for the feedback! I've addressed the issue in 96a79cb

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-09-27 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment. Hi! A bit of late feedback on this patch. We found a failure in our downstream testing likely originating from here. The failing case is: void f(int a) { (0 != (a | !0LL)); } built with `clang -cc1 -emit-llvm-bc -O2 -v -o foo.bc -x c foo.c` =

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-19 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rGfd874e5fb119: Missing tautological compare warnings due to unary operators (authored by Codesbyusman, committed by aaron.ballman). Changed prior to commit: https://reviews.llvm.org/D130510?vs=453976&id=

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-19 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 453976. Codesbyusman added a comment. updated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/docs/ReleaseNotes.rst clang/lib/Analysis/CFG.cpp

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D130510#3729864 , @rtrieu wrote: > In D130510#3728719 , @aaron.ballman > wrote: > >> In D130510#3727096 , @rtrieu wrote: >> >>> This pat

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-17 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment. In D130510#3728719 , @aaron.ballman wrote: > In D130510#3727096 , @rtrieu wrote: > >> This patch has been moving back and forth between >> `IsIntegerLiteralConstantExpr` and `getIntegerLi

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-17 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 453388. Codesbyusman added a comment. updated test cases. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/docs/ReleaseNotes.rst clang/lib/Analys

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-17 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman added a comment. working on the test. Will update the patch soon. 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-

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D130510#3727096 , @rtrieu wrote: > This patch has been moving back and forth between > `IsIntegerLiteralConstantExpr` and `getIntegerLiteralSubexpressionValue`. > The first function is preexisting and the second one is

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-16 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment. This patch has been moving back and forth between `IsIntegerLiteralConstantExpr` and `getIntegerLiteralSubexpressionValue`. The first function is preexisting and the second one is a new function. The final patch seems to settle on using just `getIntegerLiteralSubexpres

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. This looks correct to me! Any further concerns @erichkeane or @rtrieu? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ h

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-16 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 453064. Codesbyusman marked 3 inline comments as not done. Codesbyusman added a comment. updated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Nice! Just a few more small nits to fix that I can see. Comment at: clang/lib/Analysis/CFG.cpp:1016-1021 + Optional getIntegerLiteralSubexpressionValue(const Expr *E) { + +const auto *UnOp = dyn_cast(E->IgnoreParens()); + +// If unary. +

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-16 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 453058. Codesbyusman marked 10 inline comments as done. Codesbyusman added a comment. updated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/doc

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. This is looking much closer to what I think we had in mind, so I mostly have some cleanup suggestions. Comment at: clang/lib/Analysis/CFG.cpp:979 -const BinaryOperator *BitOp = dyn_cast(BoolExpr); +const BinaryOperator *BitOp = dyn_cas

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-16 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 452988. Codesbyusman added a comment. updated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/docs/ReleaseNotes.rst clang/lib/Analysis/CFG.cpp

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-16 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 452987. Codesbyusman added a comment. updated also the test cases. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/docs/ReleaseNotes.rst clang/l

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-15 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 452799. Codesbyusman added a comment. updates Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/docs/ReleaseNotes.rst clang/lib/Analysis/CFG.cpp

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-15 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 452797. Codesbyusman added a comment. updating for the missing tautological compare warnings. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/docs

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-04 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment. void foo(long x) { if ((x & 1) == 1L) return; // bad always false warning here static_assert(sizeof(int) < sizeof(long), "long is bigger than int"); static_assert((long(15) & 1) == 1L, "proof that condition can be true"); } I found this false positive case

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-03 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman added a comment. In D130510#3698415 , @rtrieu wrote: > Can you add my earlier test case or something like it to > SemaCXX/warn-bitwise-compare.cpp ? > > template > void foo(int x) { > bool b1 = (x & sizeof(T)) == 8; > bool b

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-03 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment. Can you add my earlier test case or something like it to SemaCXX/warn-bitwise-compare.cpp ? template 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) {

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-03 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 449778. Codesbyusman added a comment. Adopted another approach working for the error caught. Kindly review this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-02 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment. In D130510#3693494 , @aaron.ballman wrote: > In D130510#3692654 , @rtrieu wrote: > >> Because of this, warnings should treat dependent expressions as non-constant >> even when they can be

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision. aaron.ballman added a comment. This revision now requires changes to proceed. I've reverted in c783ca0de1e1e00f364cf4745b8444a020ddd29b . Marking as requesting changes to make i

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D130510#3692654 , @rtrieu wrote: > This warning is now flagging some code which I believe is a false positive. > In particular, when template arguments are involved, their values can be > calculated during template ins

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-08-01 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu reopened this revision. rtrieu added a comment. This revision is now accepted and ready to land. This warning is now flagging some code which I believe is a false positive. In particular, when template arguments are involved, their values can be calculated during template instantiation,

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-28 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman added a comment. In D130510#3684740 , @aaron.ballman wrote: > LGTM! I'll make some editorial corrections for grammar to the release note > when I land. Thank you. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https:/

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG0cc3c184c784: Missing tautological compare warnings due to unary operators (authored by Codesbyusman, committed by aaron.ballman). Changed prior to

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! I'll make some editorial corrections for grammar to the release note when I land. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.o

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-27 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 448141. Codesbyusman added a comment. updated with the small fixes and addition of release note Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/do

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D130510#3683078 , @Codesbyusman wrote: > In D130510#3682902 , @aaron.ballman > wrote: > >> Thank you for this, I think this is good incremental progress and is almost >> ready

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-27 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman added a comment. In D130510#3682902 , @aaron.ballman wrote: > Thank you for this, I think this is good incremental progress and is almost > ready to go. Just a few small nits, but also, can you also add a release note > for the fix (be sur

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Thank you for this, I think this is good incremental progress and is almost ready to go. Just a few small nits, but also, can you also add a release note for the fix (be sure to mention which issue is being closed too). Note, the precommit CI failures are unrelate

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-27 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 448060. Codesbyusman added a comment. updating the code suggestions and test cases. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/lib/Analysis/C

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-26 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman marked an inline comment as done. Codesbyusman added inline comments. Comment at: clang/lib/Analysis/CFG.cpp:970-980 +if (LHSExpr->EvaluateAsInt(IntExprResult, *Context)) { + // Evaluating value. + BoolExpr = RHSExpr; +} +else if (RHSExpr->Eval

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Thanks for working on this! I have some suggestions, but you'll also need to add a release note at some point. Comment at: clang/lib/Analysis/CFG.cpp:970-980 +if (LHSExpr->EvaluateAsInt(IntExprResult, *Context)) { + // Evaluating value.

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-25 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 447453. Codesbyusman added a comment. also updating for the Xor bitwise operator Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510 Files: clang/lib/Analysis/CFG.

[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-25 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 447440. Codesbyusman edited the summary of this revision. Codesbyusman added a comment. updating to more efficient Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130510/new/ https://reviews.llvm.org/D130510