Add a merge hook. Handle the situations like:
[smatch.git] / smatch_slist.h
blobd4d8ec0dbb3c86022f2f416fa2ad2be69d05bdf4
1 struct state_history {
2 unsigned int loc;
3 };
4 DECLARE_PTR_LIST(history_list, struct state_history);
6 struct sm_state {
7 char *name;
8 unsigned int owner;
9 struct symbol *sym;
10 struct smatch_state *state;
11 struct history_list *line_history;
12 struct state_list_stack *pools;
15 DECLARE_ALLOCATOR(sm_state);
16 DECLARE_PTR_LIST(state_list, struct sm_state);
17 DECLARE_PTR_LIST(state_list_stack, struct state_list);
18 struct named_slist {
19 char *name;
20 struct state_list *slist;
22 DECLARE_ALLOCATOR(named_slist);
23 DECLARE_PTR_LIST(slist_stack, struct named_slist);
25 extern struct state_list_stack *implied_pools;
27 void add_history(struct sm_state *state);
28 struct sm_state *alloc_state(const char *name, int owner,
29 struct symbol *sym,
30 struct smatch_state *state);
32 struct sm_state *clone_state(struct sm_state *s);
33 struct state_list *clone_slist(struct state_list *from_slist);
35 struct smatch_state *merge_states(const char *name, int owner,
36 struct symbol *sym,
37 struct smatch_state *state1,
38 struct smatch_state *state2);
40 struct smatch_state *get_state_slist(struct state_list *slist, const char *name, int owner,
41 struct symbol *sym);
43 struct sm_state *get_sm_state_slist(struct state_list *slist, const char *name, int owner,
44 struct symbol *sym);
46 void set_state_slist(struct state_list **slist, const char *name, int owner,
47 struct symbol *sym, struct smatch_state *state);
49 void merge_state_slist(struct state_list **slist, const char *name, int owner,
50 struct symbol *sym, struct smatch_state *state);
52 void delete_state_slist(struct state_list **slist, const char *name, int owner,
53 struct symbol *sym);
55 struct smatch_state *get_state_slist(struct state_list *slist, const char *name, int owner,
56 struct symbol *sym);
58 void push_slist(struct state_list_stack **list_stack, struct state_list *slist);
60 struct state_list *pop_slist(struct state_list_stack **list_stack);
62 void del_slist(struct state_list **slist);
64 void del_slist_stack(struct state_list_stack **slist_stack);
66 void set_state_stack(struct state_list_stack **stack, const char *name,
67 int owner, struct symbol *sym, struct smatch_state *state);
69 struct smatch_state *get_state_stack(struct state_list_stack *stack, const char *name,
70 int owner, struct symbol *sym);
72 void merge_slist(struct state_list **to, struct state_list *slist);
73 void filter(struct state_list **slist, struct state_list *filter);
74 void and_slist_stack(struct state_list_stack **slist_stack);
76 void or_slist_stack(struct state_list_stack **slist_stack);
78 struct state_list **get_slist_from_slist_stack(struct slist_stack *stack,
79 const char *name);
81 void overwrite_slist(struct state_list *from, struct state_list **to);