Issue |
130325
|
Summary |
[clang-tidy] `modernize-use-std-numbers` ignores some C math functions
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
SunBlack
|
`modernize-use-std-numbers` ignores C math functions that are not named the same as their C++ counterparts.
Calling following code with:
```
clang-tidy-20 -checks='modernize-use-std-numbers' "test.cpp" -- -std=c++20
```
`test.cpp`:
```cpp
#include <cmath>
float mySqrt3()
{
return sqrtf(3.0F);
}
```
Doesn't raise a warning. When exchanging the C method `sqrtf` by the C++ method `std::sqrt`:
```cpp
#include <cmath>
float mySqrt3()
{
return std::sqrt(3.0F);
}
```
You will get:
```
test.cpp:5:12: warning: prefer 'std::numbers::sqrt3_v<float>' to this formula [modernize-use-std-numbers]
5 | return std::sqrt(3.0F);
| ^~~~~~~~~~~~~~~
| std::numbers::sqrt3_v<float>
```
You get also the warning when using the double C method of `sqrt`:
```cpp
#include <cmath>
float mySqrt3()
{
return sqrt(3.0);
}
```
```
test.cpp:5:12: warning: prefer 'std::numbers::sqrt3' to this formula [modernize-use-std-numbers]
5 | return sqrt(3.0);
| ^~~~~~~~~
| std::numbers::sqrt3
```
I think also the non-double C math methods should cause a warning.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs