[analyzer] ConversionChecker: handle floating point
authorKristof Umann <dkszelethus@gmail.com>
Fri, 16 Nov 2018 01:00:55 +0000 (01:00 +0000)
committerKristof Umann <dkszelethus@gmail.com>
Fri, 16 Nov 2018 01:00:55 +0000 (01:00 +0000)
commit9d6c4402c667e85eda381b1c0bff11005acaf459
treedcbfeb7e8ad366cccca0fd522167321a31fd7e1e
parentad9d68c2b44dce12e13bf038f27ba5182b655345
[analyzer] ConversionChecker: handle floating point

Extend the alpha.core.Conversion checker to handle implicit converions
where a too large integer value is converted to a floating point type. Each
floating point type has a range where it can exactly represent all integers; we
emit a warning when the integer value is above this range. Although it is
possible to exactly represent some integers which are outside of this range
(those that are divisible by a large enough power of 2); we still report cast
involving those, because their usage may lead to bugs. (For example, if 1<<24
is stored in a float variable x, then x==x+1 holds.)

Patch by: DonĂ¡t Nagy!

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

llvm-svn: 347006
clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
clang/test/Analysis/conversion.c