14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
16 */
17
18 #include "smatch.h"
19 #include "smatch_slist.h"
20
21 static int my_id;
22
23 static struct stree *used_stree;
24 static struct stree_stack *saved_stack;
25
26 STATE(used);
27
28 static void get_state_hook(int owner, const char *name, struct symbol *sym)
29 {
30 int arg;
31
32 if (!option_info)
33 return;
34 if (__in_fake_assign || __in_fake_parameter_assign || __in_function_def)
35 return;
36
37 arg = get_param_num_from_sym(sym);
38 if (arg >= 0)
39 set_state_stree(&used_stree, my_id, name, sym, &used);
40 }
41
42 static void set_param_used(struct expression *call, struct expression *arg, char *key, char *unused)
43 {
44 struct symbol *sym;
45 char *name;
46 int arg_nr;
47
48 name = get_variable_from_key(arg, key, &sym);
49 if (!name || !sym)
50 goto free;
51
52 arg_nr = get_param_num_from_sym(sym);
53 if (arg_nr >= 0)
54 set_state_stree(&used_stree, my_id, name, sym, &used);
55 free:
56 free_string(name);
57 }
58
59 static void process_states(void)
60 {
61 struct sm_state *tmp;
62 int arg;
63 const char *name;
64
65 FOR_EACH_SM(used_stree, tmp) {
66 arg = get_param_num_from_sym(tmp->sym);
67 if (arg < 0)
68 continue;
69 name = get_param_name(tmp);
70 if (!name)
71 continue;
72 if (is_recursive_member(name))
73 continue;
|
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
16 */
17
18 #include "smatch.h"
19 #include "smatch_slist.h"
20
21 static int my_id;
22
23 static struct stree *used_stree;
24 static struct stree_stack *saved_stack;
25
26 STATE(used);
27
28 static void get_state_hook(int owner, const char *name, struct symbol *sym)
29 {
30 int arg;
31
32 if (!option_info)
33 return;
34
35 if (__in_fake_assign || __in_fake_parameter_assign || __in_function_def || __in_unmatched_hook)
36 return;
37
38 arg = get_param_num_from_sym(sym);
39 if (arg < 0)
40 return;
41 if (param_was_set_var_sym(name, sym))
42 return;
43 set_state_stree(&used_stree, my_id, name, sym, &used);
44 }
45
46 static void set_param_used(struct expression *call, struct expression *arg, char *key, char *unused)
47 {
48 struct symbol *sym;
49 char *name;
50 int arg_nr;
51
52 if (!option_info)
53 return;
54
55 name = get_variable_from_key(arg, key, &sym);
56 if (!name || !sym)
57 goto free;
58
59 arg_nr = get_param_num_from_sym(sym);
60 if (arg_nr < 0)
61 goto free;
62 if (param_was_set_var_sym(name, sym))
63 goto free;
64 set_state_stree(&used_stree, my_id, name, sym, &used);
65 free:
66 free_string(name);
67 }
68
69 static void process_states(void)
70 {
71 struct sm_state *tmp;
72 int arg;
73 const char *name;
74
75 FOR_EACH_SM(used_stree, tmp) {
76 arg = get_param_num_from_sym(tmp->sym);
77 if (arg < 0)
78 continue;
79 name = get_param_name(tmp);
80 if (!name)
81 continue;
82 if (is_recursive_member(name))
83 continue;
|