From fc2dc2e0b5de3531610d729559d284054bb11651 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 27 Jan 2017 11:30:20 +0300 Subject: [PATCH] type_val: handle |= type assignments In the old code, I tried to figure out the value of the right hand side, but now I just wait until smatch_extra.c has set the left hand side and then use that value. Signed-off-by: Dan Carpenter --- smatch_type_val.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/smatch_type_val.c b/smatch_type_val.c index 51ef641f..f153986f 100644 --- a/smatch_type_val.c +++ b/smatch_type_val.c @@ -261,12 +261,12 @@ static void match_assign_value(struct expression *expr) goto free; } - if (expr->op != '=') { - add_type_val(member, alloc_whole_rl(get_type(expr->left))); - goto free; - } - get_absolute_rl(expr->right, &rl); - rl = cast_rl(type, rl); + /* + * This is a bit cheating. We order it so this will already be set + * by smatch_extra.c and we just look up the value. + */ + + get_absolute_rl(expr->left, &rl); add_type_val(member, rl); free: free_string(right_member); @@ -420,7 +420,7 @@ void register_type_val(int id) my_id = id; - add_hook(&match_assign_value, ASSIGNMENT_HOOK); + add_hook(&match_assign_value, ASSIGNMENT_HOOK_AFTER); add_hook(&match_assign_pointer, ASSIGNMENT_HOOK); add_hook(&unop_expr, OP_HOOK); add_hook(&asm_expr, ASM_HOOK); -- 2.11.4.GIT