implied: improve overwrite_states_using_pool()
commit06982189382f9a27e2f79a1ecbe0f3e4065299f5
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 1 Jun 2016 21:32:25 +0000 (2 00:32 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 1 Jun 2016 21:32:25 +0000 (2 00:32 +0300)
tree4bd790385bcd94564b2cb26f2eb6b81b4cd0e0dc
parent61839d87d5f46d62cf324c32fb775aaf8b24d6ed
implied: improve overwrite_states_using_pool()

How this worked originally is we have code like:
if (...) {
a = 0;
} else if (...) {
a = 0;
} else {
a = 1;
}

if (a == 0)
b = 2;

return a;

So then we look at the stree where a was set, and any states which were
set specifically in that path, then we use those and overwrite the fake
cur stree.  The problem is that we miss some implications this way.

The solution is to re-use the existing implication code.

We group all the similar possible leaf sm states together.  We set the
true and false stack.  Then we reuse the implication code.  It's simple
enough.

Grouping the similar states together means that we have fewer separate
returns to handle with seems like a good thing.  I introduced the
ptr_in_list() function to see if we have already handled that return
range.

The other thing here is that I noticed that split_helper() and
call_return_state_hooks_split_possible() are basically the same function
so I merged them together.  I probably should have done that in a separate
patch but I am a loser.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch.h
smatch_db.c
smatch_implied.c