From 93708aa181389405784f0545a94c284750fd632d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 4 May 2009 20:25:45 +0300 Subject: [PATCH] Delete all the anding compound conditions code. 114 lines of code replaced by 1 line. This also fixes a test case. Signed-off-by: Dan Carpenter --- smatch_extra.c | 26 ----------- smatch_extra.h | 2 - smatch_slist.c | 87 +----------------------------------- validation/sm_compound_conditions2.c | 4 +- 4 files changed, 3 insertions(+), 116 deletions(-) diff --git a/smatch_extra.c b/smatch_extra.c index dc9f3bbc..e98f4c0c 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -130,32 +130,6 @@ static struct smatch_state *merge_func(const char *name, struct symbol *sym, return tmp; } -struct sm_state *__extra_and_merge(struct sm_state *sm, - struct state_list_stack *stack) -{ - struct state_list *slist; - struct sm_state *ret = NULL; - struct sm_state *tmp; - int i = 0; - - FOR_EACH_PTR(stack, slist) { - if (!i++) { - ret = get_sm_state_slist(slist, sm->name, sm->owner, - sm->sym); - } else { - tmp = get_sm_state_slist(slist, sm->name, sm->owner, - sm->sym); - ret = merge_sm_states(ret, tmp); - } - } END_FOR_EACH_PTR(slist); - if (!ret) { - smatch_msg("Internal error in __extra_and_merge"); - return NULL; - } - ret->my_pools = stack; - return ret; -} - struct sm_state *__extra_pre_loop_hook_before(struct statement *iterator_pre_statement) { struct expression *expr; diff --git a/smatch_extra.h b/smatch_extra.h index ac1d02b7..ab93db7c 100644 --- a/smatch_extra.h +++ b/smatch_extra.h @@ -33,8 +33,6 @@ struct range_list *remove_range(struct range_list *list, long long min, long lon /* used in smatch_slist. implemented in smatch_extra.c */ struct sm_state *__extra_merge(struct sm_state *one, struct state_list *slist1, struct sm_state *two, struct state_list *slist2); -struct sm_state *__extra_and_merge(struct sm_state *sm, - struct state_list_stack *stack); struct sm_state *__extra_pre_loop_hook_before(struct statement *iterator_pre_statement); int __iterator_unchanged(struct sm_state *sm, struct statement *iterator); void __extra_pre_loop_hook_after(struct sm_state *sm, diff --git a/smatch_slist.c b/smatch_slist.c index d7475d15..27054c13 100644 --- a/smatch_slist.c +++ b/smatch_slist.c @@ -653,86 +653,6 @@ void merge_slist(struct state_list **to, struct state_list *slist) *to = results; } -static struct sm_state *find_intersection(struct sm_state *one, - struct sm_state *two) -{ - struct state_list *tmp1, *tmp2; - struct state_list_stack *stack = NULL; - struct sm_state *tmp_state; - struct sm_state *ret; - int count = 0; - - if (!one) - return two; - - if (one->owner != SMATCH_EXTRA && one->state != &merged) { - if (one->state == two->state) - return one; - if (two->state != &merged) { - SM_DEBUG("mutually exclusive 'and' conditions states " - "'%s': %s + %s\n", one->name, - show_state(one->state), - show_state(two->state)); - return two; - } - } - if (one->owner == SMATCH_EXTRA) { - if (one->state == two->state) - return one; - - ret = NULL; - if (!one->my_pools) { - ret = one; - } - if (!two->my_pools) { - ret = two; - } - if (ret) - return ret; - } - - PREPARE_PTR_LIST(one->my_pools, tmp1); - PREPARE_PTR_LIST(two->my_pools, tmp2); - for (;;) { - if (!tmp1 && !tmp2) - break; - if (!tmp2 || (tmp1 && tmp1 < tmp2)) { - NEXT_PTR_LIST(tmp1); - } else if (tmp1 == tmp2) { - push_slist(&stack, tmp1); - count++; - NEXT_PTR_LIST(tmp1); - NEXT_PTR_LIST(tmp2); - } else { - NEXT_PTR_LIST(tmp2); - } - } - FINISH_PTR_LIST(tmp2); - FINISH_PTR_LIST(tmp1); - - if (count == 0) { - SM_DEBUG("mutually eXclusive 'and' conditions states " - "'%s': %s + %s\n", one->name, show_state(one->state), - show_state(two->state)); - return two; - } - if (count == 1) - return get_sm_state_stack(stack, one->name, one->owner, - one->sym); - - if (one->owner == SMATCH_EXTRA) - return __extra_and_merge(one, stack); - - ret = alloc_state_no_name(one->name, one->owner, one->sym, &merged); - FOR_EACH_PTR(stack, tmp1) { - tmp_state = get_sm_state_slist(tmp1, one->name, one->owner, - one->sym); - add_possible(ret, tmp_state); - } END_FOR_EACH_PTR(tmp1); - ret->my_pools = stack; - return ret; -} - /* * and_slist_stack() is basically the same as popping the top two slists, * overwriting the one with the other and pushing it back on the stack. @@ -743,15 +663,10 @@ static struct sm_state *find_intersection(struct sm_state *one, void and_slist_stack(struct state_list_stack **slist_stack) { struct sm_state *tmp; - struct sm_state *left_state; - struct sm_state *res; struct state_list *right_slist = pop_slist(slist_stack); FOR_EACH_PTR(right_slist, tmp) { - left_state = get_sm_state_stack(*slist_stack, tmp->name, - tmp->owner, tmp->sym); - res = find_intersection(left_state, tmp); - overwrite_sm_state_stack(slist_stack, res); + overwrite_sm_state_stack(slist_stack, tmp); } END_FOR_EACH_PTR(tmp); free_slist(&right_slist); } diff --git a/validation/sm_compound_conditions2.c b/validation/sm_compound_conditions2.c index ae8f773d..923dc597 100644 --- a/validation/sm_compound_conditions2.c +++ b/validation/sm_compound_conditions2.c @@ -43,12 +43,10 @@ void func (void) __smatch_print_value("aaa"); if (x || y) __smatch_print_value("aaa"); -/* these last ones are broken else __smatch_print_value("aaa"); if (!x && !y) __smatch_print_value("aaa"); -*/ } /* * check-name: Compound Conditions #2 @@ -69,5 +67,7 @@ sm_compound_conditions2.c +38 func(32) aaa = 2 sm_compound_conditions2.c +40 func(34) aaa = 0 sm_compound_conditions2.c +43 func(37) aaa = 2 sm_compound_conditions2.c +45 func(39) aaa = 1-2 +sm_compound_conditions2.c +47 func(41) aaa = 0 +sm_compound_conditions2.c +49 func(43) aaa = 0 * check-output-end */ -- 2.11.4.GIT