Commit Graph

7 Commits

Author SHA1 Message Date
Nick Desaulniers 87be98223c [SEMA] add more -Wfloat-conversion to compound assigment analysis
Summary: Fixes Bug: https://bugs.llvm.org/show_bug.cgi?id=27061

Reviewers: aaron.ballman, acoomans

Reviewed By: aaron.ballman, acoomans

Subscribers: acoomans, cfe-commits, srhines, pirama

Differential Revision: https://reviews.llvm.org/D50467

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339581 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 16:38:07 +00:00
Richard Trieu 1680f6cae0 Enable control flow pruning of float overflow warnings.
Like other conversion warnings, allow float overflow warnings to be disabled
in known dead paths of template instantiation.  This often occurs when a
template template type is a numeric type and the template will check the
range of the numeric type before performing the conversion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332310 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-14 23:21:48 +00:00
Erich Keane 65d5e3d8ad Fix float->int conversion warnings when near barriers.
As Eli brought up here: https://reviews.llvm.org/D46535
I'd previously messed up this fix by missing conversions
that are just slightly outside the range.  This patch fixes
this by no longer ignoring the return value of 
convertToInteger.  Additionally, one of the error messages
wasn't very sensical (mentioning out of range value, when it 
really was not), so it was cleaned up as well.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331812 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-08 21:26:21 +00:00
Erich Keane 8052cdc639 Correct warning on Float->Integer conversions.
As identified and briefly discussed here:
https://bugs.llvm.org/show_bug.cgi?id=37305

Converting a floating point number to an integer type when
the integral part is out of the range of the integer type is
undefined behavior in C. Additionally, CodeGen emits an undef
in this situation.

HOWEVER, we've been giving a warning that says that the value is
changed. This patch corrects the warning to list that it is actually
undefined behavior.

Differential Revision: https://reviews.llvm.org/D46535


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331673 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-07 20:52:56 +00:00
Richard Trieu beccaa284d Revert the bool portion of r267054
Remove the floating point to bool conversion warnings.  Some of these
conversions will be caught by -Wliteral-conversion and -Wfloat-conversion


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267234 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 22:14:32 +00:00
Richard Trieu 3c188bce6b Split interesting warnings off from -Wfloat-conversion
Restructure the implict floating point to integer conversions so that
interesting sub-groups are under different flags.  Breakdown of warnings:

No warning:
Exact conversions from floating point to integer:
int x = 10.0;
int x = 1e10;

-Wliteral-conversion - Floating point literal to integer with rounding:
int x = 5.5;
int x = -3.4;

-Wfloat-conversion - All conversions not covered by the above two:
int x = GetFloat();
int x = 5.5 + 3.5;

-Wfloat-zero-conversion - The expression converted has a non-zero floating
point value that gets converted to a zero integer value, excluded the cases
falling under -Wliteral-conversion.  Subset of -Wfloat-conversion.
int x = 1.0 / 2.0;

-Wfloat-overflow-conversion - The floating point value is outside the range
of the integer type, exluding cases from -Wliteral conversion.  Subset of
-Wfloat-conversion.
char x = 500;
char x = -1000;

-Wfloat-bool-conversion - Any conversion of a floating point type to bool.
Subset of -Wfloat-conversion.
if (GetFloat()) {}
bool x = 5.0;

-Wfloat-bool-constant-conversion - Conversion of a compile time evaluatable
floating point value to bool.  Subset of -Wfloat-bool-conversion.
bool x = 1.0;
bool x = 4.0 / 20.0;

Also add EvaluateAsFloat to Sema, which is similar to EvaluateAsInt, but for
floating point values.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267054 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 21:04:55 +00:00
Richard Trieu 88d3e52db3 Change -Wfloating-point-conversion to -Wfloat-conversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207037 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 21:53:59 +00:00