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.
25 #include "smatch_slist.h"
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
);
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)
58 void register_start_states(int 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
);