extra: assume indexes are in bounds
[smatch.git] / smatch_start_states.c
bloba039377c342a0d384cfadea24dfcd2e769539a29
1 /*
2 * sparse/smatch_start_states.c
4 * Copyright (C) 2012 Oracle.
6 * Licensed under the Open Software License version 1.1
8 */
11 * Store the states at the start of the function because this is something that
12 * is used in a couple places.
16 #include "smatch.h"
17 #include "smatch_slist.h"
19 static int my_id;
21 static struct state_list *start_states;
22 static struct state_list_stack *saved_stack;
23 static void save_start_states(struct statement *stmt)
25 start_states = clone_slist(__get_cur_slist());
28 static void match_save_states(struct expression *expr)
30 push_slist(&saved_stack, start_states);
31 start_states = NULL;
34 static void match_restore_states(struct expression *expr)
36 free_slist(&start_states);
37 start_states = pop_slist(&saved_stack);
40 static void match_end_func(void)
42 free_slist(&start_states);
45 struct state_list *get_start_states(void)
47 return start_states;
50 void register_start_states(int id)
52 my_id = id;
54 add_hook(&save_start_states, AFTER_DEF_HOOK);
55 add_hook(&match_save_states, INLINE_FN_START);
56 add_hook(&match_restore_states, INLINE_FN_END);
57 add_hook(&match_end_func, END_FUNC_HOOK);