This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy]: Add cert-str34-c alias for bugprone-signed-char-misuse.
ClosedPublic

Authored by ztamas on May 4 2020, 8:49 AM.

Details

Summary

Added DiagnoseSignedUnsignedCharComparisons option to
filter out unrelated use cases. The SEI cert catches explicit
integer casts (two use cases), while in the case of
signed char \ unsigned char comparison, we have implicit
conversions.

Diff Detail

Event Timeline

ztamas created this revision.May 4 2020, 8:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2020, 8:49 AM
ztamas edited the summary of this revision. (Show Details)May 4 2020, 8:49 AM
ztamas edited the summary of this revision. (Show Details)
ztamas edited the summary of this revision. (Show Details)
ztamas added a reviewer: aaron.ballman.
aaron.ballman added inline comments.May 4 2020, 12:32 PM
clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
33

Same request for the user-facing option name as above.

clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
41

I'd prefer a more descriptive name than this -- most people reading the code won't be familiar with that coding standard. How about DiagnoseSignedUnsignedCharComparisons or something along those lines?

clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
117–119

The documentation should describe the actual differences rather than defer directly to other documentation. It's fine to make the description light on content and say "see <link> for more information" if the differences are hard to spell out concisely.

ztamas updated this revision to Diff 262046.May 5 2020, 2:42 AM

CertSTR34C -> DiagnoseSignedUnsignedCharComparisons

ztamas marked 3 inline comments as done.May 5 2020, 2:44 AM
ztamas added inline comments.
clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
41

OK, I updated the code to use this option name.

ztamas edited the summary of this revision. (Show Details)May 5 2020, 2:45 AM
ztamas edited the summary of this revision. (Show Details)
aaron.ballman accepted this revision.May 5 2020, 12:44 PM

LGTM aside from some small nits with the documentation.

clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
117

non-zero -> nonzero
comparison -> comparisons,
(with the plural and comma)

118

this use case is -> these comparisons are

clang-tools-extra/docs/clang-tidy/checks/cert-str34-c.rst
7

The underlining here looks too long.

This revision is now accepted and ready to land.May 5 2020, 12:44 PM
ztamas updated this revision to Diff 262316.May 6 2020, 1:43 AM
ztamas marked an inline comment as done.

Documentation fixes

ztamas marked 3 inline comments as done.May 6 2020, 1:43 AM
This revision was automatically updated to reflect the committed changes.