From 27c775dda149cfae9678d5d062bd81fc7893ec8e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 12 Jun 2013 17:14:40 +0300 Subject: [PATCH] hooks: introduce AFTER_FUNC_HOOK The AFTER_FUNC_HOOK is useful for freeing data. Otherwise you need to add a second register_late function at the end of the check_list.h file so that you only free data when you have run all the other end of function hooks. Signed-off-by: Dan Carpenter --- smatch.h | 1 + smatch_flow.c | 2 ++ smatch_hooks.c | 3 +++ 3 files changed, 6 insertions(+) diff --git a/smatch.h b/smatch.h index 817c3911..46092087 100644 --- a/smatch.h +++ b/smatch.h @@ -99,6 +99,7 @@ enum hook_type { FUNC_DEF_HOOK, AFTER_DEF_HOOK, END_FUNC_HOOK, + AFTER_FUNC_HOOK, RETURN_HOOK, INLINE_FN_START, INLINE_FN_END, diff --git a/smatch_flow.c b/smatch_flow.c index fce79216..24a05748 100644 --- a/smatch_flow.c +++ b/smatch_flow.c @@ -998,6 +998,7 @@ static void split_function(struct symbol *sym) __split_stmt(base_type->stmt); __split_stmt(base_type->inline_stmt); __pass_to_client(sym, END_FUNC_HOOK); + __pass_to_client(sym, AFTER_FUNC_HOOK); cur_func = NULL; clear_all_states(); free_data_info_allocs(); @@ -1043,6 +1044,7 @@ static void parse_inline(struct expression *call) __split_stmt(base_type->stmt); __split_stmt(base_type->inline_stmt); __pass_to_client(call->fn->symbol, END_FUNC_HOOK); + __pass_to_client(call->fn->symbol, AFTER_FUNC_HOOK); free_expression_stack(&switch_expr_stack); __free_ptr_list((struct ptr_list **)&big_statement_stack); diff --git a/smatch_hooks.c b/smatch_hooks.c index a2cfad78..c471d75e 100644 --- a/smatch_hooks.c +++ b/smatch_hooks.c @@ -126,6 +126,9 @@ void add_hook(void *func, enum hook_type type) case END_FUNC_HOOK: container->data_type = SYMBOL_PTR; break; + case AFTER_FUNC_HOOK: + container->data_type = SYMBOL_PTR; + break; case RETURN_HOOK: container->data_type = EXPR_PTR; break; -- 2.11.4.GIT