[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL312750: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S. (authored by lebedevri). Changed prior to commit: https://reviews.llvm.org/D37565?vs=114260&id=114265#toc Repository: rL

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. LGTM. Comment at: docs/ReleaseNotes.rst:79 +- ``-Wtautological-compare`` now warns about comparison of signed integer and + ``0U`` constant when appropriate. + -

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 114260. lebedev.ri marked 3 inline comments as done. lebedev.ri added a comment. Address review notes. Repository: rL LLVM https://reviews.llvm.org/D37565 Files: docs/ReleaseNotes.rst lib/Sema/SemaChecking.cpp test/Sema/compare.c test/Sema/out

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. Great, thanks. Just a few tweaks. Comment at: docs/ReleaseNotes.rst:76 + ``0`` constant was adjusted to warn regardless of whether the constant is + signed or unsigned. + "now warns when comparing an unsigned integer and 0 regardles

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 114249. lebedev.ri marked 4 inline comments as done. lebedev.ri added a comment. Address review notes. Repository: rL LLVM https://reviews.llvm.org/D37565 Files: docs/ReleaseNotes.rst lib/Sema/SemaChecking.cpp test/Sema/compare.c test/Sema/out

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri planned changes to this revision. lebedev.ri added inline comments. Comment at: test/Sema/outof-range-constant-compare.c:41 +if (a < 0xUL) +return 0; +if (a <= 0xUL) rjmccall wrote: > Hmm. I think this s

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/Sema/SemaChecking.cpp:8589 + Expr *LHS = E->getLHS()->IgnoreParenImpCasts(); + Expr *RHS = E->getRHS()->IgnoreParenImpCasts(); + lebedev.ri wrote: > rjmccall wrote: > > Do you still need these? I'm always antsy a

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments. Comment at: lib/Sema/SemaChecking.cpp:8879 + if (IsComparisonConstant) return AnalyzeImpConvsInComparison(S, E); rjmccall wrote: > lebedev.ri wrote: > > rjmccall wrote: > > > Part of the purpose of checking for signed c

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/Sema/SemaChecking.cpp:8879 + if (IsComparisonConstant) return AnalyzeImpConvsInComparison(S, E); lebedev.ri wrote: > rjmccall wrote: > > Part of the purpose of checking for signed comparisons up here is to

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments. Comment at: lib/Sema/SemaChecking.cpp:8592 + bool BadR = !RType->isIntegerType() || RType->isSignedIntegerType() || + RHS->isKnownToHaveBooleanValue(); + rjmccall wrote: > Please extract a function which computes th

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 114221. lebedev.ri marked an inline comment as done. lebedev.ri added a comment. Address review notes. Repository: rL LLVM https://reviews.llvm.org/D37565 Files: docs/ReleaseNotes.rst lib/Sema/SemaChecking.cpp test/Sema/outof-range-constant-comp

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/Sema/SemaChecking.cpp:8592 + bool BadR = !RType->isIntegerType() || RType->isSignedIntegerType() || + RHS->isKnownToHaveBooleanValue(); + Please extract a function which computes this for an Expr* and

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 114172. lebedev.ri added a comment. Added ReleaseNotes.rst note Repository: rL LLVM https://reviews.llvm.org/D37565 Files: docs/ReleaseNotes.rst lib/Sema/SemaChecking.cpp test/Sema/outof-range-constant-compare.c Index: test/Sema/outof-range-con

[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision. lebedev.ri added a project: clang. This is a first half(?) of a fix for the following bug: https://bugs.llvm.org/show_bug.cgi?id=34147 (gcc -Wtype-limits) GCC's -Wtype-limits does warn on comparison of unsigned value with signed zero (as in, with 0), but clang on