comparison: improve "foo = min(...);" assignment handling
commit44e5d283dd92499a92e425f588d9807b47ddd24f
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 24 Aug 2018 11:21:07 +0000 (24 14:21 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Fri, 24 Aug 2018 11:21:56 +0000 (24 14:21 +0300)
tree9ed06cebcb49f03db880c4b15d7c331989e32ed5
parentb8c763dbac3ba33439d035ad1f288ac90bf3e678
comparison: improve "foo = min(...);"  assignment handling

When you have an assignment like:  "foo = min(bar, 5);" then that breaks
down into something involving __builtin_choose_expr() so I've added
support for those assignments in smatch_flow.c.  Then after that it
looks like:

foo = bar < 5 ? bar : 5;

So foo == bar or foo == 5.  That means that we need to do a pre_merge where
we use foo == 5 to set foo <= bar.

Then the other trickiness is when we have something like:
"foo = min(foo, bar);".  We're assigning "foo" to itself.  Originally that
would clear all the comparisons.  It should just be ignored.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_comparison.c
smatch_flow.c