[PATCH] D75749: [clang-tidy] extend bugprone-signed-char-misuse check.

Tamás Zolnai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 6 08:13:59 PST 2020


ztamas created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
ztamas added a reviewer: aaron.ballman.
ztamas added a comment.

I run the check on LLVM code and found only one catch of suspicious comparison:

  clang-tidy -p=/home/zolnai/clang/build /home/zolnai/clang/llvm-project/clang/lib/Lex/Lexer.cpp
  /home/zolnai/clang/llvm-project/clang/lib/Lex/Lexer.cpp:1293:39: warning: comparison between signed and unsigned char [bugprone-signed-char-misuse]
        if ((C == '\n' || C == '\r') && C != PrevC)


ztamas added a comment.

In the LibreOffice codebase, I found 8 catches:
https://gist.github.com/tzolnai/2b22492c0cf79f5dba577f6a878657e3

All catches seem valid to me.


Cover a new use case when using a 'signed char' as an integer
might lead to issue with non-ASCII characters. Comparing
a 'signed char' with an 'unsigned char' using equality / unequality
operator produces an unexpected result for non-ASCII characters.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75749

Files:
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75749.248732.patch
Type: text/x-patch
Size: 16676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200306/ba75af0f/attachment-0001.bin>


More information about the cfe-commits mailing list