introduce in_macro() which returns true if we're in a macro
The check_null_deref.c script generates a lot of false positives because
it assumes that if we check a variable for NULL, it potentially is NULL.
That doesn't work because some macros check variables for NULL when the
context doesn't mean they are potentially NULL. The in_macro() lets us
ignore checks inside of macros.
The in_macro() relies on the fact that positions for all the statements in
a macro are the same. It checks the previous statement and the next
statement and if either is in the same position as the current statement
it returns true.
The in_macro() function misses some things. The one that I know about is
if you have a single select statement like this:
#define foo(x) (x ? x->xxx : NULL)
I tried to use the big expression stack, but the problem is that we put
fake expressions on the stack in smatch_conditions.h and there is no easy
way to get the next expression.
Signed-off-by: Dan Carpenter <error27@gmail.com>