This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix bug 34747, streaming operators and hicpp-signed-bitwise
ClosedPublic

Authored by JonasToth on Sep 29 2017, 4:47 AM.

Details

Summary

The bug happened with stream operations, that were not recognized in all cases.
Even there were already existing test for streaming classes, they did not catch this bug.
Adding the isolated example to the existing tests did not trigger the bug.
Therefore i created a new isolated file that did expose the bug indeed.

Event Timeline

JonasToth created this revision.Sep 29 2017, 4:47 AM
aaron.ballman added inline comments.Sep 29 2017, 6:38 AM
test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
21–27

Instead of re-testing the same behavior as another test, you can use a different trick to make lit happy: add | count 0 to the end of the RUN line. We also put in a comment like:

// Note: this test expects no diagnostics, but FileCheck cannot handle that,
// hence the use of | count 0.
test/clang-tidy/hicpp-signed-bitwise.cpp
1 ↗(On Diff #117122)

Why is the target no longer needed for this test?

JonasToth added inline comments.Sep 29 2017, 8:31 AM
test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
21–27

Ok. I will do this.

test/clang-tidy/hicpp-signed-bitwise.cpp
1 ↗(On Diff #117122)

That line was introduced by chapuni to silence the buildbot.

The original error came from ARM having char being unsigned. I changed all occurence of char to unsigned char or signed char in my fix patch, making specifying the target unnecessary.

JonasToth marked 2 inline comments as done.Sep 29 2017, 8:35 AM
JonasToth updated this revision to Diff 117152.Sep 29 2017, 8:36 AM
  • silence lit the good way
aaron.ballman accepted this revision.Oct 2 2017, 8:06 AM

LGTM, with a comment about the unrelated test change.

test/clang-tidy/hicpp-signed-bitwise.cpp
1 ↗(On Diff #117122)

Thanks for the explanation. It sounds like that's unrelated to the current functionality fix, so it should be a separate commit. No review needed for that one.

This revision is now accepted and ready to land.Oct 2 2017, 8:06 AM
JonasToth updated this revision to Diff 117539.Oct 3 2017, 9:15 AM
  • add the target declaration for test case back
JonasToth marked 3 inline comments as done.Oct 3 2017, 9:16 AM
JonasToth closed this revision.Oct 3 2017, 9:24 AM
malcolm.parsons added inline comments.
test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
15

Typo: occured -> occurred.

JonasToth marked an inline comment as done.Oct 16 2017, 12:47 AM
JonasToth added inline comments.
test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
15

Fixed in the next bugfix for standard enums, that are allowed to be signed.

JonasToth marked 2 inline comments as done.Oct 16 2017, 12:47 AM