2 * sparse/smatch_start_states.c
4 * Copyright (C) 2012 Oracle.
6 * Licensed under the Open Software License version 1.1
11 * Store the states at the start of the function because this is something that
12 * is used in a couple places.
17 #include "smatch_slist.h"
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
);
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)
50 void register_start_states(int 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
);