This is originally implemented by Jacques Pienaar.
Details
Diff Detail
Event Timeline
Nice! See a few comments inline.
clang-tidy/misc/IncorrectRoundings.cpp | ||
---|---|---|
39 | We should use a more effective way of checking whether the type is a (long)? double or float. There'a builtinType() matcher that we could extend with a narrowing matcher calling BuiltinType::isFloatingPoint() (that can be added to ASTMatchers.h, I think). | |
51 | Since these two .bind() calls are in alternative branches, they can use the same identifier. This would also simplify the code in the callback. | |
72 | I don't think we should recommend lrint, since its behavior can be changed by fesetround(). lround() and llround() are better alternatives, IMO. We could also suggest an automated fix for this. |
clang-tidy/misc/IncorrectRoundings.cpp | ||
---|---|---|
39 | Done. The ASTMatchers.h file is not in clang-tidy repository, so I temporarily implement isFloatingPoint narrowing matcher here. Will create a separated patch to clang repository. | |
51 | Just found out there is no need to bind here since check function doesn't use it. Have removed it. |
We should use a more effective way of checking whether the type is a (long)? double or float. There'a builtinType() matcher that we could extend with a narrowing matcher calling BuiltinType::isFloatingPoint() (that can be added to ASTMatchers.h, I think).