flow: introduce function data
commit7dad765f52263ee73432d4423c56cba62ac6a55e
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 22 Sep 2020 13:10:13 +0000 (22 16:10 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Tue, 22 Sep 2020 13:10:13 +0000 (22 16:10 +0300)
tree3f865bc06aa95e266b8b372194fc0d427a75fecf
parentbf8f00d4295b3f9506c97545ed664a67aa4389d1
flow: introduce function data

I don't really like the naming for this but whatever...

The situation is that it's quite common to have a flag for a function and
you want to set it to true if something happens.  For example, does this
function call copy_to_user() or not?  Maybe these flags are a kind of hack
or cheating or whatever but it's pretty common to want to do that.

The problem is parsing inline functions.  The flag is set and you call an
inline function then it ends up being set improperly.  Or an inline
function sets the flag and it affects the original caller improperly.  So
when you're parsing an inline function then you have to store the value.
You need to have a stack to store the value to handle nested inlines.
Then set the flag to zero. hen after parsing the inline you have to restore
the value.

Instead of doing that, you can just declare the flag as an unsigned long
and pass it to "add_function_data(&flag);".  It automatically gets set to
zero at the start of a function and the original value after parsing an
inline.

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