aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2019-03-18 15:33:59 (GMT)
committerDan Carpenter <dan.carpenter@oracle.com>2019-03-18 15:33:59 (GMT)
commit5cbe4bbfc18ace0b0ad775c5102eecf5306eb712 (patch)
tree10d4c9591e08031363709e27b7306b8b98ebb64f
parent48f2ba95ec21782006c060bccacfe7f5c80d97ed (diff)
mtag_map: use expr_to_mtag_offset()
I wanted to get rid of the get_mtag() function but I ended up re-writing the whole match_assign() function. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
-rw-r--r--smatch_mtag_map.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/smatch_mtag_map.c b/smatch_mtag_map.c
index 8384a99..4ca0e00 100644
--- a/smatch_mtag_map.c
+++ b/smatch_mtag_map.c
@@ -29,8 +29,9 @@ static int my_id;
static void match_assign(struct expression *expr)
{
struct expression *left, *right;
- mtag_t left_tag, right_tag;
+ mtag_t left_tag;
int offset;
+ sval_t sval;
if (expr->op != '=')
return;
@@ -38,19 +39,20 @@ static void match_assign(struct expression *expr)
left = strip_expr(expr->left);
right = strip_expr(expr->right);
- if (left->type != EXPR_DEREF)
+ if (!type_is_ptr(get_type(right)))
return;
-
- offset = get_member_offset_from_deref(left);
- if (offset < 0)
+ if (!get_implied_value(right, &sval))
return;
-
- if (!get_mtag(left->deref, &left_tag))
+ if (sval_cmp(sval, valid_ptr_min_sval) < 0 ||
+ sval_cmp(sval, valid_ptr_max_sval) > 0)
return;
- if (!get_mtag(right, &right_tag))
+ if (sval.uvalue & MTAG_OFFSET_MASK)
+ return;
+
+ if (!expr_to_mtag_offset(left, &left_tag, &offset))
return;
- sql_insert_mtag_map(right_tag, -offset, left_tag);
+ sql_insert_mtag_map(sval.uvalue, -offset, left_tag);
}
void register_mtag_map(int id)

Privacy Policy