smatch_extra: fix (foo != 42) { ...
[smatch.git] / smatch_extra.h
blobfd262f8c0b000ec9d76873de6e6ad9429527b7ef
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_extra_helper.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, int 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, int 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 struct sm_state *__extra_pre_loop_hook_before(struct statement *iterator_pre_statement);
38 int __iterator_unchanged(struct sm_state *sm, struct statement *iterator);
39 void __extra_pre_loop_hook_after(struct sm_state *sm,
40 struct statement *iterator,
41 struct expression *condition);
43 /* also implemented in smatch_extra */
44 struct smatch_state *alloc_extra_state(int val);
45 struct smatch_state *alloc_extra_state_range_list(struct range_list *rl);
46 struct smatch_state *add_filter(struct smatch_state *orig, long long filter);
47 struct smatch_state *extra_undefined();
49 struct data_info *alloc_dinfo_range(long long min, long long max);
50 struct data_info *alloc_dinfo_range_list(struct range_list *rl);
51 struct range_list *range_list_union(struct range_list *one, struct range_list *two);
52 long long get_dinfo_min(struct data_info *dinfo);
53 long long get_dinfo_max(struct data_info *dinfo);
54 long long get_single_value_from_range(struct data_info *dinfo);
56 void function_comparison(int comparison, struct expression *expr, long long value, int left);
58 int true_comparison_range_lr(int comparison, struct data_range *var, struct data_range *val, int left);
59 int false_comparison_range_lr(int comparison, struct data_range *var, struct data_range *val, int left);
60 struct data_range *alloc_range(long long min, long long max);
61 void tack_on(struct range_list **list, struct data_range *drange);
62 int in_list_exact(struct range_list *list, struct data_range *drange);
64 struct smatch_state *alloc_extra_state_range(long long min, long long max);
66 void push_range_list(struct range_list_stack **rl_stack, struct range_list *rl);
67 struct range_list *pop_range_list(struct range_list_stack **rl_stack);
68 struct range_list *top_range_list(struct range_list_stack *rl_stack);
69 void filter_top_range_list(struct range_list_stack **rl_stack, long long num);