states, stree: introduce stree versions of __get_cur_slist() and friends
[smatch.git] / smatch_states.c
blobd022e787a2817250c50f97b4b91f5a4fe24435d3
1 /*
2 * Copyright (C) 2006 Dan Carpenter.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 * You have a lists of states. kernel = locked, foo = NULL, ...
20 * When you hit an if {} else {} statement then you swap the list
21 * of states for a different list of states. The lists are stored
22 * on stacks.
24 * At the beginning of this file there are list of the stacks that
25 * we use. Each function in this file does something to one of
26 * of the stacks.
28 * So the smatch_flow.c understands code but it doesn't understand states.
29 * smatch_flow calls functions in this file. This file calls functions
30 * in smatch_slist.c which just has boring generic plumbing for handling
31 * state lists. But really it's this file where all the magic happens.
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include "smatch.h"
37 #include "smatch_slist.h"
38 #include "smatch_extra.h"
40 struct smatch_state undefined = { .name = "undefined" };
41 struct smatch_state merged = { .name = "merged" };
42 struct smatch_state true_state = { .name = "true" };
43 struct smatch_state false_state = { .name = "false" };
45 static struct AVL *cur_stree; /* current states */
47 static struct stree_stack *true_stack; /* states after a t/f branch */
48 static struct stree_stack *false_stack;
49 static struct stree_stack *pre_cond_stack; /* states before a t/f branch */
51 static struct stree_stack *cond_true_stack; /* states affected by a branch */
52 static struct stree_stack *cond_false_stack;
54 static struct stree_stack *fake_cur_stree_stack;
55 static int read_only;
57 static struct stree_stack *break_stack;
58 static struct stree_stack *switch_stack;
59 static struct range_list_stack *remaining_cases;
60 static struct stree_stack *default_stack;
61 static struct stree_stack *continue_stack;
63 static struct named_stree_stack *goto_stack;
65 static struct ptr_list *backup;
67 struct state_list_stack *implied_pools;
69 int option_debug;
71 void __print_cur_slist(void)
73 __print_stree(cur_stree);
76 static int in_declarations_bit(void)
78 struct statement *tmp;
80 FOR_EACH_PTR_REVERSE(big_statement_stack, tmp) {
81 if (tmp->type == STMT_DECLARATION)
82 return 1;
83 return 0;
84 } END_FOR_EACH_PTR_REVERSE(tmp);
85 return 0;
88 int unreachable(void)
90 static int reset_warnings = 1;
92 if (cur_stree) {
93 if (!__inline_fn)
94 reset_warnings = 1;
95 return 0;
98 if (in_declarations_bit())
99 return 1;
101 /* option spammy turns on a noisier version of this */
102 if (reset_warnings && !option_spammy)
103 sm_msg("info: ignoring unreachable code.");
104 if (!__inline_fn)
105 reset_warnings = 0;
106 return 1;
109 struct sm_state *set_state(int owner, const char *name, struct symbol *sym, struct smatch_state *state)
111 struct sm_state *ret;
113 if (!name)
114 return NULL;
116 if (read_only)
117 sm_msg("Smatch Internal Error: cur_stree is read only.");
119 if (option_debug || strcmp(check_name(owner), option_debug_check) == 0) {
120 struct smatch_state *s;
122 s = get_state(owner, name, sym);
123 if (!s)
124 printf("%d new state. name='%s' [%s] %s\n",
125 get_lineno(), name, check_name(owner), show_state(state));
126 else
127 printf("%d state change name='%s' [%s] %s => %s\n",
128 get_lineno(), name, check_name(owner), show_state(s),
129 show_state(state));
132 if (owner != -1 && unreachable())
133 return NULL;
135 if (fake_cur_stree_stack)
136 set_state_stree_stack(&fake_cur_stree_stack, owner, name, sym, state);
138 ret = set_state_stree(&cur_stree, owner, name, sym, state);
140 if (cond_true_stack) {
141 set_state_stree_stack(&cond_true_stack, owner, name, sym, state);
142 set_state_stree_stack(&cond_false_stack, owner, name, sym, state);
144 return ret;
147 struct sm_state *set_state_expr(int owner, struct expression *expr, struct smatch_state *state)
149 char *name;
150 struct symbol *sym;
151 struct sm_state *ret = NULL;
153 expr = strip_expr(expr);
154 name = expr_to_var_sym(expr, &sym);
155 if (!name || !sym)
156 goto free;
157 ret = set_state(owner, name, sym, state);
158 free:
159 free_string(name);
160 return ret;
163 void __push_fake_cur_slist()
165 push_stree(&fake_cur_stree_stack, NULL);
166 __save_pre_cond_states();
169 struct AVL *__pop_fake_cur_slist()
171 __use_pre_cond_states();
172 return pop_stree(&fake_cur_stree_stack);
175 void __free_fake_cur_slist()
177 struct AVL *stree;
179 __use_pre_cond_states();
180 stree = pop_stree(&fake_cur_stree_stack);
181 free_stree(&stree);
184 void __set_fake_cur_slist_fast(struct state_list *slist)
186 push_stree(&pre_cond_stack, cur_stree);
187 cur_stree = slist_to_stree(slist);
188 read_only = 1;
191 void __set_fake_cur_stree_fast(struct AVL *stree)
193 push_stree(&pre_cond_stack, cur_stree);
194 cur_stree = stree;
195 read_only = 1;
198 void __pop_fake_cur_slist_fast()
200 cur_stree = pop_stree(&pre_cond_stack);
201 read_only = 0;
204 void __pop_fake_cur_stree_fast()
206 cur_stree = pop_stree(&pre_cond_stack);
207 read_only = 0;
210 void __merge_slist_into_cur(struct state_list *slist)
212 struct sm_state *sm;
213 struct sm_state *orig;
214 struct sm_state *merged;
216 FOR_EACH_PTR(slist, sm) {
217 orig = get_sm_state(sm->owner, sm->name, sm->sym);
218 if (orig)
219 merged = merge_sm_states(orig, sm);
220 else
221 merged = sm;
222 __set_sm(merged);
223 } END_FOR_EACH_PTR(sm);
226 void __set_sm(struct sm_state *sm)
228 if (read_only)
229 sm_msg("Smatch Internal Error: cur_stree is read only.");
231 if (option_debug ||
232 strcmp(check_name(sm->owner), option_debug_check) == 0) {
233 struct smatch_state *s;
235 s = get_state(sm->owner, sm->name, sm->sym);
236 if (!s)
237 printf("%d new state. name='%s' [%s] %s\n",
238 get_lineno(), sm->name, check_name(sm->owner),
239 show_state(sm->state));
240 else
241 printf("%d state change name='%s' [%s] %s => %s\n",
242 get_lineno(), sm->name, check_name(sm->owner), show_state(s),
243 show_state(sm->state));
246 if (unreachable())
247 return;
249 if (fake_cur_stree_stack)
250 overwrite_sm_state_stree_stack(&fake_cur_stree_stack, sm);
252 overwrite_sm_state_stree(&cur_stree, sm);
254 if (cond_true_stack) {
255 overwrite_sm_state_stree_stack(&cond_true_stack, sm);
256 overwrite_sm_state_stree_stack(&cond_false_stack, sm);
260 struct smatch_state *get_state(int owner, const char *name, struct symbol *sym)
262 return get_state_stree(cur_stree, owner, name, sym);
265 struct smatch_state *get_state_expr(int owner, struct expression *expr)
267 char *name;
268 struct symbol *sym;
269 struct smatch_state *ret = NULL;
271 expr = strip_expr(expr);
272 name = expr_to_var_sym(expr, &sym);
273 if (!name || !sym)
274 goto free;
275 ret = get_state(owner, name, sym);
276 free:
277 free_string(name);
278 return ret;
281 struct state_list *get_possible_states(int owner, const char *name, struct symbol *sym)
283 struct sm_state *sms;
285 sms = get_sm_state_stree(cur_stree, owner, name, sym);
286 if (sms)
287 return sms->possible;
288 return NULL;
291 struct state_list *get_possible_states_expr(int owner, struct expression *expr)
293 char *name;
294 struct symbol *sym;
295 struct state_list *ret = NULL;
297 expr = strip_expr(expr);
298 name = expr_to_var_sym(expr, &sym);
299 if (!name || !sym)
300 goto free;
301 ret = get_possible_states(owner, name, sym);
302 free:
303 free_string(name);
304 return ret;
307 struct sm_state *get_sm_state(int owner, const char *name, struct symbol *sym)
309 return get_sm_state_stree(cur_stree, owner, name, sym);
312 struct sm_state *get_sm_state_expr(int owner, struct expression *expr)
314 char *name;
315 struct symbol *sym;
316 struct sm_state *ret = NULL;
318 expr = strip_expr(expr);
319 name = expr_to_var_sym(expr, &sym);
320 if (!name || !sym)
321 goto free;
322 ret = get_sm_state(owner, name, sym);
323 free:
324 free_string(name);
325 return ret;
328 void delete_state(int owner, const char *name, struct symbol *sym)
330 delete_state_stree(&cur_stree, owner, name, sym);
331 if (cond_true_stack) {
332 delete_state_stree_stack(&pre_cond_stack, owner, name, sym);
333 delete_state_stree_stack(&cond_true_stack, owner, name, sym);
334 delete_state_stree_stack(&cond_false_stack, owner, name, sym);
338 void delete_state_expr(int owner, struct expression *expr)
340 char *name;
341 struct symbol *sym;
343 expr = strip_expr(expr);
344 name = expr_to_var_sym(expr, &sym);
345 if (!name || !sym)
346 goto free;
347 delete_state(owner, name, sym);
348 free:
349 free_string(name);
352 struct state_list *get_all_states_slist(int owner, struct state_list *source)
354 struct state_list *slist = NULL;
355 struct sm_state *tmp;
357 FOR_EACH_PTR(source, tmp) {
358 if (tmp->owner == owner)
359 add_ptr_list(&slist, tmp);
360 } END_FOR_EACH_PTR(tmp);
362 return slist;
365 struct state_list *get_all_states(int owner)
367 struct state_list *slist = NULL;
368 struct sm_state *tmp;
370 FOR_EACH_SM(cur_stree, tmp) {
371 if (tmp->owner == owner)
372 add_ptr_list(&slist, tmp);
373 } END_FOR_EACH_SM(tmp);
375 return slist;
378 struct AVL *get_all_states_from_stree(int owner, struct AVL *source)
380 struct AVL *ret = NULL;
381 struct sm_state *tmp;
383 FOR_EACH_SM(source, tmp) {
384 if (tmp->owner == owner)
385 avl_insert(&ret, tmp);
386 } END_FOR_EACH_SM(tmp);
388 return ret;
391 struct AVL *get_all_states_stree(int owner)
393 return get_all_states_from_stree(owner, cur_stree);
396 struct state_list *__get_cur_slist(void)
398 return stree_to_slist(cur_stree);
401 struct AVL *__get_cur_stree(void)
403 return cur_stree;
406 int is_reachable(void)
408 if (cur_stree)
409 return 1;
410 return 0;
413 void set_true_false_states(int owner, const char *name, struct symbol *sym,
414 struct smatch_state *true_state,
415 struct smatch_state *false_state)
417 if (option_debug || strcmp(check_name(owner), option_debug_check) == 0) {
418 struct smatch_state *tmp;
420 tmp = get_state(owner, name, sym);
421 printf("%d set_true_false '%s'. Was %s. Now T:%s F:%s\n",
422 get_lineno(), name, show_state(tmp),
423 show_state(true_state), show_state(false_state));
426 if (unreachable())
427 return;
429 if (!cond_false_stack || !cond_true_stack) {
430 printf("Error: missing true/false stacks\n");
431 return;
434 if (true_state) {
435 set_state_stree(&cur_stree, owner, name, sym, true_state);
436 set_state_stree_stack(&cond_true_stack, owner, name, sym, true_state);
438 if (false_state)
439 set_state_stree_stack(&cond_false_stack, owner, name, sym, false_state);
442 void set_true_false_states_expr(int owner, struct expression *expr,
443 struct smatch_state *true_state,
444 struct smatch_state *false_state)
446 char *name;
447 struct symbol *sym;
449 expr = strip_expr(expr);
450 name = expr_to_var_sym(expr, &sym);
451 if (!name || !sym)
452 goto free;
453 set_true_false_states(owner, name, sym, true_state, false_state);
454 free:
455 free_string(name);
458 void __set_true_false_sm(struct sm_state *true_sm, struct sm_state *false_sm)
460 if (unreachable())
461 return;
463 if (!cond_false_stack || !cond_true_stack) {
464 printf("Error: missing true/false stacks\n");
465 return;
468 if (true_sm) {
469 overwrite_sm_state_stree(&cur_stree, true_sm);
470 overwrite_sm_state_stree_stack(&cond_true_stack, true_sm);
472 if (false_sm)
473 overwrite_sm_state_stree_stack(&cond_false_stack, false_sm);
476 void nullify_path(void)
478 free_stree(&cur_stree);
481 void __match_nullify_path_hook(const char *fn, struct expression *expr,
482 void *unused)
484 nullify_path();
488 * At the start of every function we mark the path
489 * as unnull. That way there is always at least one state
490 * in the cur_stree until nullify_path is called. This
491 * is used in merge_slist() for the first null check.
493 void __unnullify_path(void)
495 set_state(-1, "unnull_path", NULL, &true_state);
498 int __path_is_null(void)
500 if (cur_stree)
501 return 0;
502 return 1;
505 static void check_stree_stack_free(struct stree_stack **stack)
507 if (*stack) {
508 sm_msg("smatch internal error: stack not empty");
509 free_stack_and_strees(stack);
513 void save_all_states(void)
515 __add_ptr_list(&backup, cur_stree, 0);
517 __add_ptr_list(&backup, true_stack, 0);
518 __add_ptr_list(&backup, false_stack, 0);
519 __add_ptr_list(&backup, pre_cond_stack, 0);
521 __add_ptr_list(&backup, cond_true_stack, 0);
522 __add_ptr_list(&backup, cond_false_stack, 0);
524 __add_ptr_list(&backup, fake_cur_stree_stack, 0);
526 __add_ptr_list(&backup, break_stack, 0);
527 __add_ptr_list(&backup, switch_stack, 0);
528 __add_ptr_list(&backup, remaining_cases, 0);
529 __add_ptr_list(&backup, default_stack, 0);
530 __add_ptr_list(&backup, continue_stack, 0);
532 __add_ptr_list(&backup, goto_stack, 0);
535 void nullify_all_states(void)
537 /* FIXME: These should call free_stree() */
538 cur_stree = NULL;
540 true_stack = NULL;
541 false_stack = NULL;
542 pre_cond_stack = NULL;
544 cond_true_stack = NULL;
545 cond_false_stack = NULL;
547 fake_cur_stree_stack = NULL;
549 break_stack = NULL;
550 switch_stack = NULL;
551 remaining_cases = NULL;
552 default_stack = NULL;
553 continue_stack = NULL;
555 goto_stack = NULL;
558 static void *pop_backup(void)
560 void *ret;
562 ret = last_ptr_list(backup);
563 delete_ptr_list_last(&backup);
564 return ret;
567 void restore_all_states(void)
569 goto_stack = pop_backup();
571 continue_stack = pop_backup();
572 default_stack = pop_backup();
573 remaining_cases = pop_backup();
574 switch_stack = pop_backup();
575 break_stack = pop_backup();
577 fake_cur_stree_stack = pop_backup();
579 cond_false_stack = pop_backup();
580 cond_true_stack = pop_backup();
582 pre_cond_stack = pop_backup();
583 false_stack = pop_backup();
584 true_stack = pop_backup();
586 cur_stree = pop_backup();
589 void clear_all_states(void)
591 struct named_stree *named_stree;
593 nullify_path();
594 check_stree_stack_free(&true_stack);
595 check_stree_stack_free(&false_stack);
596 check_stree_stack_free(&pre_cond_stack);
597 check_stree_stack_free(&cond_true_stack);
598 check_stree_stack_free(&cond_false_stack);
599 check_stree_stack_free(&break_stack);
600 check_stree_stack_free(&switch_stack);
601 check_stree_stack_free(&continue_stack);
602 free_stack_and_slists(&implied_pools);
604 FOR_EACH_PTR(goto_stack, named_stree) {
605 free_stree(&named_stree->stree);
606 } END_FOR_EACH_PTR(named_stree);
607 __free_ptr_list((struct ptr_list **)&goto_stack);
608 free_every_single_sm_state();
611 void __push_cond_stacks(void)
613 push_stree(&cond_true_stack, NULL);
614 push_stree(&cond_false_stack, NULL);
617 struct AVL *__copy_cond_true_states(void)
619 struct AVL *ret;
621 ret = pop_stree(&cond_true_stack);
622 push_stree(&cond_true_stack, clone_stree(ret));
623 return ret;
626 struct AVL *__copy_cond_false_states(void)
628 struct AVL *ret;
630 ret = pop_stree(&cond_false_stack);
631 push_stree(&cond_false_stack, clone_stree(ret));
632 return ret;
635 struct AVL *__pop_cond_true_stack(void)
637 return pop_stree(&cond_true_stack);
640 struct AVL *__pop_cond_false_stack(void)
642 return pop_stree(&cond_false_stack);
646 * This combines the pre cond states with either the true or false states.
647 * For example:
648 * a = kmalloc() ; if (a !! foo(a)
649 * In the pre state a is possibly null. In the true state it is non null.
650 * In the false state it is null. Combine the pre and the false to get
651 * that when we call 'foo', 'a' is null.
653 static void __use_cond_stack(struct stree_stack **stack)
655 struct AVL *stree;
657 free_stree(&cur_stree);
659 cur_stree = pop_stree(&pre_cond_stack);
660 push_stree(&pre_cond_stack, clone_stree(cur_stree));
662 stree = pop_stree(stack);
663 overwrite_stree(stree, &cur_stree);
664 push_stree(stack, stree);
667 void __use_pre_cond_states(void)
669 free_stree(&cur_stree);
670 cur_stree = pop_stree(&pre_cond_stack);
673 void __use_cond_true_states(void)
675 __use_cond_stack(&cond_true_stack);
678 void __use_cond_false_states(void)
680 __use_cond_stack(&cond_false_stack);
683 void __negate_cond_stacks(void)
685 struct AVL *old_false, *old_true;
687 __use_cond_stack(&cond_false_stack);
688 old_false = pop_stree(&cond_false_stack);
689 old_true = pop_stree(&cond_true_stack);
690 push_stree(&cond_false_stack, old_true);
691 push_stree(&cond_true_stack, old_false);
694 void __and_cond_states(void)
696 and_stree_stack(&cond_true_stack);
697 or_stree_stack(&pre_cond_stack, cur_stree, &cond_false_stack);
700 void __or_cond_states(void)
702 or_stree_stack(&pre_cond_stack, cur_stree, &cond_true_stack);
703 and_stree_stack(&cond_false_stack);
706 void __save_pre_cond_states(void)
708 push_stree(&pre_cond_stack, clone_stree(cur_stree));
711 void __discard_pre_cond_states(void)
713 struct AVL *tmp;
715 tmp = pop_stree(&pre_cond_stack);
716 free_stree(&tmp);
719 void __use_cond_states(void)
721 struct AVL *pre, *pre_clone, *true_states, *false_states;
723 pre = pop_stree(&pre_cond_stack);
724 pre_clone = clone_stree(pre);
726 true_states = pop_stree(&cond_true_stack);
727 overwrite_stree(true_states, &pre);
728 /* we use the true states right away */
729 free_stree(&cur_stree);
730 cur_stree = pre;
732 false_states = pop_stree(&cond_false_stack);
733 overwrite_stree(false_states, &pre_clone);
734 push_stree(&false_stack, pre_clone);
737 void __push_true_states(void)
739 push_stree(&true_stack, clone_stree(cur_stree));
742 void __use_false_states(void)
744 free_stree(&cur_stree);
745 cur_stree = pop_stree(&false_stack);
748 void __discard_false_states(void)
750 struct AVL *stree;
752 stree = pop_stree(&false_stack);
753 free_stree(&stree);
756 void __merge_false_states(void)
758 struct AVL *stree;
760 stree = pop_stree(&false_stack);
761 merge_stree(&cur_stree, stree);
762 free_stree(&stree);
765 void __merge_true_states(void)
767 struct AVL *stree;
769 stree = pop_stree(&true_stack);
770 merge_stree(&cur_stree, stree);
771 free_stree(&stree);
774 void __push_continues(void)
776 push_stree(&continue_stack, NULL);
779 void __discard_continues(void)
781 struct AVL *stree;
783 stree = pop_stree(&continue_stack);
784 free_stree(&stree);
787 void __process_continues(void)
789 struct AVL *stree;
791 stree = pop_stree(&continue_stack);
792 if (!stree)
793 stree = clone_stree(cur_stree);
794 else
795 merge_stree(&stree, cur_stree);
797 push_stree(&continue_stack, stree);
800 static int top_stree_empty(struct stree_stack **stack)
802 struct AVL *tmp;
803 int empty = 0;
805 tmp = pop_stree(stack);
806 if (!tmp)
807 empty = 1;
808 push_stree(stack, tmp);
809 return empty;
812 /* a silly loop does this: while(i--) { return; } */
813 void __warn_on_silly_pre_loops(void)
815 if (!__path_is_null())
816 return;
817 if (!top_stree_empty(&continue_stack))
818 return;
819 if (!top_stree_empty(&break_stack))
820 return;
821 /* if the path was nullified before the loop, then we already
822 printed an error earlier */
823 if (top_stree_empty(&false_stack))
824 return;
825 sm_msg("info: loop could be replaced with if statement.");
828 void __merge_continues(void)
830 struct AVL *stree;
832 stree = pop_stree(&continue_stack);
833 merge_stree(&cur_stree, stree);
834 free_stree(&stree);
837 void __push_breaks(void)
839 push_stree(&break_stack, NULL);
842 void __process_breaks(void)
844 struct AVL *stree;
846 stree = pop_stree(&break_stack);
847 if (!stree)
848 stree = clone_stree(cur_stree);
849 else
850 merge_stree(&stree, cur_stree);
852 push_stree(&break_stack, stree);
855 int __has_breaks(void)
857 struct AVL *stree;
858 int ret;
860 stree = pop_stree(&break_stack);
861 ret = !!stree;
862 push_stree(&break_stack, stree);
863 return ret;
866 void __merge_breaks(void)
868 struct AVL *stree;
870 stree = pop_stree(&break_stack);
871 merge_stree(&cur_stree, stree);
872 free_stree(&stree);
875 void __use_breaks(void)
877 free_stree(&cur_stree);
878 cur_stree = pop_stree(&break_stack);
881 void __save_switch_states(struct expression *switch_expr)
883 push_rl(&remaining_cases, __get_implied_values(switch_expr));
884 push_stree(&switch_stack, clone_stree(cur_stree));
887 void __merge_switches(struct expression *switch_expr, struct expression *case_expr)
889 struct AVL *stree;
890 struct state_list *implied_slist;
892 stree = pop_stree(&switch_stack);
893 implied_slist = __implied_case_slist(switch_expr, case_expr, &remaining_cases, &stree);
894 merge_stree(&cur_stree, slist_to_stree(implied_slist));
895 free_slist(&implied_slist);
896 push_stree(&switch_stack, stree);
899 void __discard_switches(void)
901 struct AVL *stree;
903 pop_rl(&remaining_cases);
904 stree = pop_stree(&switch_stack);
905 free_stree(&stree);
908 void __push_default(void)
910 push_stree(&default_stack, NULL);
913 void __set_default(void)
915 set_state_stree_stack(&default_stack, 0, "has_default", NULL, &true_state);
918 int __pop_default(void)
920 struct AVL *stree;
922 stree = pop_stree(&default_stack);
923 if (stree) {
924 free_stree(&stree);
925 return 1;
927 return 0;
930 static struct named_stree *alloc_named_stree(const char *name, struct AVL *stree)
932 struct named_stree *named_stree = __alloc_named_stree(0);
934 named_stree->name = (char *)name;
935 named_stree->stree = stree;
936 return named_stree;
939 void __save_gotos(const char *name)
941 struct AVL **stree;
942 struct AVL *clone;
944 stree = get_named_stree(goto_stack, name);
945 if (stree) {
946 merge_stree(stree, cur_stree);
947 return;
948 } else {
949 struct named_stree *named_stree;
951 clone = clone_stree(cur_stree);
952 named_stree = alloc_named_stree(name, clone);
953 add_ptr_list(&goto_stack, named_stree);
957 void __merge_gotos(const char *name)
959 struct AVL **stree;
961 stree = get_named_stree(goto_stack, name);
962 if (stree)
963 merge_stree(&cur_stree, *stree);