From fef3b84b47cbd580fcfdf2ca87299c401c7a04fa Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sun, 8 Mar 2009 01:25:21 +0300 Subject: [PATCH] implied pools: cleanup how implied pools are created. Implied pools help us know where a state comes from. When two branches are merged we save the pool. sm_states have an ->all_pools which records every pool that a state is a part of. The first time an sm_state goes through a pool that is recorded in the ->my_pools. When we merge sm_states both the ->my_pools and ->all_pools from both sides are copied to the new state. This patch cleans up how that is implemented. Signed-off-by: Dan Carpenter --- smatch_slist.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/smatch_slist.c b/smatch_slist.c index 3bd7c9c4..3d76154a 100644 --- a/smatch_slist.c +++ b/smatch_slist.c @@ -574,6 +574,20 @@ static int is_really_same(struct sm_state *one, struct sm_state *two) return 1; } +static void register_implied_pool(struct state_list *pool) +{ + struct sm_state *sm; + + FOR_EACH_PTR(pool, sm) { + if (!sm->my_pools) { + add_pool(&sm->my_pools, pool); + } + add_pool(&sm->all_pools, pool); + } END_FOR_EACH_PTR(sm); + + push_slist(&implied_pools, pool); +} + /* * merge_slist() is called whenever paths merge, such as after * an if statement. It takes the two slists and creates one. @@ -602,6 +616,9 @@ void merge_slist(struct state_list **to, struct state_list *slist) implied_to = clone_slist(*to); implied_from = clone_slist(slist); + register_implied_pool(implied_to); + register_implied_pool(implied_from); + PREPARE_PTR_LIST(implied_to, to_state); PREPARE_PTR_LIST(implied_from, state); for (;;) { @@ -609,33 +626,19 @@ void merge_slist(struct state_list **to, struct state_list *slist) break; if (cmp_tracker(to_state, state) < 0) { tmp = merge_sm_states(to_state, NULL); - add_pool(&to_state->my_pools, implied_to); - add_pool(&to_state->all_pools, implied_to); - add_pool(&tmp->my_pools, implied_to); - add_pool(&tmp->all_pools, implied_to); add_ptr_list(&results, tmp); NEXT_PTR_LIST(to_state); } else if (cmp_tracker(to_state, state) == 0) { tmp = merge_sm_states(to_state, state); if (!is_really_same(to_state, state)) { - add_pool(&to_state->my_pools, implied_to); - add_pool(&state->my_pools, implied_from); add_pool(&tmp->my_pools, implied_to); add_pool(&tmp->my_pools, implied_from); } - add_pool(&tmp->all_pools, implied_to); - add_pool(&tmp->all_pools, implied_from); - add_pool(&to_state->all_pools, implied_to); - add_pool(&state->all_pools, implied_from); add_ptr_list(&results, tmp); NEXT_PTR_LIST(to_state); NEXT_PTR_LIST(state); } else { tmp = merge_sm_states(state, NULL); - add_pool(&state->my_pools, implied_from); - add_pool(&state->all_pools, implied_from); - add_pool(&tmp->my_pools, implied_from); - add_pool(&tmp->all_pools, implied_from); add_ptr_list(&results, tmp); NEXT_PTR_LIST(state); } @@ -645,9 +648,6 @@ void merge_slist(struct state_list **to, struct state_list *slist) free_slist(to); *to = results; - - push_slist(&implied_pools, implied_from); - push_slist(&implied_pools, implied_to); } static int pool_in_pools(struct state_list_stack *pools, -- 2.11.4.GIT