[cfe-dev] [StaticAnalyser][RFC] New checker, -Wsign-compare without the noise
Daniel Marjamäki via cfe-dev
cfe-dev at lists.llvm.org
Tue Sep 1 06:07:08 PDT 2015
Hello!
I want to implement a new -Wsign-compare checker in the static analyser that is not noisy.
I like the idea of Wsign-compare. However the checker generates lots of noise:
int x = 10;
unsigned y = x; // <- FP
The -Wsign-compare doesn't care that the code is 100% safe and warns anyway.
I only want to see a warning when there can be a real loss of precision or a real loss of sign (when the value can be negative).
I don't plan to remove the -Wsign-compare from Clang. People will have to use -Wno-sign-compare to get rid of the noise.
I attach a simple proof of concept checker. It will just warn if there is an assignment and RHS is a known negative value. Do you have opinions about the design? Should some alternative approach be used?
Best regards,
Daniel Marjamäki
..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
Mobile: +46 (0)709 12 42 62
E-mail: Daniel.Marjamaki at evidente.se
www.evidente.se
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 150901-sign.patch
Type: text/x-patch
Size: 3982 bytes
Desc: 150901-sign.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150901/6aa98189/attachment.bin>
More information about the cfe-dev
mailing list