[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 9 07:22:11 PDT 2021


ASDenysPetrov added a comment.

In D103096#2866730 <https://reviews.llvm.org/D103096#2866730>, @vsavchenko wrote:

> In D103096#2866704 <https://reviews.llvm.org/D103096#2866704>, @ASDenysPetrov wrote:
>
>> @vsavchenko
>
> That's not the question I'm asking.  Why do you need to set constraints for other symbolic expressions, when `SymbolicInferrer` can look them up on its own?  Which cases will fail if we remove that part altogether?

I see. Here is what fails in case if we don't update other constraints:

  void test(int x) {
    if ((char)x > -10 && (char)x < 10) {
      if ((short)x == 8) {
        // If you remove updateExistingConstraints,
        // then `c` won't be 8. It would be [-10, 10] instead.
        char c = x;
        if (c != 8)
          clang_analyzer_warnIfReached(); // should no-warning, but fail
      }
    }
  }


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

https://reviews.llvm.org/D103096



More information about the cfe-commits mailing list