[cfe-dev] [analyzer] Condition optimization improvements for RangeConstraintManager

Denis Petrov via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 22 13:55:53 PDT 2020

Hi, CSA ?community.

I got an idea how to make RangeConstraintManager? more sofisticated.

I want you speak out, share your vision about this idea.

Actually this bug https://bugs.llvm.org/show_bug.cgi?id=13426 pushed me to these thoughts.

Let's consider the next snippet:

int foo(int y, int x) {
int x;
if (y == z) {
x = 0;
if (y != z) {
x = 1;
return x;

Finally CSA reports you:
warning: Undefined or garbage value returned to caller
        return x;

But as a human you know that `x` has definitely been initialized.
As you can see CSA builds paths without relying on previous conditions (except the case {A-B} {B-A}m it is already done).
The same behavior appears when:
(y >  z) (y <= z)
(y <= z) (y >  z)?
(y == z) (z != y)?
I made a solution for this but have not upload it for review yet.

I also have some more thoughts about optimization such:
if (y <  z) {}
if (y <= z) {} // which is a subset of (y < z)

I can continue to do this improvement and show you the result soon.

Denys Petrov
Senior ะก++ Developer | Kharkiv, Ukraine

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200422/aa19d74e/attachment.html>

More information about the cfe-dev mailing list