[all-commits] [llvm/llvm-project] 32bcd4: [clang-tidy] use correct template type in ``std::m...
Congcong Cai via All-commits
all-commits at lists.llvm.org
Sat Jan 11 02:49:00 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 32bcd41adcc664f6d690efc9b7cd209ac9c65f68
https://github.com/llvm/llvm-project/commit/32bcd41adcc664f6d690efc9b7cd209ac9c65f68
Author: Congcong Cai <congcongcai0907 at 163.com>
Date: 2025-01-11 (Sat, 11 Jan 2025)
Changed paths:
M clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/test/clang-tidy/checkers/readability/use-std-min-max.cpp
Log Message:
-----------
[clang-tidy] use correct template type in ``std::min`` and ``std::max`` when operand is integer literal for readability-use-std-min-max (#122296)
When comparing with integer literal, integer promote will happen to
promote type which has less bit width than int to int or unsigned int.
It will let auto-fix provide correct but out of expected fix.
e.g.
```c++
short a;
if ( a > 10 )
a = 10;
```
will be
```c++
short a;
if ( (int)a > 10 )
a = (short)10;
```
which will be fixed as
```c++
short a;
a = std::max<int>(a, 10);
```
but actually it can be
```c++
short a;
a = std::max<short>(a, 10);
```
Fixed: #121676
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list