diff options
author | Jordan Rose <jordan_rose@apple.com> | 2014-07-10 16:10:52 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2014-07-10 16:10:52 +0000 |
commit | dc352bb82b31251188b40201c30708976fe2c127 (patch) | |
tree | c049a5948a33be60ce644ffd0400a15fcb3a5157 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 511fea7acdc360bc77978370cfbe0218738ea24c (diff) | |
download | llvm-dc352bb82b31251188b40201c30708976fe2c127.zip llvm-dc352bb82b31251188b40201c30708976fe2c127.tar.gz llvm-dc352bb82b31251188b40201c30708976fe2c127.tar.bz2 |
[analyzer] Check for code testing a variable for 0 after using it as a denominator.
This new checker, alpha.core.TestAfterDivZero, catches issues like this:
int sum = ...
int avg = sum / count; // potential division by zero...
if (count == 0) { ... } // ...caught here
Because the analyzer does not necessarily explore /all/ paths through a program,
this check is restricted to only work on zero checks that immediately follow a
division operation (/ % /= %=). This could later be expanded to handle checks
dominated by a division operation but not necessarily in the same CFG block.
Patch by Anders Rönnholm! (with very minor modifications by me)
llvm-svn: 212731
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
0 files changed, 0 insertions, 0 deletions