2 * sparse/check_assigned_expr.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
11 * This is not a check. It just saves an struct expression pointer
12 * whenever something is assigned. This can be used later on by other scripts.
16 #include "smatch_slist.h"
18 int check_assigned_expr_id
;
21 static struct smatch_state
*alloc_my_state(struct expression
*expr
)
23 struct smatch_state
*state
;
26 state
= __alloc_smatch_state(0);
27 expr
= strip_expr(expr
);
28 name
= get_variable_from_expr_complex(expr
, NULL
);
29 state
->name
= alloc_sname(name
);
35 static void match_assignment(struct expression
*expr
)
37 set_state_expr(my_id
, expr
->left
, alloc_my_state(expr
->right
));
40 void check_assigned_expr(int id
)
42 my_id
= check_assigned_expr_id
= id
;
43 add_hook(&match_assignment
, ASSIGNMENT_HOOK
);