From 27d660c3ccffda62076a66ce8289a3d3addc0dc0 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 24 Sep 2014 17:53:14 +0300 Subject: [PATCH] assigned_expr: undefine on modification If the variable is modified then clear the assignment state. This could happen for code like "foo++" but it could also happen that we do a struct assignment or something with smatch_param_set.c. Signed-off-by: Dan Carpenter --- check_assigned_expr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/check_assigned_expr.c b/check_assigned_expr.c index 5e7e47d7..2d76db3e 100644 --- a/check_assigned_expr.c +++ b/check_assigned_expr.c @@ -28,6 +28,11 @@ int check_assigned_expr_id; static int my_id; static int link_id; +static void undef(struct sm_state *sm, struct expression *mod_expr) +{ + set_state(my_id, sm->name, sm->sym, &undefined); +} + struct expression *get_assigned_expr(struct expression *expr) { struct smatch_state *state; @@ -93,6 +98,7 @@ void check_assigned_expr(int id) { my_id = check_assigned_expr_id = id; add_hook(&match_assignment, ASSIGNMENT_HOOK); + add_modification_hook(my_id, &undef); } void check_assigned_expr_links(int id) -- 2.11.4.GIT