avl: change some void pointers to struct sm_state pointers
[smatch.git] / smatch_start_states.c
blob61dc14a4ff1560333e7ad9937f0248a8ed5eb2be
1 /*
2 * Copyright (C) 2012 Oracle.
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 * Store the states at the start of the function because this is something that
20 * is used in a couple places.
24 #include "smatch.h"
25 #include "smatch_slist.h"
27 static int my_id;
29 static struct state_list *start_states;
30 static struct state_list_stack *saved_stack;
31 static void save_start_states(struct statement *stmt)
33 start_states = clone_slist(__get_cur_slist());
36 static void match_save_states(struct expression *expr)
38 push_slist(&saved_stack, start_states);
39 start_states = NULL;
42 static void match_restore_states(struct expression *expr)
44 free_slist(&start_states);
45 start_states = pop_slist(&saved_stack);
48 static void match_end_func(void)
50 free_slist(&start_states);
53 struct state_list *get_start_states(void)
55 return start_states;
58 void register_start_states(int id)
60 my_id = id;
62 add_hook(&save_start_states, AFTER_DEF_HOOK);
63 add_hook(&match_save_states, INLINE_FN_START);
64 add_hook(&match_restore_states, INLINE_FN_END);
65 add_hook(&match_end_func, END_FUNC_HOOK);