Issue 120867
Summary [clang-tidy] Ignore `modernize-use-integer-sign-comparison` between signed wide type and unsigned narrow type
Labels clang-tidy
Assignees
Reporter zufuliu
    For following code (online at https://godbolt.org/z/evGzzTdb7), I'd like the checker emits no warnings for `foo1` and `foo2` (the narrow `y` implicitly promoted to `int`), also `bar1` missed the warning even with `-fsigned-char`.
```c++
bool foo1(int x, unsigned char y) {
    return x == y;
}
bool foo2(int x, unsigned short y) {
    return x == y;
}
bool bar1(unsigned int x, char y) {
    return x == y;
}
bool bar2(unsigned int x, short y) {
    return x == y;
}
```

current output:
```console
[<source>:2:12: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]](_javascript_:;)
 1 | bool foo1(int x, unsigned char y) {
    2 |     return x == y;
 |            ^ ~~  
      |            std::cmp_equal( , )
[<source>:5:12: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]](_javascript_:;)
    5 |     return x == y;
      |            ^ ~~  
      |            std::cmp_equal( , )
[<source>:11:12: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]](_javascript_:;)
   11 | return x == y;
      |            ^ ~~  
      |            std::cmp_equal( , )
3 warnings generated.
```

CC @qt-tatiana as author of the checker (PR #113144).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to