Print this page
12166 resync smatch to 0.6.1-rc1-il-3
*** 31,88 ****
#include "smatch.h"
static int my_id;
- STATE(argument);
-
- static struct symbol *func_sym;
-
- static void delete(struct sm_state *sm, struct expression *mod_expr)
- {
- set_state(my_id, sm->name, sm->sym, &undefined);
- }
-
- static void match_function_def(struct symbol *sym)
- {
- struct symbol *arg;
-
- func_sym = sym;
- FOR_EACH_PTR(func_sym->ctype.base_type->arguments, arg) {
- if (!arg->ident) {
- continue;
- }
- set_state(my_id, arg->ident->name, arg, &argument);
- } END_FOR_EACH_PTR(arg);
- }
-
- static int get_arg_num(struct expression *expr)
- {
- struct smatch_state *state;
- struct symbol *arg;
- struct symbol *this_arg;
- int i;
-
- expr = strip_expr(expr);
- if (expr->type != EXPR_SYMBOL)
- return -1;
- this_arg = expr->symbol;
-
- state = get_state_expr(my_id, expr);
- if (!state || state != &argument)
- return -1;
-
- i = 0;
- FOR_EACH_PTR(func_sym->ctype.base_type->arguments, arg) {
- if (arg == this_arg)
- return i;
- i++;
- } END_FOR_EACH_PTR(arg);
-
- return -1;
- }
-
static void match_call(struct expression *expr)
{
struct expression *tmp;
char *func;
int arg_num;
--- 31,40 ----
*** 91,114 ****
if (expr->fn->type != EXPR_SYMBOL)
return;
func = expr->fn->symbol_name->name;
! i = 0;
FOR_EACH_PTR(expr->args, tmp) {
tmp = strip_expr(tmp);
! arg_num = get_arg_num(tmp);
! if (arg_num >= 0)
sm_msg("info: param_mapper %d => %s %d", arg_num, func, i);
- i++;
} END_FOR_EACH_PTR(tmp);
}
void check_param_mapper(int id)
{
! if (!option_param_mapper)
return;
my_id = id;
- add_modification_hook(my_id, &delete);
- add_hook(&match_function_def, FUNC_DEF_HOOK);
add_hook(&match_call, FUNCTION_CALL_HOOK);
}
--- 43,69 ----
if (expr->fn->type != EXPR_SYMBOL)
return;
func = expr->fn->symbol_name->name;
! i = -1;
FOR_EACH_PTR(expr->args, tmp) {
+ i++;
tmp = strip_expr(tmp);
! if (tmp->type != EXPR_SYMBOL)
! continue;
! if (param_was_set(tmp))
! continue;
! arg_num = get_param_num_from_sym(tmp->symbol);
! if (arg_num < 0)
! continue;
sm_msg("info: param_mapper %d => %s %d", arg_num, func, i);
} END_FOR_EACH_PTR(tmp);
}
void check_param_mapper(int id)
{
! if (!option_info)
return;
my_id = id;
add_hook(&match_call, FUNCTION_CALL_HOOK);
}