[all-commits] [llvm/llvm-project] 015c39: [Analyzer] Infer 0 value when the divisible is 0 (...

Gabor Marton via All-commits all-commits at lists.llvm.org
Thu Mar 25 10:25:47 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 015c39882ebc1771713a7523ae76903ebae83288
      https://github.com/llvm/llvm-project/commit/015c39882ebc1771713a7523ae76903ebae83288
  Author: Gabor Marton <gabor.marton at ericsson.com>
  Date:   2021-03-25 (Thu, 25 Mar 2021)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
    A clang/test/Analysis/zero-operands.c

  Log Message:
  -----------
  [Analyzer] Infer 0 value when the divisible is 0 (bug fix)

Currently, we infer 0 if the divisible of the modulo op is 0:
  int a = x < 0; // a can be 0
  int b = a % y; // b is either 1 % sym or 0
However, we don't when the op is / :
  int a = x < 0; // a can be 0
  int b = a / y; // b is either 1 / sym or 0 / sym

This commit fixes the discrepancy.

Differential Revision: https://reviews.llvm.org/D99343




More information about the All-commits mailing list