implied: fix bug handling unmatched implications
commit00231cbe6b59a5efb1a4241aa9021a91549b5eac
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 28 Jul 2015 12:08:38 +0000 (28 15:08 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Tue, 28 Jul 2015 12:08:38 +0000 (28 15:08 +0300)
treeca9deaf5e982890bb723c9e9724177f480a3f89e
parent362cda5138e441600a87bafdfe224a6e322d42f4
implied: fix bug handling unmatched implications

The situation here is you have a condition:

if (foo && bar) { ...

Imagine that if foo is true it implies X, but when it is false there are no
implications.  The __set_true_false_sm() function sets the cur_stree.  It
wouldn't be a problem except that the "bar" condition has no implications
but it means we preserve X on both the true and false paths.  This leads to
a situation where a condition is implied on the false path and it's
possibly true, but it's only definitely true on the true path.

The way to get around this is to preserve the original state on the false
path.

I had hoped to preserve the whole sm_state so that it would still have the
original implications preserved as well, but when I tried that it caused
some false positives.  I'm not positive what went wrong.  I need to
rethink the implication code sometime.

The fact that I no longer preserve the implications means that there are
now a few new false positive which we avoided before because when we could
calculate the implications.  But this is a bugfix because being ambiguous
is better than being wrong so I'm going to go with it.

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