[all-commits] [llvm/llvm-project] 030ff9: [clang-tidy] extend bugprone-signed-char-misuse ch...

Tamás Zolnai via All-commits all-commits at lists.llvm.org
Sat May 2 05:09:06 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 030ff901f43258d18b68a77b0085d0fae2a0fbc6
      https://github.com/llvm/llvm-project/commit/030ff901f43258d18b68a77b0085d0fae2a0fbc6
  Author: Tamás Zolnai <tamas.zolnai at collabora.com>
  Date:   2020-05-02 (Sat, 02 May 2020)

  Changed paths:
    M clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
    M clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
    M clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list