]> granicus.if.org Git - clang/commit
[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)
commit75aa1c144f4fbd5497aa95b51074e0ba45fa05f3
tree94bddd3ba2e2168fd2e313334802456a0ca65416
parentcf529cbb221682520d1a11a17546a42084ed0ca5
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347006 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
test/Analysis/conversion.c