This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Put tautological comparison of unsigned and zero into it's own flag
ClosedPublic

Authored by lebedev.ri on Sep 8 2017, 5:25 AM.

Details

Summary

As requested by Sam McCall.

$ /build/llvm-build-Clang-release/./bin/clang -c /build/clang/test/Sema/outof-range-constant-compare.c /build/clang/test/Sema/outof-range-constant-compare.c:40:11: warning: comparison of unsigned expression < 0 is always false [-Wtautological-unsigned-zero-compare]
    if (a < 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
        ~ ^ ~~~~~~~~~~~~~~~~~~~~

Diff Detail

Repository
rL LLVM

Event Timeline

lebedev.ri created this revision.Sep 8 2017, 5:25 AM

Does this need test?

Yes, it does -- I'd add one with two RUN lines, one with the flag and one without it to make sure you only get the diagnostics in one case.

sammccall edited edge metadata.Sep 8 2017, 6:09 AM

Thanks!
Unless I'm missing something, the current patch just adds the category, but doesn't actually recategorize the warning, right?

Thanks!
Unless I'm missing something, the current patch just adds the category, but doesn't actually recategorize the warning, right?

The diagnostics in DiagnosticSemaKinds.td are changed to be in the new group.

sammccall accepted this revision.Sep 8 2017, 6:21 AM

Right, of course.

Thanks and LG, but clearly also get a review from someone more familiar with the code (I'm just a buildcop)

This revision is now accepted and ready to land.Sep 8 2017, 6:21 AM
aaron.ballman requested changes to this revision.Sep 8 2017, 6:22 AM

The bulk of the patch LGTM as well, but it should still have a test case.

This revision now requires changes to proceed.Sep 8 2017, 6:22 AM
lebedev.ri updated this revision to Diff 114351.Sep 8 2017, 6:43 AM
lebedev.ri edited edge metadata.
lebedev.ri edited the summary of this revision. (Show Details)

Added test.

aaron.ballman accepted this revision.Sep 8 2017, 6:47 AM

Please run the test through clang-format, but otherwise LGTM!

This revision is now accepted and ready to land.Sep 8 2017, 6:47 AM
This revision was automatically updated to reflect the committed changes.