[PATCH] D85256: Add -Wtautological-value-range-compare warning.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 13:55:36 PDT 2020


rsmith added a comment.

In D85256#2211129 <https://reviews.llvm.org/D85256#2211129>, @rsmith wrote:

> This appears to be a general problem: the `GetExprRange` mechanism in SemaChecking miscomputes the ranges for `+`, `*`, and `-` expressions, and we'll get them wrong for all warnings that use that mechanism :-(

See https://reviews.llvm.org/D85778 for a fix. We were intentionally miscomputing the expression ranges in order to give conservative narrowing-conversion results for cases like `char a = some_char + 1;` (which is technically lossy because the RHS could be `CHAR_MAX + 1`, but is probably fine), and this caused us to similarly compute that `(a & 1) + (b & 1)` was in the range [0, 1], not [0, 2].


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85256



More information about the cfe-commits mailing list