smatch.c: use strncpy() instead of strcpy()
[smatch.git] / smatch_extra.h
blob4281c2a2e5798bb744ebaa6c3288c60c46d47be7
1 /*
2 * sparse/smatch_extra.h
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 enum data_type {
11 DATA_RANGE,
14 DECLARE_PTR_LIST(range_list, struct data_range);
15 DECLARE_PTR_LIST(range_list_stack, struct range_list);
17 struct data_info {
18 enum data_type type;
19 struct range_list *value_ranges;
21 DECLARE_ALLOCATOR(data_info);
23 /* these are implimented in smatch_ranges.c */
24 struct data_range *alloc_range_perm(long long min, long long max);
25 void add_range(struct range_list **list, long long min, long long max);
26 int true_comparison_range(struct data_range *left, int comparison, struct data_range *right);
27 int possibly_true(int comparison, struct data_info *dinfo, long long num, int left);
28 int possibly_true_range_list(int comparison, struct data_info *dinfo, struct range_list *values, int left);
29 int possibly_false(int comparison, struct data_info *dinfo, long long num, int left);
30 int possibly_false_range_list(int comparison, struct data_info *dinfo, struct range_list *values, int left);
31 void free_data_info_allocs(void);
32 struct range_list *clone_range_list(struct range_list *list);
33 char *show_ranges(struct range_list *list);
34 struct range_list *remove_range(struct range_list *list, long long min, long long max);
36 /* used in smatch_slist. implemented in smatch_extra.c */
37 int implied_not_equal(struct expression *expr, long long val);
38 struct sm_state *__extra_pre_loop_hook_before(struct statement *iterator_pre_statement);
39 int __iterator_unchanged(struct sm_state *sm, struct statement *iterator);
40 void __extra_pre_loop_hook_after(struct sm_state *sm,
41 struct statement *iterator,
42 struct expression *condition);
44 /* also implemented in smatch_extra */
45 struct smatch_state *alloc_extra_state(long long val);
46 struct smatch_state *alloc_extra_state_range_list(struct range_list *rl);
47 struct data_info *get_dinfo(struct smatch_state *state);
48 struct smatch_state *add_filter(struct smatch_state *orig, long long filter);
49 struct smatch_state *extra_undefined(void);
51 struct data_info *alloc_dinfo_range(long long min, long long max);
52 struct data_info *alloc_dinfo_range_list(struct range_list *rl);
53 struct range_list *range_list_union(struct range_list *one, struct range_list *two);
54 long long get_dinfo_min(struct data_info *dinfo);
55 long long get_dinfo_max(struct data_info *dinfo);
56 int get_single_value_from_range(struct data_info *dinfo, long long *val);
58 void function_comparison(int comparison, struct expression *expr, long long value, int left);
60 int true_comparison_range_lr(int comparison, struct data_range *var, struct data_range *val, int left);
61 int false_comparison_range_lr(int comparison, struct data_range *var, struct data_range *val, int left);
62 struct data_range *alloc_range(long long min, long long max);
63 void tack_on(struct range_list **list, struct data_range *drange);
64 int in_list_exact(struct range_list *list, struct data_range *drange);
66 struct smatch_state *alloc_extra_state_range(long long min, long long max);
68 void push_range_list(struct range_list_stack **rl_stack, struct range_list *rl);
69 struct range_list *pop_range_list(struct range_list_stack **rl_stack);
70 struct range_list *top_range_list(struct range_list_stack *rl_stack);
71 void filter_top_range_list(struct range_list_stack **rl_stack, long long num);
72 int get_implied_range_list(struct expression *expr, struct range_list **rl);