[PATCH] Warn on suspicious use of absolute value function
rtrieu at google.com
Mon Jan 6 14:29:49 PST 2014
> Is this meant to be just for ‘abs’, or will it be generalized for all the calls in <math.h>?
I haven't analyzed the use of the other functions in math.h to see how prevalent the problem with other functions are, but this warning could be generalized to other functions.
> What about in C++ code, where there can be many functions named “abs” that take different arguments? What will this patch do in that case?
> [ Ok, they’re named std::abs, but people hoist them into the global namespace _all the time_ ]
It is also a common mistake to forget "std::", calling abs instead of std::abs when both are present, so a surprising bit of C++ code uses the wrong absolute value function. I plan on extending this to provide some checking on std::abs.
More information about the cfe-commits