return_to_param: Use the DB return strings like "[$->foo]" for indirection
commitc8a60888ee16f9e32d24a1ad201b419b804401fd
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 26 Apr 2017 10:30:48 +0000 (26 13:30 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 26 Apr 2017 10:30:48 +0000 (26 13:30 +0300)
treeb153562e49672c69e1933566a0aed712ce7b234f
parentba89c175b92dd7c89db96e3e0db5fa1de500adb9
return_to_param: Use the DB return strings like "[$->foo]" for indirection

In C there can be many ways to refer to the same memory.  Often we want to
have a shorter way to do it like:

struct foo *p = one->two->three->foo;

p->xxx = 42;

Smatch generally handles this by assuming the shortest name is the one that
people will use and updating the long name in the background.  If people
use the long name instead then Smatch gets messed up.  Don't do that.

This patch augments that feature so that if we do:

struct foo *p = get_driver_data(drv);

Then then we store the short to long mapping there as well.

The one place where we sometimes go the reverse way is across function
boundaries.  In that case, it's normal to just always pass "drv" (in this
example) and each function calls the get_driver_data(drv) themselves.  So
for that situation we need the long to short mapping.

One limitation is that this patch only works for assignments so if we do
"return get_driver_data(drv);" then the mapping is lost.  It's complicated
to add this, so I'm going to postpone that work.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Makefile
check_list.h
smatch.h
smatch_extra.c
smatch_function_hooks.c
smatch_return_to_param.c [new file with mode: 0644]
validation/sm_indirection2.c [new file with mode: 0644]