2 * sparse/smatch_extra.h
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
14 DECLARE_PTR_LIST(range_list
, struct data_range
);
15 DECLARE_PTR_LIST(range_list_stack
, struct range_list
);
23 DECLARE_PTR_LIST(related_list
, struct relation
);
26 struct related_list
*related
;
28 struct range_list
*value_ranges
;
30 DECLARE_ALLOCATOR(data_info
);
32 extern struct string_list
*__ignored_macros
;
34 /* these are implimented in smatch_ranges.c */
35 int is_whole_range_rl(struct range_list
*rl
);
36 long long rl_min(struct range_list
*rl
);
37 long long rl_max(struct range_list
*rl
);
38 struct data_range
*alloc_range_perm(long long min
, long long max
);
39 struct range_list
*alloc_range_list(long long min
, long long max
);
40 struct range_list
*whole_range_list(void);
41 void add_range(struct range_list
**list
, long long min
, long long max
);
42 int range_lists_equiv(struct range_list
*one
, struct range_list
*two
);
43 struct range_list
*invert_range_list(struct range_list
*orig
);
44 int true_comparison_range(struct data_range
*left
, int comparison
, struct data_range
*right
);
46 int possibly_true(struct expression
*left
, int comparison
, struct expression
*right
);
47 int possibly_true_range_lists(struct range_list
*left_ranges
, int comparison
, struct range_list
*right_ranges
);
48 int possibly_true_range_lists_rl(int comparison
, struct range_list
*a
, struct range_list
*b
, int left
);
50 int possibly_false(struct expression
*left
, int comparison
, struct expression
*right
);
51 int possibly_false_range_lists(struct range_list
*left_ranges
, int comparison
, struct range_list
*right_ranges
);
52 int possibly_false_range_lists_rl(int comparison
, struct range_list
*a
, struct range_list
*b
, int left
);
54 void free_range_list(struct range_list
**rlist
);
55 void free_data_info_allocs(void);
56 struct range_list
*clone_range_list(struct range_list
*list
);
57 struct range_list
*clone_permanent(struct range_list
*list
);
58 char *show_ranges(struct range_list
*list
);
59 void get_value_ranges(char *value
, struct range_list
**rl
);
61 struct range_list
*remove_range(struct range_list
*list
, long long min
, long long max
);
63 /* used in smatch_slist. implemented in smatch_extra.c */
64 int implied_not_equal(struct expression
*expr
, long long val
);
65 struct sm_state
*__extra_handle_canonical_loops(struct statement
*loop
, struct state_list
**slist
);
66 int __iterator_unchanged(struct sm_state
*sm
);
67 void __extra_pre_loop_hook_after(struct sm_state
*sm
,
68 struct statement
*iterator
,
69 struct expression
*condition
);
71 /* also implemented in smatch_extra */
72 struct smatch_state
*clone_estate(struct smatch_state
*state
);
73 struct sm_state
*set_extra_mod(const char *name
, struct symbol
*sym
, struct smatch_state
*state
);
74 struct sm_state
*set_extra_expr_mod(struct expression
*expr
, struct smatch_state
*state
);
75 void set_extra_expr_nomod(struct expression
*expr
, struct smatch_state
*state
);
76 struct smatch_state
*alloc_estate_empty(void);
77 struct smatch_state
*alloc_estate(long long val
);
78 struct smatch_state
*alloc_estate_range_list(struct range_list
*rl
);
79 struct data_info
*get_dinfo(struct smatch_state
*state
);
80 struct range_list
*estate_ranges(struct smatch_state
*state
);
81 struct related_list
*estate_related(struct smatch_state
*state
);
82 long long estate_min(struct smatch_state
*state
);
83 long long estate_max(struct smatch_state
*state
);
84 struct smatch_state
*add_filter(struct smatch_state
*orig
, long long filter
);
85 struct smatch_state
*extra_undefined(void);
87 struct range_list
*range_list_union(struct range_list
*one
, struct range_list
*two
);
88 int estate_get_single_value(struct smatch_state
*estate
, long long *val
);
90 void function_comparison(int comparison
, struct expression
*expr
, long long value
, int left
);
92 int true_comparison_range_lr(int comparison
, struct data_range
*var
, struct data_range
*val
, int left
);
93 int false_comparison_range_lr(int comparison
, struct data_range
*var
, struct data_range
*val
, int left
);
94 struct data_range
*alloc_range(long long min
, long long max
);
95 void tack_on(struct range_list
**list
, struct data_range
*drange
);
96 int in_list_exact(struct range_list
*list
, struct data_range
*drange
);
98 struct smatch_state
*alloc_estate_range(long long min
, long long max
);
100 void push_range_list(struct range_list_stack
**rl_stack
, struct range_list
*rl
);
101 struct range_list
*pop_range_list(struct range_list_stack
**rl_stack
);
102 struct range_list
*top_range_list(struct range_list_stack
*rl_stack
);
103 void filter_top_range_list(struct range_list_stack
**rl_stack
, long long num
);
104 int get_implied_range_list(struct expression
*expr
, struct range_list
**rl
);
105 int is_whole_range(struct smatch_state
*state
);
107 /* smatch_expressions.c */
108 struct expression
*zero_expr();
109 struct expression
*value_expr(long long val
);
111 /* implemented in smatch_constraints */
112 void set_equiv(struct expression
*left
, struct expression
*right
);
113 struct relation
*get_common_relationship(struct smatch_state
*estate
, int op
,
114 const char *name
, struct symbol
*sym
);
115 struct related_list
*clone_related_list(struct related_list
*related
);
116 void add_related(struct smatch_state
*state
, int op
, const char *name
, struct symbol
*sym
);
117 void add_equiv(struct smatch_state
*state
, const char *name
, struct symbol
*sym
);
118 void remove_from_equiv(const char *name
, struct symbol
*sym
);
119 void remove_from_equiv_expr(struct expression
*expr
);
120 void set_equiv_state_expr(int id
, struct expression
*expr
, struct smatch_state
*state
);