[cfe-dev] New division by zero check
Anders Rönnholm
Anders.Ronnholm at evidente.se
Wed Jan 22 07:18:54 PST 2014
Hi,
There is a division by zero check where the denominator value is already known. I would like some feedback on a new static check for division by zero I intend to write where the value isn't known yet.
It shall catch scenarios where the division is made before checking it against a value. To start with it will have to be directly after the division.
e.g
x = 100 / y;
if (y == 0)
I plan to do it by:
1. When a division is reached where the denominator is a variable with unknown value, "mark" the denominator variable.
2. When reaching a condition that checks if a variable is 0, check if the variable in the condition is "marked".
3. Report bug
I guess RecursiveASTVisitor is best for this?
Is there perhaps a better way to do this that would allow me to follow the variable from division to check so that it doesn't have to be directly after?
//Anders
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140122/f3eeda62/attachment.html>
More information about the cfe-dev
mailing list