Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-tidy] Fix cppcoreguidelines-narrowing-conversions false positive
Fix https://llvm.org/PR49498. The check notices 2 sides of a conditional operator have types with a different constness and so tries to examine the implicit cast. As one side is infinity, the float narrowing detection sees when its casted to a double(which it already was) it thinks the result is out of range. I've fixed this by just disregarding expressions where the builtin type(without quals) match as no conversion would take place. However this has opened a can of worms. Currenty `float a = std::numeric_limits<double>::infinity();` is marked as narrowing. Whats more suspicious is `double a = std::numeric_limits<float>::infinity();` is also marked as narrowing. It could be argued `double inf -> float inf` is narrowing, but `float inf -> double inf` definitely isnt. Reviewed By: carlosgalvezp Differential Revision: https://reviews.llvm.org/D98416
- Loading branch information