martong added a comment.

Here is a smaller reproducer:

  void bar(short k) {
    ++k;             // k1 = k0 + 1
    assert(k == 1);  // k1 == 1 --> k0 == 0
    (long)k << 16;   // k0 + 1 <<  16
  }

And the explanation is the following. With this patch, when the analyzer 
evaluates the `(long)k << 16` expression then it can properly deduce the value 
of `k` being `1`. However, it was not possible in the baseline. Since we do not 
model neither promotion nor explicit casts we get the false positive report. 
This issue highlights the importance of the patch stack to implement the 
modeling of casts (starting with https://reviews.llvm.org/D99797).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113753/new/

https://reviews.llvm.org/D113753

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to