Print this page
new smatch


  14  * You should have received a copy of the GNU General Public License
  15  * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16  */
  17 
  18 DECLARE_PTR_LIST(range_list, struct data_range);
  19 DECLARE_PTR_LIST(range_list_stack, struct range_list);
  20 
  21 struct relation {
  22         char *name;
  23         struct symbol *sym;
  24 };
  25 
  26 DECLARE_PTR_LIST(related_list, struct relation);
  27 
  28 struct data_info {
  29         struct related_list *related;
  30         struct range_list *value_ranges;
  31         sval_t fuzzy_max;
  32         unsigned int hard_max:1;
  33         unsigned int capped:1;

  34 };
  35 DECLARE_ALLOCATOR(data_info);
  36 
  37 extern struct string_list *__ignored_macros;
  38 
  39 /* these are implemented in smatch_ranges.c */
  40 struct range_list *rl_zero(void);
  41 struct range_list *rl_one(void);
  42 char *show_rl(struct range_list *list);
  43 int str_to_comparison_arg(const char *c, struct expression *call, int *comparison, struct expression **arg);
  44 void str_to_rl(struct symbol *type, char *value, struct range_list **rl);
  45 void call_results_to_rl(struct expression *call, struct symbol *type, const char *value, struct range_list **rl);
  46 
  47 struct data_range *alloc_range(sval_t min, sval_t max);
  48 struct data_range *alloc_range_perm(sval_t min, sval_t max);
  49 
  50 int rl_fits_in_type(struct range_list *rl, struct symbol *type);
  51 
  52 struct range_list *alloc_rl(sval_t min, sval_t max);
  53 struct range_list *clone_rl(struct range_list *list);


  56 
  57 void add_range(struct range_list **list, sval_t min, sval_t max);
  58 struct range_list *remove_range(struct range_list *list, sval_t min, sval_t max);
  59 void tack_on(struct range_list **list, struct data_range *drange);
  60 
  61 int true_comparison_range(struct data_range *left, int comparison, struct data_range *right);
  62 int true_comparison_range_LR(int comparison, struct data_range *var, struct data_range *val, int left);
  63 int false_comparison_range_LR(int comparison, struct data_range *var, struct data_range *val, int left);
  64 
  65 int possibly_true(struct expression *left, int comparison, struct expression *right);
  66 int possibly_true_rl(struct range_list *left_ranges, int comparison, struct range_list *right_ranges);
  67 int possibly_true_rl_LR(int comparison, struct range_list *a, struct range_list *b, int left);
  68 
  69 int possibly_false(struct expression *left, int comparison, struct expression *right);
  70 int possibly_false_rl(struct range_list *left_ranges, int comparison, struct range_list *right_ranges);
  71 int possibly_false_rl_LR(int comparison, struct range_list *a, struct range_list *b, int left);
  72 
  73 int rl_has_sval(struct range_list *rl, sval_t sval);
  74 int ranges_equiv(struct data_range *one, struct data_range *two);
  75 


  76 int rl_equiv(struct range_list *one, struct range_list *two);
  77 int is_whole_rl(struct range_list *rl);
  78 int is_unknown_ptr(struct range_list *rl);
  79 int is_whole_rl_non_zero(struct range_list *rl);
  80 int estate_is_unknown(struct smatch_state *state);
  81 
  82 sval_t rl_min(struct range_list *rl);
  83 sval_t rl_max(struct range_list *rl);
  84 int rl_to_sval(struct range_list *rl, sval_t *sval);
  85 struct symbol *rl_type(struct range_list *rl);
  86 
  87 struct range_list *rl_filter(struct range_list *rl, struct range_list *filter);
  88 struct range_list *rl_intersection(struct range_list *one, struct range_list *two);
  89 struct range_list *rl_union(struct range_list *one, struct range_list *two);
  90 struct range_list *rl_binop(struct range_list *left, int op, struct range_list *right);
  91 
  92 void push_rl(struct range_list_stack **rl_stack, struct range_list *rl);
  93 struct range_list *pop_rl(struct range_list_stack **rl_stack);
  94 struct range_list *top_rl(struct range_list_stack *rl_stack);
  95 void filter_top_rl(struct range_list_stack **rl_stack, struct range_list *filter);


 129 int estate_is_empty(struct smatch_state *state);
 130 
 131 struct range_list *estate_rl(struct smatch_state *state);
 132 struct related_list *estate_related(struct smatch_state *state);
 133 
 134 sval_t estate_min(struct smatch_state *state);
 135 sval_t estate_max(struct smatch_state *state);
 136 struct symbol *estate_type(struct smatch_state *state);
 137 
 138 int estate_has_fuzzy_max(struct smatch_state *state);
 139 sval_t estate_get_fuzzy_max(struct smatch_state *state);
 140 void estate_set_fuzzy_max(struct smatch_state *state, sval_t max);
 141 void estate_copy_fuzzy_max(struct smatch_state *new, struct smatch_state *old);
 142 void estate_clear_fuzzy_max(struct smatch_state *state);
 143 int estate_has_hard_max(struct smatch_state *state);
 144 void estate_set_hard_max(struct smatch_state *state);
 145 void estate_clear_hard_max(struct smatch_state *state);
 146 int estate_get_hard_max(struct smatch_state *state, sval_t *sval);
 147 bool estate_capped(struct smatch_state *state);
 148 void estate_set_capped(struct smatch_state *state);


 149 
 150 int estate_get_single_value(struct smatch_state *state, sval_t *sval);
 151 struct smatch_state *get_implied_estate(struct expression *expr);
 152 
 153 struct smatch_state *estate_filter_sval(struct smatch_state *orig, sval_t filter);
 154 struct data_info *clone_dinfo_perm(struct data_info *dinfo);
 155 struct smatch_state *clone_estate_perm(struct smatch_state *state);
 156 
 157 /* smatch_extra.c */
 158 bool is_impossible_variable(struct expression *expr);
 159 struct sm_state *get_extra_sm_state(struct expression *expr);
 160 struct smatch_state *get_extra_state(struct expression *expr);
 161 void call_extra_mod_hooks(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state);
 162 void set_extra_mod(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state);
 163 void set_extra_expr_mod(struct expression *expr, struct smatch_state *state);
 164 void set_extra_nomod(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state);
 165 void set_extra_nomod_vsl(const char *name, struct symbol *sym, struct var_sym_list *vsl, struct expression *expr, struct smatch_state *state);
 166 void set_extra_expr_nomod(struct expression *expr, struct smatch_state *state);
 167 void set_extra_mod_helper(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state);
 168 


 194 void remove_from_equiv_expr(struct expression *expr);
 195 void set_equiv_state_expr(int id, struct expression *expr, struct smatch_state *state);
 196 
 197 /* smatch_function_hooks.c */
 198 void function_comparison(struct expression *left, int comparison, struct expression *right);
 199 
 200 /* smatch_expressions.c */
 201 struct expression *zero_expr();
 202 struct expression *value_expr(long long val);
 203 struct expression *member_expression(struct expression *deref, int op, struct ident *member);
 204 struct expression *preop_expression(struct expression *expr, int op);
 205 struct expression *deref_expression(struct expression *expr);
 206 struct expression *assign_expression(struct expression *left, int op, struct expression *right);
 207 struct expression *binop_expression(struct expression *left, int op, struct expression *right);
 208 struct expression *array_element_expression(struct expression *array, struct expression *offset);
 209 struct expression *symbol_expression(struct symbol *sym);
 210 struct expression *string_expression(char *str);
 211 struct expression *compare_expression(struct expression *left, int op, struct expression *right);
 212 struct expression *unknown_value_expression(struct expression *expr);
 213 int is_fake_call(struct expression *expr);

 214 struct expression *gen_expression_from_key(struct expression *arg, const char *key);
 215 void free_tmp_expressions(void);
 216 void expr_set_parent_expr(struct expression *expr, struct expression *parent);
 217 void expr_set_parent_stmt(struct expression *expr, struct statement *parent);
 218 struct expression *expr_get_parent_expr(struct expression *expr);
 219 struct statement *expr_get_parent_stmt(struct expression *expr);
 220 
 221 /* smatch_param_limit.c */
 222 struct smatch_state *get_orig_estate(const char *name, struct symbol *sym);
 223 
 224 /* smatch_real_absolute.c */
 225 struct smatch_state *get_real_absolute_state(struct expression *expr);
 226 struct smatch_state *get_real_absolute_state_var_sym(const char *name, struct symbol *sym);
 227 
 228 /* smatch_imaginary_absolute.c */
 229 void __save_imaginary_state(struct expression *expr, struct range_list *true_rl, struct range_list *false_rl);
 230 int get_imaginary_absolute(struct expression *expr, struct range_list **rl);
 231 


  14  * You should have received a copy of the GNU General Public License
  15  * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16  */
  17 
  18 DECLARE_PTR_LIST(range_list, struct data_range);
  19 DECLARE_PTR_LIST(range_list_stack, struct range_list);
  20 
  21 struct relation {
  22         char *name;
  23         struct symbol *sym;
  24 };
  25 
  26 DECLARE_PTR_LIST(related_list, struct relation);
  27 
  28 struct data_info {
  29         struct related_list *related;
  30         struct range_list *value_ranges;
  31         sval_t fuzzy_max;
  32         unsigned int hard_max:1;
  33         unsigned int capped:1;
  34         unsigned int treat_untagged:1;
  35 };
  36 DECLARE_ALLOCATOR(data_info);
  37 
  38 extern struct string_list *__ignored_macros;
  39 
  40 /* these are implemented in smatch_ranges.c */
  41 struct range_list *rl_zero(void);
  42 struct range_list *rl_one(void);
  43 char *show_rl(struct range_list *list);
  44 int str_to_comparison_arg(const char *c, struct expression *call, int *comparison, struct expression **arg);
  45 void str_to_rl(struct symbol *type, char *value, struct range_list **rl);
  46 void call_results_to_rl(struct expression *call, struct symbol *type, const char *value, struct range_list **rl);
  47 
  48 struct data_range *alloc_range(sval_t min, sval_t max);
  49 struct data_range *alloc_range_perm(sval_t min, sval_t max);
  50 
  51 int rl_fits_in_type(struct range_list *rl, struct symbol *type);
  52 
  53 struct range_list *alloc_rl(sval_t min, sval_t max);
  54 struct range_list *clone_rl(struct range_list *list);


  57 
  58 void add_range(struct range_list **list, sval_t min, sval_t max);
  59 struct range_list *remove_range(struct range_list *list, sval_t min, sval_t max);
  60 void tack_on(struct range_list **list, struct data_range *drange);
  61 
  62 int true_comparison_range(struct data_range *left, int comparison, struct data_range *right);
  63 int true_comparison_range_LR(int comparison, struct data_range *var, struct data_range *val, int left);
  64 int false_comparison_range_LR(int comparison, struct data_range *var, struct data_range *val, int left);
  65 
  66 int possibly_true(struct expression *left, int comparison, struct expression *right);
  67 int possibly_true_rl(struct range_list *left_ranges, int comparison, struct range_list *right_ranges);
  68 int possibly_true_rl_LR(int comparison, struct range_list *a, struct range_list *b, int left);
  69 
  70 int possibly_false(struct expression *left, int comparison, struct expression *right);
  71 int possibly_false_rl(struct range_list *left_ranges, int comparison, struct range_list *right_ranges);
  72 int possibly_false_rl_LR(int comparison, struct range_list *a, struct range_list *b, int left);
  73 
  74 int rl_has_sval(struct range_list *rl, sval_t sval);
  75 int ranges_equiv(struct data_range *one, struct data_range *two);
  76 
  77 bool is_err_ptr(sval_t sval);
  78 
  79 int rl_equiv(struct range_list *one, struct range_list *two);
  80 int is_whole_rl(struct range_list *rl);
  81 int is_unknown_ptr(struct range_list *rl);
  82 int is_whole_rl_non_zero(struct range_list *rl);
  83 int estate_is_unknown(struct smatch_state *state);
  84 
  85 sval_t rl_min(struct range_list *rl);
  86 sval_t rl_max(struct range_list *rl);
  87 int rl_to_sval(struct range_list *rl, sval_t *sval);
  88 struct symbol *rl_type(struct range_list *rl);
  89 
  90 struct range_list *rl_filter(struct range_list *rl, struct range_list *filter);
  91 struct range_list *rl_intersection(struct range_list *one, struct range_list *two);
  92 struct range_list *rl_union(struct range_list *one, struct range_list *two);
  93 struct range_list *rl_binop(struct range_list *left, int op, struct range_list *right);
  94 
  95 void push_rl(struct range_list_stack **rl_stack, struct range_list *rl);
  96 struct range_list *pop_rl(struct range_list_stack **rl_stack);
  97 struct range_list *top_rl(struct range_list_stack *rl_stack);
  98 void filter_top_rl(struct range_list_stack **rl_stack, struct range_list *filter);


 132 int estate_is_empty(struct smatch_state *state);
 133 
 134 struct range_list *estate_rl(struct smatch_state *state);
 135 struct related_list *estate_related(struct smatch_state *state);
 136 
 137 sval_t estate_min(struct smatch_state *state);
 138 sval_t estate_max(struct smatch_state *state);
 139 struct symbol *estate_type(struct smatch_state *state);
 140 
 141 int estate_has_fuzzy_max(struct smatch_state *state);
 142 sval_t estate_get_fuzzy_max(struct smatch_state *state);
 143 void estate_set_fuzzy_max(struct smatch_state *state, sval_t max);
 144 void estate_copy_fuzzy_max(struct smatch_state *new, struct smatch_state *old);
 145 void estate_clear_fuzzy_max(struct smatch_state *state);
 146 int estate_has_hard_max(struct smatch_state *state);
 147 void estate_set_hard_max(struct smatch_state *state);
 148 void estate_clear_hard_max(struct smatch_state *state);
 149 int estate_get_hard_max(struct smatch_state *state, sval_t *sval);
 150 bool estate_capped(struct smatch_state *state);
 151 void estate_set_capped(struct smatch_state *state);
 152 bool estate_treat_untagged(struct smatch_state *state);
 153 void estate_set_treat_untagged(struct smatch_state *state);
 154 
 155 int estate_get_single_value(struct smatch_state *state, sval_t *sval);
 156 struct smatch_state *get_implied_estate(struct expression *expr);
 157 
 158 struct smatch_state *estate_filter_sval(struct smatch_state *orig, sval_t filter);
 159 struct data_info *clone_dinfo_perm(struct data_info *dinfo);
 160 struct smatch_state *clone_estate_perm(struct smatch_state *state);
 161 
 162 /* smatch_extra.c */
 163 bool is_impossible_variable(struct expression *expr);
 164 struct sm_state *get_extra_sm_state(struct expression *expr);
 165 struct smatch_state *get_extra_state(struct expression *expr);
 166 void call_extra_mod_hooks(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state);
 167 void set_extra_mod(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state);
 168 void set_extra_expr_mod(struct expression *expr, struct smatch_state *state);
 169 void set_extra_nomod(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state);
 170 void set_extra_nomod_vsl(const char *name, struct symbol *sym, struct var_sym_list *vsl, struct expression *expr, struct smatch_state *state);
 171 void set_extra_expr_nomod(struct expression *expr, struct smatch_state *state);
 172 void set_extra_mod_helper(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state);
 173 


 199 void remove_from_equiv_expr(struct expression *expr);
 200 void set_equiv_state_expr(int id, struct expression *expr, struct smatch_state *state);
 201 
 202 /* smatch_function_hooks.c */
 203 void function_comparison(struct expression *left, int comparison, struct expression *right);
 204 
 205 /* smatch_expressions.c */
 206 struct expression *zero_expr();
 207 struct expression *value_expr(long long val);
 208 struct expression *member_expression(struct expression *deref, int op, struct ident *member);
 209 struct expression *preop_expression(struct expression *expr, int op);
 210 struct expression *deref_expression(struct expression *expr);
 211 struct expression *assign_expression(struct expression *left, int op, struct expression *right);
 212 struct expression *binop_expression(struct expression *left, int op, struct expression *right);
 213 struct expression *array_element_expression(struct expression *array, struct expression *offset);
 214 struct expression *symbol_expression(struct symbol *sym);
 215 struct expression *string_expression(char *str);
 216 struct expression *compare_expression(struct expression *left, int op, struct expression *right);
 217 struct expression *unknown_value_expression(struct expression *expr);
 218 int is_fake_call(struct expression *expr);
 219 struct expression *gen_expression_from_name_sym(const char *name, struct symbol *sym);
 220 struct expression *gen_expression_from_key(struct expression *arg, const char *key);
 221 void free_tmp_expressions(void);
 222 void expr_set_parent_expr(struct expression *expr, struct expression *parent);
 223 void expr_set_parent_stmt(struct expression *expr, struct statement *parent);
 224 struct expression *expr_get_parent_expr(struct expression *expr);
 225 struct statement *expr_get_parent_stmt(struct expression *expr);
 226 
 227 /* smatch_param_limit.c */
 228 struct smatch_state *get_orig_estate(const char *name, struct symbol *sym);
 229 
 230 /* smatch_real_absolute.c */
 231 struct smatch_state *get_real_absolute_state(struct expression *expr);
 232 struct smatch_state *get_real_absolute_state_var_sym(const char *name, struct symbol *sym);
 233 
 234 /* smatch_imaginary_absolute.c */
 235 void __save_imaginary_state(struct expression *expr, struct range_list *true_rl, struct range_list *false_rl);
 236 int get_imaginary_absolute(struct expression *expr, struct range_list **rl);
 237