mtag_data: improve looking up the mtag_data for "foo->bar"
commitc65c08e56b08203804e87d38a464e7a9c8904739
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 18 Mar 2019 11:59:29 +0000 (18 14:59 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 18 Mar 2019 14:05:36 +0000 (18 17:05 +0300)
tree0bba1031bc4f71e81515a23ddf87d89f22cbeb3f
parentb33d7be65a33d0d18d0c0aa979889bdf8d370308
mtag_data: improve looking up the mtag_data for "foo->bar"

I've had the mtag code for a bit, but it's always kind of suffered because
mtags are pointer and pointers are hard.  (And I am stupid).

Anyway, up to now I've been looking at global structs so I want to find
the value of "globar_struct.foo" but now I want to find the value of
"foo->bar" where "foo" points to known memory (or in other words, "foo" is
an mtag).

The other complication is that I guess I wrote some code to talk about
svals and other functions deal with mtag and offset.  So I have the
get_mtag_addr_sval() function, and I have the expr_to_mtag_offset()
function.  They almost do the same thing, except that the sval function
ORs the mtag and the offset together.  And also they have different bugs.

So when you're looking up data in the DB, it makes more sense to talk about
mtags and offsets as a separate thing.  I'm going to change all the code
to do it this way.

The expr_to_mtag_offset() wasn't working correctly for several reasons.
The first bug I noticed is that I forgot to call
"expr = strip_expr(expr->unop);" on the deref expression.

The final change is that I don't like to call get_mtag().  It does a bunch
of recursive stuff...  I'm not sure it's correct.  Anyway, it's not correct
for looking up the data in smatch_extra.c so...

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