Commit Graph

3 Commits

Author SHA1 Message Date
Alp Toker aed9b33870 Consolidate header inclusion diagnostics
Make argument orders match, unify diagnostic IDs and reword the message to be a
little less saccharine.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212845 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-11 20:53:51 +00:00
Richard Trieu ab66ae5002 Make -Wabsolute-value C++-aware.
Warn on std::abs() with unsigned argument.
Suggest std::abs as replacement for the C absolute value functions.
Suggest C++ headers if the specific std::abs overload is not found.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206340 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-15 23:47:53 +00:00
Richard Trieu 4a7f7947a3 Add -Wabsolute-value, warnings about absolute value functions.
The warnings fall into three groups.
1) Using an absolute value function of the wrong type, for instance, using the
int absolute value function when the argument is a floating point type.
2) Using the improper sized absolute value function, for instance, using abs
when the argument is a long long.  llabs should be used instead.

From these two cases, an implicit conversion will occur which may cause
unexpected behavior.  Where possible, suggest the proper absolute value
function to use, and which header to include if the function is not available.

3) Taking the absolute value of an unsigned value.  In addition to this warning,
suggest to remove the function call.  This usually indicates a logic error
since the programmer assumed negative values would have been possible.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202211 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-26 01:17:28 +00:00