[PATCH] D13126: New static analyzer checker for loss of sign/precision
Daniel Marjamäki via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 18 07:18:06 PST 2015
danielmarjamaki updated this revision to Diff 40505.
danielmarjamaki added a comment.
I have problems with the "default" handling of expressions.
I want to warn about loss of precision for such code:
unsigned int x = 256;
unsigned char c;
c = x;
The analyser tells me that the RHS value is 0 instead of 256 in the assignment "c = x". Here is the dump of the ProgramState:
Store (direct and default bindings), 0x0 :
Expressions:
(0x7b9bd30,0x7b458d8) c : &c
(0x7b9bd30,0x7b45940) x : 0 U8b
Ranges are empty.
This patch is a quick proof-of-concept where I track variable values myself using ProgramState. It gives me better results when I scan projects.
I wonder if you think I should continue working on this proof-of-concept method. Or if you have some tip how I can see the untruncated rhs value in a assignment.
http://reviews.llvm.org/D13126
Files:
lib/StaticAnalyzer/Checkers/CMakeLists.txt
lib/StaticAnalyzer/Checkers/Checkers.td
lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
test/Analysis/conversion.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13126.40505.patch
Type: text/x-patch
Size: 7951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151118/d3bbce48/attachment.bin>
More information about the cfe-commits
mailing list