2 * Copyright (C) 2015 Oracle.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
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
19 #include "smatch_slist.h"
23 struct stree
*used_stree
;
27 * I am a loser. This should be a proper hook, but I am too lazy. I'll add
28 * that stuff if we have a second user.
30 void __get_state_hook(int owner
, const char *name
, struct symbol
*sym
)
39 arg
= get_param_num_from_sym(sym
);
43 set_state_stree(&used_stree
, my_id
, name
, sym
, &used
);
46 static void set_param_used(struct expression
*arg
, char *key
, char *unused
)
52 name
= get_variable_from_key(arg
, key
, &sym
);
56 arg_nr
= get_param_num_from_sym(sym
);
60 set_state(my_id
, name
, sym
, &used
);
65 static void process_states(struct stree
*stree
)
71 FOR_EACH_SM(used_stree
, tmp
) {
72 arg
= get_param_num_from_sym(tmp
->sym
);
73 name
= get_param_name(tmp
);
76 sql_insert_call_implies(PARAM_USED
, arg
, name
, "1");
77 } END_FOR_EACH_SM(tmp
);
79 free_stree(&used_stree
);
82 void register_param_used(int id
)
89 select_call_implies_hook(PARAM_USED
, &set_param_used
);
90 all_return_states_hook(&process_states
);