Skip to content
Snippets Groups Projects
  • Jordan Rose's avatar
    00a1ef80
    [analyzer] Check for code testing a variable for 0 after using it as a denominator. · 00a1ef80
    Jordan Rose authored
    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)
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212731 91177308-0d34-0410-b5e6-96231b3b80d8
    00a1ef80
    History
    [analyzer] Check for code testing a variable for 0 after using it as a denominator.
    Jordan Rose authored
    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)
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212731 91177308-0d34-0410-b5e6-96231b3b80d8
Code owners
Assign users and groups as approvers for specific file changes. Learn more.