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
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
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.
37 #include "smatch_slist.h"
38 #include "smatch_extra.h"
40 struct smatch_state undefined
= { .name
= "undefined" };
41 struct smatch_state ghost
= { .name
= "ghost" };
42 struct smatch_state merged
= { .name
= "merged" };
43 struct smatch_state true_state
= { .name
= "true" };
44 struct smatch_state false_state
= { .name
= "false" };
46 static struct stree
*cur_stree
; /* current states */
48 static struct stree_stack
*true_stack
; /* states after a t/f branch */
49 static struct stree_stack
*false_stack
;
50 static struct stree_stack
*pre_cond_stack
; /* states before a t/f branch */
52 static struct stree_stack
*cond_true_stack
; /* states affected by a branch */
53 static struct stree_stack
*cond_false_stack
;
55 static struct stree_stack
*fake_cur_stree_stack
;
58 static struct stree_stack
*break_stack
;
59 static struct stree_stack
*switch_stack
;
60 static struct range_list_stack
*remaining_cases
;
61 static struct stree_stack
*default_stack
;
62 static struct stree_stack
*continue_stack
;
64 static struct named_stree_stack
*goto_stack
;
66 static struct ptr_list
*backup
;
70 void __print_cur_stree(void)
72 __print_stree(cur_stree
);
82 struct sm_state
*set_state(int owner
, const char *name
, struct symbol
*sym
, struct smatch_state
*state
)
90 sm_msg("Smatch Internal Error: cur_stree is read only.");
92 if (option_debug
|| strcmp(check_name(owner
), option_debug_check
) == 0) {
93 struct smatch_state
*s
;
95 s
= get_state(owner
, name
, sym
);
97 sm_msg("%s new [%s] '%s' %s", __func__
,
98 check_name(owner
), name
, show_state(state
));
100 sm_msg("%s change [%s] '%s' %s => %s",
101 __func__
, check_name(owner
), name
, show_state(s
),
105 if (owner
!= -1 && unreachable())
108 if (fake_cur_stree_stack
)
109 set_state_stree_stack(&fake_cur_stree_stack
, owner
, name
, sym
, state
);
111 ret
= set_state_stree(&cur_stree
, owner
, name
, sym
, state
);
116 struct sm_state
*set_state_expr(int owner
, struct expression
*expr
, struct smatch_state
*state
)
120 struct sm_state
*ret
= NULL
;
122 expr
= strip_expr(expr
);
123 name
= expr_to_var_sym(expr
, &sym
);
126 ret
= set_state(owner
, name
, sym
, state
);
132 void __swap_cur_stree(struct stree
*stree
)
134 free_stree(&cur_stree
);
138 void __push_fake_cur_stree(void)
140 push_stree(&fake_cur_stree_stack
, NULL
);
141 __save_pre_cond_states();
144 struct stree
*__pop_fake_cur_stree(void)
146 if (!fake_cur_stree_stack
)
147 sm_msg("INTERNAL error: popping too many fake cur strees.");
148 __use_pre_cond_states();
149 return pop_stree(&fake_cur_stree_stack
);
152 void __free_fake_cur_stree(void)
156 stree
= __pop_fake_cur_stree();
160 void __set_fake_cur_stree_fast(struct stree
*stree
)
162 push_stree(&pre_cond_stack
, cur_stree
);
167 void __pop_fake_cur_stree_fast(void)
169 cur_stree
= pop_stree(&pre_cond_stack
);
173 void __merge_stree_into_cur(struct stree
*stree
)
176 struct sm_state
*orig
;
177 struct sm_state
*merged
;
179 FOR_EACH_SM(stree
, sm
) {
180 orig
= get_sm_state(sm
->owner
, sm
->name
, sm
->sym
);
182 merged
= merge_sm_states(orig
, sm
);
186 } END_FOR_EACH_SM(sm
);
189 void __set_sm(struct sm_state
*sm
)
192 sm_msg("Smatch Internal Error: cur_stree is read only.");
195 strcmp(check_name(sm
->owner
), option_debug_check
) == 0) {
196 struct smatch_state
*s
;
198 s
= get_state(sm
->owner
, sm
->name
, sm
->sym
);
200 sm_msg("%s new %s", __func__
, show_sm(sm
));
202 sm_msg("%s change %s (was %s)", __func__
, show_sm(sm
),
209 if (fake_cur_stree_stack
)
210 overwrite_sm_state_stree_stack(&fake_cur_stree_stack
, sm
);
212 overwrite_sm_state_stree(&cur_stree
, sm
);
215 void __set_sm_cur_stree(struct sm_state
*sm
)
218 sm_msg("Smatch Internal Error: cur_stree is read only.");
221 strcmp(check_name(sm
->owner
), option_debug_check
) == 0) {
222 struct smatch_state
*s
;
224 s
= get_state(sm
->owner
, sm
->name
, sm
->sym
);
226 sm_msg("%s new %s", __func__
, show_sm(sm
));
228 sm_msg("%s change %s (was %s)",
229 __func__
, show_sm(sm
), show_state(s
));
235 overwrite_sm_state_stree(&cur_stree
, sm
);
238 void __set_sm_fake_stree(struct sm_state
*sm
)
241 sm_msg("Smatch Internal Error: cur_stree is read only.");
244 strcmp(check_name(sm
->owner
), option_debug_check
) == 0) {
245 struct smatch_state
*s
;
247 s
= get_state(sm
->owner
, sm
->name
, sm
->sym
);
249 sm_msg("%s new %s", __func__
, show_sm(sm
));
251 sm_msg("%s change %s (was %s)",
252 __func__
, show_sm(sm
), show_state(s
));
258 overwrite_sm_state_stree_stack(&fake_cur_stree_stack
, sm
);
261 struct smatch_state
*get_state(int owner
, const char *name
, struct symbol
*sym
)
263 __get_state_hook(owner
, name
, sym
);
265 return get_state_stree(cur_stree
, owner
, name
, sym
);
268 struct smatch_state
*get_state_expr(int owner
, struct expression
*expr
)
272 struct smatch_state
*ret
= NULL
;
274 expr
= strip_expr(expr
);
275 name
= expr_to_var_sym(expr
, &sym
);
278 ret
= get_state(owner
, name
, sym
);
284 struct state_list
*get_possible_states(int owner
, const char *name
, struct symbol
*sym
)
286 struct sm_state
*sms
;
288 sms
= get_sm_state_stree(cur_stree
, owner
, name
, sym
);
290 return sms
->possible
;
294 struct state_list
*get_possible_states_expr(int owner
, struct expression
*expr
)
298 struct state_list
*ret
= NULL
;
300 expr
= strip_expr(expr
);
301 name
= expr_to_var_sym(expr
, &sym
);
304 ret
= get_possible_states(owner
, name
, sym
);
310 struct sm_state
*get_sm_state(int owner
, const char *name
, struct symbol
*sym
)
312 return get_sm_state_stree(cur_stree
, owner
, name
, sym
);
315 struct sm_state
*get_sm_state_expr(int owner
, struct expression
*expr
)
319 struct sm_state
*ret
= NULL
;
321 expr
= strip_expr(expr
);
322 name
= expr_to_var_sym(expr
, &sym
);
325 ret
= get_sm_state(owner
, name
, sym
);
331 void delete_state(int owner
, const char *name
, struct symbol
*sym
)
333 delete_state_stree(&cur_stree
, owner
, name
, sym
);
334 if (cond_true_stack
) {
335 delete_state_stree_stack(&pre_cond_stack
, owner
, name
, sym
);
336 delete_state_stree_stack(&cond_true_stack
, owner
, name
, sym
);
337 delete_state_stree_stack(&cond_false_stack
, owner
, name
, sym
);
341 void delete_state_expr(int owner
, struct expression
*expr
)
346 expr
= strip_expr(expr
);
347 name
= expr_to_var_sym(expr
, &sym
);
350 delete_state(owner
, name
, sym
);
355 static void delete_all_states_stree_sym(struct stree
**stree
, struct symbol
*sym
)
357 struct state_list
*slist
= NULL
;
360 FOR_EACH_SM(*stree
, sm
) {
362 add_ptr_list(&slist
, sm
);
363 } END_FOR_EACH_SM(sm
);
365 FOR_EACH_PTR(slist
, sm
) {
366 delete_state_stree(stree
, sm
->owner
, sm
->name
, sm
->sym
);
367 } END_FOR_EACH_PTR(sm
);
372 static void delete_all_states_stree_stack_sym(struct stree_stack
**stack
, struct symbol
*sym
)
379 stree
= pop_stree(stack
);
380 delete_all_states_stree_sym(&stree
, sym
);
381 push_stree(stack
, stree
);
384 void __delete_all_states_sym(struct symbol
*sym
)
386 delete_all_states_stree_sym(&cur_stree
, sym
);
388 delete_all_states_stree_stack_sym(&true_stack
, sym
);
389 delete_all_states_stree_stack_sym(&true_stack
, sym
);
390 delete_all_states_stree_stack_sym(&false_stack
, sym
);
391 delete_all_states_stree_stack_sym(&pre_cond_stack
, sym
);
392 delete_all_states_stree_stack_sym(&cond_true_stack
, sym
);
393 delete_all_states_stree_stack_sym(&cond_false_stack
, sym
);
394 delete_all_states_stree_stack_sym(&fake_cur_stree_stack
, sym
);
395 delete_all_states_stree_stack_sym(&break_stack
, sym
);
396 delete_all_states_stree_stack_sym(&switch_stack
, sym
);
397 delete_all_states_stree_stack_sym(&continue_stack
, sym
);
400 * deleting from the goto stack is problematic because we don't know
401 * if the label is in scope and also we need the value for --two-passes.
405 struct stree
*get_all_states_from_stree(int owner
, struct stree
*source
)
407 struct stree
*ret
= NULL
;
408 struct sm_state
*tmp
;
410 FOR_EACH_SM(source
, tmp
) {
411 if (tmp
->owner
== owner
)
412 avl_insert(&ret
, tmp
);
413 } END_FOR_EACH_SM(tmp
);
418 struct stree
*get_all_states_stree(int owner
)
420 return get_all_states_from_stree(owner
, cur_stree
);
423 struct stree
*__get_cur_stree(void)
428 int is_reachable(void)
435 void set_true_false_states(int owner
, const char *name
, struct symbol
*sym
,
436 struct smatch_state
*true_state
,
437 struct smatch_state
*false_state
)
440 sm_msg("Smatch Internal Error: cur_stree is read only.");
442 if (option_debug
|| strcmp(check_name(owner
), option_debug_check
) == 0) {
443 struct smatch_state
*tmp
;
445 tmp
= get_state(owner
, name
, sym
);
446 sm_msg("%s [%s] '%s'. Was %s. Now T:%s F:%s", __func__
,
447 check_name(owner
), name
, show_state(tmp
),
448 show_state(true_state
), show_state(false_state
));
454 if (!cond_false_stack
|| !cond_true_stack
) {
455 printf("Error: missing true/false stacks\n");
460 set_state_stree_stack(&cond_true_stack
, owner
, name
, sym
, true_state
);
462 set_state_stree_stack(&cond_false_stack
, owner
, name
, sym
, false_state
);
465 void set_true_false_states_expr(int owner
, struct expression
*expr
,
466 struct smatch_state
*true_state
,
467 struct smatch_state
*false_state
)
472 expr
= strip_expr(expr
);
473 name
= expr_to_var_sym(expr
, &sym
);
476 set_true_false_states(owner
, name
, sym
, true_state
, false_state
);
481 void __set_true_false_sm(struct sm_state
*true_sm
, struct sm_state
*false_sm
)
487 if (!true_sm
&& !false_sm
)
493 owner
= true_sm
? true_sm
->owner
: false_sm
->owner
;
494 name
= true_sm
? true_sm
->name
: false_sm
->name
;
495 sym
= true_sm
? true_sm
->sym
: false_sm
->sym
;
496 if (option_debug
|| strcmp(check_name(owner
), option_debug_check
) == 0) {
497 struct smatch_state
*tmp
;
499 tmp
= get_state(owner
, name
, sym
);
500 sm_msg("%s [%s] '%s'. Was %s. Now T:%s F:%s", __func__
,
501 check_name(owner
), name
, show_state(tmp
),
502 show_state(true_sm
? true_sm
->state
: NULL
),
503 show_state(false_sm
? false_sm
->state
: NULL
));
506 if (!cond_false_stack
|| !cond_true_stack
) {
507 printf("Error: missing true/false stacks\n");
512 overwrite_sm_state_stree_stack(&cond_true_stack
, true_sm
);
514 overwrite_sm_state_stree_stack(&cond_false_stack
, false_sm
);
517 void nullify_path(void)
519 if (fake_cur_stree_stack
) {
520 __free_fake_cur_stree();
521 __push_fake_cur_stree();
523 free_stree(&cur_stree
);
526 void __match_nullify_path_hook(const char *fn
, struct expression
*expr
,
533 * At the start of every function we mark the path
534 * as unnull. That way there is always at least one state
535 * in the cur_stree until nullify_path is called. This
536 * is used in merge_slist() for the first null check.
538 void __unnullify_path(void)
541 set_state(-1, "unnull_path", NULL
, &true_state
);
544 int __path_is_null(void)
551 static void check_stree_stack_free(struct stree_stack
**stack
)
554 sm_msg("smatch internal error: stack not empty");
555 free_stack_and_strees(stack
);
559 void save_all_states(void)
561 __add_ptr_list(&backup
, cur_stree
, 0);
564 __add_ptr_list(&backup
, true_stack
, 0);
566 __add_ptr_list(&backup
, false_stack
, 0);
568 __add_ptr_list(&backup
, pre_cond_stack
, 0);
569 pre_cond_stack
= NULL
;
571 __add_ptr_list(&backup
, cond_true_stack
, 0);
572 cond_true_stack
= NULL
;
573 __add_ptr_list(&backup
, cond_false_stack
, 0);
574 cond_false_stack
= NULL
;
576 __add_ptr_list(&backup
, fake_cur_stree_stack
, 0);
577 fake_cur_stree_stack
= NULL
;
579 __add_ptr_list(&backup
, break_stack
, 0);
581 __add_ptr_list(&backup
, switch_stack
, 0);
583 __add_ptr_list(&backup
, remaining_cases
, 0);
584 remaining_cases
= NULL
;
585 __add_ptr_list(&backup
, default_stack
, 0);
586 default_stack
= NULL
;
587 __add_ptr_list(&backup
, continue_stack
, 0);
588 continue_stack
= NULL
;
590 __add_ptr_list(&backup
, goto_stack
, 0);
594 static void *pop_backup(void)
598 ret
= last_ptr_list(backup
);
599 delete_ptr_list_last(&backup
);
603 void restore_all_states(void)
605 goto_stack
= pop_backup();
607 continue_stack
= pop_backup();
608 default_stack
= pop_backup();
609 remaining_cases
= pop_backup();
610 switch_stack
= pop_backup();
611 break_stack
= pop_backup();
613 fake_cur_stree_stack
= pop_backup();
615 cond_false_stack
= pop_backup();
616 cond_true_stack
= pop_backup();
618 pre_cond_stack
= pop_backup();
619 false_stack
= pop_backup();
620 true_stack
= pop_backup();
622 cur_stree
= pop_backup();
625 void free_goto_stack(void)
627 struct named_stree
*named_stree
;
629 FOR_EACH_PTR(goto_stack
, named_stree
) {
630 free_stree(&named_stree
->stree
);
631 } END_FOR_EACH_PTR(named_stree
);
632 __free_ptr_list((struct ptr_list
**)&goto_stack
);
635 void clear_all_states(void)
638 check_stree_stack_free(&true_stack
);
639 check_stree_stack_free(&false_stack
);
640 check_stree_stack_free(&pre_cond_stack
);
641 check_stree_stack_free(&cond_true_stack
);
642 check_stree_stack_free(&cond_false_stack
);
643 check_stree_stack_free(&break_stack
);
644 check_stree_stack_free(&switch_stack
);
645 check_stree_stack_free(&continue_stack
);
646 check_stree_stack_free(&fake_cur_stree_stack
);
650 free_every_single_sm_state();
653 void __push_cond_stacks(void)
655 push_stree(&cond_true_stack
, NULL
);
656 push_stree(&cond_false_stack
, NULL
);
657 __push_fake_cur_stree();
660 void __fold_in_set_states(void)
662 struct stree
*new_states
;
665 new_states
= __pop_fake_cur_stree();
666 FOR_EACH_SM(new_states
, sm
) {
668 __set_true_false_sm(sm
, sm
);
669 } END_FOR_EACH_SM(sm
);
670 free_stree(&new_states
);
673 void __free_set_states(void)
675 struct stree
*new_states
;
677 new_states
= __pop_fake_cur_stree();
678 free_stree(&new_states
);
681 struct stree
*__copy_cond_true_states(void)
685 ret
= pop_stree(&cond_true_stack
);
686 push_stree(&cond_true_stack
, clone_stree(ret
));
690 struct stree
*__copy_cond_false_states(void)
694 ret
= pop_stree(&cond_false_stack
);
695 push_stree(&cond_false_stack
, clone_stree(ret
));
699 struct stree
*__pop_cond_true_stack(void)
701 return pop_stree(&cond_true_stack
);
704 struct stree
*__pop_cond_false_stack(void)
706 return pop_stree(&cond_false_stack
);
710 * This combines the pre cond states with either the true or false states.
712 * a = kmalloc() ; if (a !! foo(a)
713 * In the pre state a is possibly null. In the true state it is non null.
714 * In the false state it is null. Combine the pre and the false to get
715 * that when we call 'foo', 'a' is null.
717 static void __use_cond_stack(struct stree_stack
**stack
)
721 free_stree(&cur_stree
);
723 cur_stree
= pop_stree(&pre_cond_stack
);
724 push_stree(&pre_cond_stack
, clone_stree(cur_stree
));
726 stree
= pop_stree(stack
);
727 overwrite_stree(stree
, &cur_stree
);
728 push_stree(stack
, stree
);
731 void __use_pre_cond_states(void)
733 free_stree(&cur_stree
);
734 cur_stree
= pop_stree(&pre_cond_stack
);
737 void __use_cond_true_states(void)
739 __use_cond_stack(&cond_true_stack
);
742 void __use_cond_false_states(void)
744 __use_cond_stack(&cond_false_stack
);
747 void __negate_cond_stacks(void)
749 struct stree
*old_false
, *old_true
;
751 __use_cond_stack(&cond_false_stack
);
752 old_false
= pop_stree(&cond_false_stack
);
753 old_true
= pop_stree(&cond_true_stack
);
754 push_stree(&cond_false_stack
, old_true
);
755 push_stree(&cond_true_stack
, old_false
);
758 void __and_cond_states(void)
760 and_stree_stack(&cond_true_stack
);
761 or_stree_stack(&pre_cond_stack
, cur_stree
, &cond_false_stack
);
764 void __or_cond_states(void)
766 or_stree_stack(&pre_cond_stack
, cur_stree
, &cond_true_stack
);
767 and_stree_stack(&cond_false_stack
);
770 void __save_pre_cond_states(void)
772 push_stree(&pre_cond_stack
, clone_stree(cur_stree
));
775 void __discard_pre_cond_states(void)
779 tmp
= pop_stree(&pre_cond_stack
);
783 struct stree
*__get_true_states(void)
785 return clone_stree(top_stree(cond_true_stack
));
788 struct stree
*__get_false_states(void)
790 return clone_stree(top_stree(cond_false_stack
));
793 void __use_cond_states(void)
795 struct stree
*pre
, *pre_clone
, *true_states
, *false_states
;
797 pre
= pop_stree(&pre_cond_stack
);
798 pre_clone
= clone_stree(pre
);
800 true_states
= pop_stree(&cond_true_stack
);
801 overwrite_stree(true_states
, &pre
);
802 free_stree(&true_states
);
803 /* we use the true states right away */
804 free_stree(&cur_stree
);
807 false_states
= pop_stree(&cond_false_stack
);
808 overwrite_stree(false_states
, &pre_clone
);
809 free_stree(&false_states
);
810 push_stree(&false_stack
, pre_clone
);
813 void __push_true_states(void)
815 push_stree(&true_stack
, clone_stree(cur_stree
));
818 void __use_false_states(void)
820 free_stree(&cur_stree
);
821 cur_stree
= pop_stree(&false_stack
);
824 void __discard_false_states(void)
828 stree
= pop_stree(&false_stack
);
832 void __merge_false_states(void)
836 stree
= pop_stree(&false_stack
);
837 merge_stree(&cur_stree
, stree
);
841 static void update_fake_stree_with_merged(void)
844 struct state_list
*slist
= NULL
;
845 struct sm_state
*sm
, *new;
847 if (!fake_cur_stree_stack
)
849 stree
= pop_stree(&fake_cur_stree_stack
);
850 FOR_EACH_SM(stree
, sm
) {
851 new = get_sm_state(sm
->owner
, sm
->name
, sm
->sym
);
854 add_ptr_list(&slist
, new);
855 } END_FOR_EACH_SM(sm
);
857 FOR_EACH_PTR(slist
, sm
) {
858 overwrite_sm_state_stree(&stree
, sm
);
859 } END_FOR_EACH_PTR(sm
);
862 push_stree(&fake_cur_stree_stack
, stree
);
865 void __merge_true_states(void)
869 stree
= pop_stree(&true_stack
);
870 merge_stree(&cur_stree
, stree
);
871 update_fake_stree_with_merged();
875 void __push_continues(void)
877 push_stree(&continue_stack
, NULL
);
880 void __discard_continues(void)
884 stree
= pop_stree(&continue_stack
);
888 void __process_continues(void)
892 stree
= pop_stree(&continue_stack
);
894 stree
= clone_stree(cur_stree
);
896 merge_stree(&stree
, cur_stree
);
898 push_stree(&continue_stack
, stree
);
901 void __merge_continues(void)
905 stree
= pop_stree(&continue_stack
);
906 merge_stree(&cur_stree
, stree
);
910 void __push_breaks(void)
912 push_stree(&break_stack
, NULL
);
915 void __process_breaks(void)
919 stree
= pop_stree(&break_stack
);
921 stree
= clone_stree(cur_stree
);
923 merge_stree(&stree
, cur_stree
);
925 push_stree(&break_stack
, stree
);
928 int __has_breaks(void)
933 stree
= pop_stree(&break_stack
);
935 push_stree(&break_stack
, stree
);
939 void __merge_breaks(void)
943 stree
= pop_stree(&break_stack
);
944 merge_stree(&cur_stree
, stree
);
948 void __use_breaks(void)
950 free_stree(&cur_stree
);
951 cur_stree
= pop_stree(&break_stack
);
954 void __save_switch_states(struct expression
*switch_expr
)
956 struct range_list
*rl
;
958 get_absolute_rl(switch_expr
, &rl
);
960 push_rl(&remaining_cases
, rl
);
961 push_stree(&switch_stack
, clone_stree(cur_stree
));
964 void __merge_switches(struct expression
*switch_expr
, struct range_list
*case_rl
)
967 struct stree
*implied_stree
;
969 stree
= pop_stree(&switch_stack
);
970 implied_stree
= __implied_case_stree(switch_expr
, case_rl
, &remaining_cases
, &stree
);
971 merge_stree(&cur_stree
, implied_stree
);
972 free_stree(&implied_stree
);
973 push_stree(&switch_stack
, stree
);
976 void __discard_switches(void)
980 pop_rl(&remaining_cases
);
981 stree
= pop_stree(&switch_stack
);
985 void __push_default(void)
987 push_stree(&default_stack
, NULL
);
990 void __set_default(void)
992 set_state_stree_stack(&default_stack
, 0, "has_default", NULL
, &true_state
);
995 int __pop_default(void)
999 stree
= pop_stree(&default_stack
);
1007 static struct named_stree
*alloc_named_stree(const char *name
, struct symbol
*sym
, struct stree
*stree
)
1009 struct named_stree
*named_stree
= __alloc_named_stree(0);
1011 named_stree
->name
= (char *)name
;
1012 named_stree
->stree
= stree
;
1013 named_stree
->sym
= sym
;
1017 void __save_gotos(const char *name
, struct symbol
*sym
)
1019 struct stree
**stree
;
1020 struct stree
*clone
;
1022 stree
= get_named_stree(goto_stack
, name
, sym
);
1024 merge_stree(stree
, cur_stree
);
1027 struct named_stree
*named_stree
;
1029 clone
= clone_stree(cur_stree
);
1030 named_stree
= alloc_named_stree(name
, sym
, clone
);
1031 add_ptr_list(&goto_stack
, named_stree
);
1035 void __merge_gotos(const char *name
, struct symbol
*sym
)
1037 struct stree
**stree
;
1039 stree
= get_named_stree(goto_stack
, name
, sym
);
1041 merge_stree(&cur_stree
, *stree
);