dereferences_param: mark more parameters as dereferenced
[smatch.git] / smatch_start_states.c
blob1c3d4b3809360275b83b94bc664fde91c4a9dc5b
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 stree *start_states;
30 static struct stree_stack *saved_stack;
31 static void save_start_states(struct statement *stmt)
33 start_states = clone_stree(__get_cur_stree());
36 static void match_save_states(struct expression *expr)
38 push_stree(&saved_stack, start_states);
39 start_states = NULL;
42 static void match_restore_states(struct expression *expr)
44 free_stree(&start_states);
45 start_states = pop_stree(&saved_stack);
48 static void match_end_func(void)
50 free_stree(&start_states);
53 struct stree *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, AFTER_FUNC_HOOK);