[PATCH] D102696: [Analyzer] Find constraints that are directly attached to a BinOp

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 21 02:50:33 PDT 2021


martong added a comment.

In D102696#2768857 <https://reviews.llvm.org/D102696#2768857>, @vsavchenko wrote:

> My take on this: for whatever approach, we definitely will be able to construct a more nested/complex example so that it doesn't work.
> For this patch, I'm wondering about something like this:
>
>   int foo() {
>     if (z != 0)
>       return 0;
>     if (x + y + z != 0)
>       return 0;
>     clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}} OK.
>     if (y != 0)
>       return 0;
>     clang_analyzer_eval(y == 0);         // expected-warning{{TRUE}} OK.
>     clang_analyzer_eval(z == 0);         // expected-warning{{TRUE}} OK.
>     clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}} ?
>   }

I've added a test case for this, and it passes with the patch.

Also, I added another test case for checking that "y + x" should be zero if "x + y" is constrained. This fails. To support that we should be synthesizing all combination of the commutative expressions, which would not scale of course. (Perhaps we could do this only for the upper level expression and this way, the most common case could be supported)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102696



More information about the cfe-commits mailing list