From 618a46040c1cef75e6f9e08eaf588de29cc6661a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 20 Nov 2012 14:48:00 +0300 Subject: [PATCH] extra: type: move get_arge_type() to smatch_type.c This is more type related. Signed-off-by: Dan Carpenter --- smatch.h | 1 + smatch_extra.c | 27 --------------------------- smatch_type.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/smatch.h b/smatch.h index 0be4f4e2..218615e8 100644 --- a/smatch.h +++ b/smatch.h @@ -273,6 +273,7 @@ int is_static(struct expression *expr); int types_equiv(struct symbol *one, struct symbol *two); const char *global_static(); struct symbol *cur_func_return_type(void); +struct symbol *get_arg_type(struct expression *fn, int arg); /* smatch_ignore.c */ void add_ignore(int owner, const char *name, struct symbol *sym); diff --git a/smatch_extra.c b/smatch_extra.c index 630b0eaa..0f936db9 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -953,33 +953,6 @@ int implied_not_equal(struct expression *expr, long long val) return !possibly_false(expr, SPECIAL_NOTEQUAL, value_expr(val)); } -static struct symbol *get_arg_type(struct expression *fn, int arg) -{ - struct symbol *fn_type; - struct symbol *tmp; - struct symbol *arg_type; - int i; - - fn_type = get_type(fn); - if (!fn_type) - return NULL; - if (fn_type->type == SYM_PTR) - fn_type = get_real_base_type(fn_type); - if (fn_type->type != SYM_FN) - return NULL; - - i = 0; - FOR_EACH_PTR(fn_type->arguments, tmp) { - arg_type = get_real_base_type(tmp); - if (i == arg) { - return arg_type; - } - i++; - } END_FOR_EACH_PTR(tmp); - - return NULL; -} - int is_whole_range(struct smatch_state *state) { return is_whole_range_rl(estate_ranges(state)); diff --git a/smatch_type.c b/smatch_type.c index 6f71e44e..488a778a 100644 --- a/smatch_type.c +++ b/smatch_type.c @@ -386,3 +386,31 @@ struct symbol *cur_func_return_type(void) sym = get_real_base_type(sym); return sym; } + +struct symbol *get_arg_type(struct expression *fn, int arg) +{ + struct symbol *fn_type; + struct symbol *tmp; + struct symbol *arg_type; + int i; + + fn_type = get_type(fn); + if (!fn_type) + return NULL; + if (fn_type->type == SYM_PTR) + fn_type = get_real_base_type(fn_type); + if (fn_type->type != SYM_FN) + return NULL; + + i = 0; + FOR_EACH_PTR(fn_type->arguments, tmp) { + arg_type = get_real_base_type(tmp); + if (i == arg) { + return arg_type; + } + i++; + } END_FOR_EACH_PTR(tmp); + + return NULL; +} + -- 2.11.4.GIT