[cfe-commits] [PATCH] Improve -Wtautological-constant-out-of-range-compare

Eli Friedman eli.friedman at gmail.com
Wed Nov 14 12:16:28 PST 2012


+  // Common unsigned, other signed, constant unsigned
+  (void)((int)other != (unsigned long)(0xffffffffffffffff)); //
expected-warning{{different signs}}
+  (void)((int)other != (unsigned long)(0x00000000ffffffff)); //
expected-warning{{true}}

I'd like to see a testcase for (int)other < (unsigned long)(0x00000000ffffffff).

+      // The constant value rests between values that OtherT can
represent after
+      // conversion.  Relational comparison still works, but equality
+      // comparisons will be tautological.
+      if (OtherWidth <= Value.getActiveBits())
+        EqualityOnly = true;

The condition of this branch is always true.


I think I've run out of comments now. :)  (I know it must be annoying
to take this many rounds to review this, but thanks for sticking with
it.)

-Eli

On Wed, Nov 14, 2012 at 11:57 AM, Richard Trieu <rtrieu at google.com> wrote:
>   Add missing test case as pointed out by Eli.
>
> http://llvm-reviews.chandlerc.com/D113
>
> CHANGE SINCE LAST DIFF
>   http://llvm-reviews.chandlerc.com/D113?vs=320&id=327#toc
>
> Files:
>   test/Analysis/additive-folding.cpp
>   test/SemaCXX/compare.cpp
>   lib/Sema/SemaChecking.cpp



More information about the cfe-commits mailing list