HomePhabricator

[clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.

Authored by ztamas on May 2 2020, 5:04 AM.

Description

[clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.

Summary:
To cover STR34-C rule's second use case, where `signed char` is
used for array subscript after an integer conversion. In the case
of non-ASCII character this conversion will result in a value
in excess of UCHAR_MAX.

There is another clang-tidy check which catches these cases.
cppcoreguidelines-pro-bounds-constant-array-index catches any
indexing which is not integer constant. I think this check is
very strict about the index (e.g. constant), so it's still useful
to cover the `signed char` use case in this check, so we
can provide a way to catch the SEI cert rule's use cases on a
codebase, where this CPP guideline is not used.

Reviewers: aaron.ballman, njames93

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D78904