helper: re-order symbol additions in expr_to_chunk()
commit2e9c209effe7c6b7aaf1c96f84a1792f301bdf19
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 25 Sep 2017 12:45:34 +0000 (25 15:45 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 25 Sep 2017 12:45:34 +0000 (25 15:45 +0300)
treeccafae8d2c6d09251df64f1c45a0b148d7520d47
parente261512ab236d38faebbff93b23c5089f7eacedd
helper: re-order symbol additions in expr_to_chunk()

The problem is say you have code like:

if (foo + bar > 5) {

we know the value of "foo + bar" but say we want to know the value of
"bar + foo"?  Smatch doesn't know those two are the same.  Most code uses
the same ordering consistently but what often causes the problem is code
like this:

if (foo > 5)
return -EINVAL;
if (bar > 5 - foo)
bar =  5 - foo;

For code like that, Smatch picks the order of "foo + bar" or "bar + foo"
so it might not be consistent with how the programmer uses it.

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