179 void add_function_hook(const char *look_for, func_hook *call_back, void *data);
180
181 void add_function_assign_hook(const char *look_for, func_hook *call_back,
182 void *info);
183 void add_implied_return_hook(const char *look_for,
184 implied_return_hook *call_back,
185 void *info);
186 void add_macro_assign_hook(const char *look_for, func_hook *call_back,
187 void *info);
188 void add_macro_assign_hook_extra(const char *look_for, func_hook *call_back,
189 void *info);
190 void return_implies_state(const char *look_for, long long start, long long end,
191 implication_hook *call_back, void *info);
192 void return_implies_state_sval(const char *look_for, sval_t start, sval_t end,
193 implication_hook *call_back, void *info);
194 void select_return_states_hook(int type, return_implies_hook *callback);
195 void select_return_states_before(void (*fn)(void));
196 void select_return_states_after(void (*fn)(void));
197 int get_implied_return(struct expression *expr, struct range_list **rl);
198 void allocate_hook_memory(void);
199
200 struct modification_data {
201 struct smatch_state *prev;
202 struct expression *cur;
203 };
204
205 typedef void (modification_hook)(struct sm_state *sm, struct expression *mod_expr);
206 void add_modification_hook(int owner, modification_hook *call_back);
207 void add_modification_hook_late(int owner, modification_hook *call_back);
208 struct smatch_state *get_modification_state(struct expression *expr);
209
210 int outside_of_function(void);
211 const char *get_filename(void);
212 const char *get_base_file(void);
213 char *get_function(void);
214 int get_lineno(void);
215 extern int final_pass;
216 extern struct symbol *cur_func_sym;
217 extern int option_debug;
218 extern int local_debug;
371
372 struct stree *get_all_states_from_stree(int owner, struct stree *source);
373 struct stree *get_all_states_stree(int id);
374 struct stree *__get_cur_stree(void);
375 int is_reachable(void);
376 void add_get_state_hook(void (*fn)(int owner, const char *name, struct symbol *sym));
377
378 /* smatch_helper.c */
379 DECLARE_PTR_LIST(int_stack, int);
380 char *alloc_string(const char *str);
381 char *alloc_string_newline(const char *str);
382 void free_string(char *str);
383 void append(char *dest, const char *data, int buff_len);
384 void remove_parens(char *str);
385 struct smatch_state *alloc_state_num(int num);
386 struct smatch_state *alloc_state_str(const char *name);
387 struct smatch_state *merge_str_state(struct smatch_state *s1, struct smatch_state *s2);
388 struct smatch_state *alloc_state_expr(struct expression *expr);
389 struct expression *get_argument_from_call_expr(struct expression_list *args,
390 int num);
391
392 char *expr_to_var(struct expression *expr);
393 struct symbol *expr_to_sym(struct expression *expr);
394 char *expr_to_str(struct expression *expr);
395 char *expr_to_str_sym(struct expression *expr,
396 struct symbol **sym_ptr);
397 char *expr_to_var_sym(struct expression *expr,
398 struct symbol **sym_ptr);
399 char *expr_to_known_chunk_sym(struct expression *expr, struct symbol **sym);
400 char *expr_to_chunk_sym_vsl(struct expression *expr, struct symbol **sym, struct var_sym_list **vsl);
401 int get_complication_score(struct expression *expr);
402
403 int sym_name_is(const char *name, struct expression *expr);
404 int get_const_value(struct expression *expr, sval_t *sval);
405 int get_value(struct expression *expr, sval_t *val);
406 int get_implied_value(struct expression *expr, sval_t *val);
407 int get_implied_value_fast(struct expression *expr, sval_t *sval);
408 int get_implied_min(struct expression *expr, sval_t *sval);
409 int get_implied_max(struct expression *expr, sval_t *val);
410 int get_hard_max(struct expression *expr, sval_t *sval);
429
430 int is_array(struct expression *expr);
431 struct expression *get_array_base(struct expression *expr);
432 struct expression *get_array_offset(struct expression *expr);
433 const char *show_state(struct smatch_state *state);
434 struct statement *get_expression_statement(struct expression *expr);
435 struct expression *strip_parens(struct expression *expr);
436 struct expression *strip_expr(struct expression *expr);
437 struct expression *strip_expr_set_parent(struct expression *expr);
438 void scoped_state(int my_id, const char *name, struct symbol *sym);
439 int is_error_return(struct expression *expr);
440 int getting_address(struct expression *expr);
441 int get_struct_and_member(struct expression *expr, const char **type, const char **member);
442 char *get_member_name(struct expression *expr);
443 char *get_fnptr_name(struct expression *expr);
444 int cmp_pos(struct position pos1, struct position pos2);
445 int positions_eq(struct position pos1, struct position pos2);
446 struct statement *get_current_statement(void);
447 struct statement *get_prev_statement(void);
448 struct expression *get_last_expr_from_expression_stmt(struct expression *expr);
449 int get_param_num_from_sym(struct symbol *sym);
450 int get_param_num(struct expression *expr);
451 struct symbol *get_param_sym_from_num(int num);
452 int ms_since(struct timeval *start);
453 int parent_is_gone_var_sym(const char *name, struct symbol *sym);
454 int parent_is_gone(struct expression *expr);
455 int invert_op(int op);
456 int op_remove_assign(int op);
457 int expr_equiv(struct expression *one, struct expression *two);
458 void push_int(struct int_stack **stack, int num);
459 int pop_int(struct int_stack **stack);
460
461 /* smatch_type.c */
462 struct symbol *get_real_base_type(struct symbol *sym);
463 int type_bytes(struct symbol *type);
464 int array_bytes(struct symbol *type);
465 struct symbol *get_pointer_type(struct expression *expr);
466 struct symbol *get_type(struct expression *expr);
467 struct symbol *get_final_type(struct expression *expr);
468 struct symbol *get_promoted_type(struct symbol *left, struct symbol *right);
469 int type_signed(struct symbol *base_type);
470 int expr_unsigned(struct expression *expr);
471 int expr_signed(struct expression *expr);
472 int returns_unsigned(struct symbol *base_type);
473 int is_pointer(struct expression *expr);
474 int returns_pointer(struct symbol *base_type);
475 sval_t sval_type_max(struct symbol *base_type);
476 sval_t sval_type_min(struct symbol *base_type);
477 int nr_bits(struct expression *expr);
478 int is_void_pointer(struct expression *expr);
479 int is_char_pointer(struct expression *expr);
480 int is_string(struct expression *expr);
481 int is_static(struct expression *expr);
482 bool is_local_variable(struct expression *expr);
483 int types_equiv(struct symbol *one, struct symbol *two);
484 int fn_static(void);
485 const char *global_static();
486 struct symbol *cur_func_return_type(void);
487 struct symbol *get_arg_type(struct expression *fn, int arg);
488 struct symbol *get_member_type_from_key(struct expression *expr, const char *key);
489 struct symbol *get_arg_type_from_key(struct expression *fn, int param, struct expression *arg, const char *key);
490 int is_struct(struct expression *expr);
491 char *type_to_str(struct symbol *type);
492
493 /* smatch_ignore.c */
494 void add_ignore(int owner, const char *name, struct symbol *sym);
495 int is_ignored(int owner, const char *name, struct symbol *sym);
496 void add_ignore_expr(int owner, struct expression *expr);
497 int is_ignored_expr(int owner, struct expression *expr);
498
499 /* smatch_var_sym */
500 struct var_sym *alloc_var_sym(const char *var, struct symbol *sym);
501 struct var_sym_list *expr_to_vsl(struct expression *expr);
502 void add_var_sym(struct var_sym_list **list, const char *var, struct symbol *sym);
503 void add_var_sym_expr(struct var_sym_list **list, struct expression *expr);
564 int time_parsing_function(void);
565 bool taking_too_long(void);
566
567 /* smatch_struct_assignment.c */
568 struct expression *get_faked_expression(void);
569 void __fake_struct_member_assignments(struct expression *expr);
570
571 /* smatch_project.c */
572 int is_no_inline_function(const char *function);
573
574 /* smatch_conditions */
575 void __split_whole_condition(struct expression *expr);
576 void __handle_logic(struct expression *expr);
577 int is_condition(struct expression *expr);
578 int __handle_condition_assigns(struct expression *expr);
579 int __handle_select_assigns(struct expression *expr);
580 int __handle_expr_statement_assigns(struct expression *expr);
581
582 /* smatch_implied.c */
583 struct range_list_stack;
584 void param_limit_implications(struct expression *expr, int param, char *key, char *value);
585 struct stree *__implied_case_stree(struct expression *switch_expr,
586 struct range_list *case_rl,
587 struct range_list_stack **remaining_cases,
588 struct stree **raw_stree);
589 void overwrite_states_using_pool(struct sm_state *gate_sm, struct sm_state *pool_sm);
590 int assume(struct expression *expr);
591 void end_assume(void);
592 int impossible_assumption(struct expression *left, int op, sval_t sval);
593
594 /* smatch_slist.h */
595 bool has_dynamic_states(unsigned short owner);
596 void set_dynamic_states(unsigned short owner);
597
598 /* smatch_extras.c */
599 int in_warn_on_macro(void);
600 #define SMATCH_EXTRA 5 /* this is my_id from smatch extra set in smatch.c */
601 extern int RETURN_ID;
602
603 struct data_range {
604 sval_t min;
763 void __process_breaks(void);
764 int __has_breaks(void);
765 void __merge_breaks(void);
766 void __use_breaks(void);
767
768 void __save_switch_states(struct expression *switch_expr);
769 void __discard_switches(void);
770 int have_remaining_cases(void);
771 void __merge_switches(struct expression *switch_expr, struct range_list *case_rl);
772 void __push_default(void);
773 void __set_default(void);
774 int __pop_default(void);
775
776 void __push_conditions(void);
777 void __discard_conditions(void);
778
779 void __save_gotos(const char *name, struct symbol *sym);
780 void __merge_gotos(const char *name, struct symbol *sym);
781
782 void __print_cur_stree(void);
783
784 /* smatch_hooks.c */
785 void __pass_to_client(void *data, enum hook_type type);
786 void __pass_case_to_client(struct expression *switch_expr,
787 struct range_list *rl);
788 int __has_merge_function(int client_id);
789 struct smatch_state *__client_merge_function(int owner,
790 struct smatch_state *s1,
791 struct smatch_state *s2);
792 struct smatch_state *__client_unmatched_state_function(struct sm_state *sm);
793 void call_pre_merge_hook(struct sm_state *cur, struct sm_state *other);
794 void __push_scope_hooks(void);
795 void __call_scope_hooks(void);
796
797 /* smatch_function_hooks.c */
798 void create_function_hook_hash(void);
799 void __match_initializer_call(struct symbol *sym);
800
801 /* smatch_db.c */
802 enum info_type {
830 CONTAINER = 1020,
831 CASTED_CALL = 1021,
832 TYPE_LINK = 1022,
833 UNTRACKED_PARAM = 1023,
834 LOST_PARAM = 2023,
835 CULL_PATH = 1024,
836 PARAM_SET = 1025,
837 PARAM_USED = 1026,
838 BYTE_UNITS = 1027,
839 COMPARE_LIMIT = 1028,
840 PARAM_COMPARE = 1029,
841 CONSTRAINT = 1031,
842 PASSES_TYPE = 1032,
843 CONSTRAINT_REQUIRED = 1033,
844 BIT_INFO = 1034,
845 NOSPEC = 1035,
846 NOSPEC_WB = 1036,
847 STMT_CNT = 1037,
848 TERMINATED = 1038,
849 FRESH_ALLOC = 1044,
850
851 /* put random temporary stuff in the 7000-7999 range for testing */
852 USER_DATA = 8017,
853 USER_DATA_SET = 9017,
854 NO_OVERFLOW = 8018,
855 NO_OVERFLOW_SIMPLE = 8019,
856 LOCKED = 8020,
857 UNLOCKED = 8021,
858 HALF_LOCKED = 9022,
859 LOCK_RESTORED = 9023,
860 KNOWN_LOCKED = 9024,
861 KNOWN_UNLOCKED = 9025,
862 SET_FS = 8022,
863 ATOMIC_INC = 8023,
864 ATOMIC_DEC = 8024,
865 NO_SIDE_EFFECT = 8025,
866 FN_ARG_LINK = 8028,
867 DATA_VALUE = 8029,
868 ARRAYSIZE_ARG = 8033,
869 SIZEOF_ARG = 8034,
870 MEMORY_TAG = 8036,
871 MTAG_ASSIGN = 8035,
872 STRING_VALUE = 8041,
873
874 BYTE_COUNT = 8050,
875 ELEM_COUNT = 8051,
876 ELEM_LAST = 8052,
877 USED_LAST = 8053,
878 USED_COUNT = 8054,
879 };
880
881 extern struct sqlite3 *smatch_db;
882 extern struct sqlite3 *mem_db;
883 extern struct sqlite3 *cache_db;
884
885 void db_ignore_states(int id);
886 void select_caller_info_hook(void (*callback)(const char *name, struct symbol *sym, char *key, char *value), int type);
887 void add_member_info_callback(int owner, void (*callback)(struct expression *call, int param, char *printed_name, struct sm_state *sm));
888 void add_split_return_callback(void (*fn)(int return_id, char *return_ranges, struct expression *returned_expr));
889 void add_returned_member_callback(int owner, void (*callback)(int return_id, char *return_ranges, struct expression *expr, char *printed_name, struct smatch_state *state));
890 void select_call_implies_hook(int type, void (*callback)(struct expression *call, struct expression *arg, char *key, char *value));
891 void select_return_implies_hook(int type, void (*callback)(struct expression *call, struct expression *arg, char *key, char *value));
892 struct range_list *db_return_vals(struct expression *expr);
893 struct range_list *db_return_vals_from_str(const char *fn_name);
894 struct range_list *db_return_vals_no_args(struct expression *expr);
895 char *return_state_to_var_sym(struct expression *expr, int param, const char *key, struct symbol **sym);
896 char *get_chunk_from_key(struct expression *arg, char *key, struct symbol **sym, struct var_sym_list **vsl);
897 char *get_variable_from_key(struct expression *arg, const char *key, struct symbol **sym);
898 const char *state_name_to_param_name(const char *state_name, const char *param_name);
899 const char *get_param_name_var_sym(const char *name, struct symbol *sym);
900 const char *get_param_name(struct sm_state *sm);
901 const char *get_mtag_name_var_sym(const char *state_name, struct symbol *sym);
902 const char *get_mtag_name_expr(struct expression *expr);
903 char *get_data_info_name(struct expression *expr);
904 char *sm_to_arg_name(struct expression *expr, struct sm_state *sm);
905 int is_recursive_member(const char *param_name);
906
907 char *escape_newlines(const char *str);
979 void sql_insert_caller_info(struct expression *call, int type, int param,
980 const char *key, const char *value);
981 void sql_insert_function_ptr(const char *fn, const char *struct_name);
982 void sql_insert_return_values(const char *return_values);
983 void sql_insert_return_implies(int type, int param, const char *key, const char *value);
984 void sql_insert_function_type_size(const char *member, const char *ranges);
985 void sql_insert_function_type_info(int type, const char *struct_type, const char *member, const char *value);
986 void sql_insert_type_info(int type, const char *member, const char *value);
987 void sql_insert_local_values(const char *name, const char *value);
988 void sql_insert_function_type_value(const char *type, const char *value);
989 void sql_insert_function_type(int param, const char *value);
990 void sql_insert_parameter_name(int param, const char *value);
991 void sql_insert_data_info(struct expression *data, int type, const char *value);
992 void sql_insert_data_info_var_sym(const char *var, struct symbol *sym, int type, const char *value);
993 void sql_save_constraint(const char *con);
994 void sql_save_constraint_required(const char *data, int op, const char *limit);
995 void sql_copy_constraint_required(const char *new_limit, const char *old_limit);
996 void sql_insert_fn_ptr_data_link(const char *ptr, const char *data);
997 void sql_insert_fn_data_link(struct expression *fn, int type, int param, const char *key, const char *value);
998 void sql_insert_mtag_about(mtag_t tag, const char *left_name, const char *right_name);
999 void sql_insert_mtag_map(mtag_t tag, int offset, mtag_t container);
1000 void sql_insert_mtag_alias(mtag_t orig, mtag_t alias);
1001 int mtag_map_select_container(mtag_t tag, int offset, mtag_t *container);
1002 int mtag_map_select_tag(mtag_t container, int offset, mtag_t *tag);
1003 struct smatch_state *swap_mtag_return(struct expression *expr, struct smatch_state *state);
1004 struct range_list *swap_mtag_seed(struct expression *expr, struct range_list *rl);
1005
1006 void sql_select_return_states(const char *cols, struct expression *call,
1007 int (*callback)(void*, int, char**, char**), void *info);
1008 void sql_select_call_implies(const char *cols, struct expression *call,
1009 int (*callback)(void*, int, char**, char**));
1010
1011 void open_smatch_db(char *db_file);
1012
1013 /* smatch_files.c */
1014 int open_data_file(const char *filename);
1015 int open_schema_file(const char *schema);
1016 struct token *get_tokens_file(const char *filename);
1017
1018 /* smatch.c */
1019 extern char *option_debug_check;
1020 extern char *option_project_str;
1021 extern char *bin_dir;
1022 extern char *data_dir;
1023 extern int option_no_data;
1052
1053 /* smatch_capped.c */
1054 int is_capped(struct expression *expr);
1055 int is_capped_var_sym(const char *name, struct symbol *sym);
1056
1057 /* check_user_data.c */
1058 int is_user_macro(struct expression *expr);
1059 int is_capped_user_data(struct expression *expr);
1060 int implied_user_data(struct expression *expr, struct range_list **rl);
1061 struct stree *get_user_stree(void);
1062 int get_user_rl(struct expression *expr, struct range_list **rl);
1063 int is_user_rl(struct expression *expr);
1064 int get_user_rl_var_sym(const char *name, struct symbol *sym, struct range_list **rl);
1065 bool user_rl_capped(struct expression *expr);
1066 struct range_list *var_user_rl(struct expression *expr);
1067
1068 /* check_locking.c */
1069 void print_held_locks();
1070
1071 /* check_assigned_expr.c */
1072 struct expression *get_assigned_expr(struct expression *expr);
1073 struct expression *get_assigned_expr_name_sym(const char *name, struct symbol *sym);
1074 /* smatch_return_to_param.c */
1075 void __add_return_to_param_mapping(struct expression *assign, const char *return_string);
1076 char *map_call_to_param_name_sym(struct expression *expr, struct symbol **sym);
1077
1078 /* smatch_comparison.c */
1079 extern int comparison_id;
1080 #define UNKNOWN_COMPARISON 0
1081 #define IMPOSSIBLE_COMPARISON -1
1082 struct compare_data {
1083 /* The ->left and ->right expression pointers might be NULL (I'm lazy) */
1084 struct expression *left;
1085 const char *left_var;
1086 struct var_sym_list *left_vsl;
1087 int comparison;
1088 struct expression *right;
1089 const char *right_var;
1090 struct var_sym_list *right_vsl;
1091 };
1102 int state_to_comparison(struct smatch_state *state);
1103 struct smatch_state *merge_compare_states(struct smatch_state *s1, struct smatch_state *s2);
1104 int get_comparison(struct expression *left, struct expression *right);
1105 int get_comparison_no_extra(struct expression *a, struct expression *b);
1106 int get_comparison_strings(const char *one, const char *two);
1107 int possible_comparison(struct expression *a, int comparison, struct expression *b);
1108 struct state_list *get_all_comparisons(struct expression *expr);
1109 struct state_list *get_all_possible_equal_comparisons(struct expression *expr);
1110 void __add_return_comparison(struct expression *call, const char *range);
1111 void __add_comparison_info(struct expression *expr, struct expression *call, const char *range);
1112 char *get_printed_param_name(struct expression *call, const char *param_name, struct symbol *param_sym);
1113 char *name_sym_to_param_comparison(const char *name, struct symbol *sym);
1114 char *expr_equal_to_param(struct expression *expr, int ignore);
1115 char *expr_lte_to_param(struct expression *expr, int ignore);
1116 char *expr_param_comparison(struct expression *expr, int ignore);
1117 int flip_comparison(int op);
1118 int negate_comparison(int op);
1119 int remove_unsigned_from_comparison(int op);
1120 int param_compare_limit_is_impossible(struct expression *expr, int left_param, char *left_key, char *value);
1121 void filter_by_comparison(struct range_list **rl, int comparison, struct range_list *right);
1122 struct sm_state *comparison_implication_hook(struct expression *expr,
1123 struct state_list **true_stack,
1124 struct state_list **false_stack);
1125 void __compare_param_limit_hook(struct expression *left_expr, struct expression *right_expr,
1126 const char *state_name,
1127 struct smatch_state *true_state, struct smatch_state *false_state);
1128 int impossibly_high_comparison(struct expression *expr);
1129
1130 /* smatch_sval.c */
1131 sval_t *sval_alloc(sval_t sval);
1132 sval_t *sval_alloc_permanent(sval_t sval);
1133 sval_t sval_blank(struct expression *expr);
1134 sval_t sval_type_val(struct symbol *type, long long val);
1135 sval_t sval_type_fval(struct symbol *type, long double fval);
1136 sval_t sval_from_val(struct expression *expr, long long val);
1137 sval_t sval_from_fval(struct expression *expr, long double fval);
1138 int sval_is_ptr(sval_t sval);
1139 bool sval_is_fp(sval_t sval);
1140 int sval_unsigned(sval_t sval);
1141 int sval_signed(sval_t sval);
1142 int sval_bits(sval_t sval);
1143 int sval_bits_used(sval_t sval);
1144 int sval_is_negative(sval_t sval);
1176 struct string_list *combine_string_lists(struct string_list *one, struct string_list *two);
1177
1178 /* smatch_start_states.c */
1179 struct stree *get_start_states(void);
1180
1181 /* smatch_recurse.c */
1182 int has_symbol(struct expression *expr, struct symbol *sym);
1183 int has_variable(struct expression *expr, struct expression *var);
1184 int has_inc_dec(struct expression *expr);
1185
1186 /* smatch_stored_conditions.c */
1187 struct smatch_state *get_stored_condition(struct expression *expr);
1188 struct expression_list *get_conditions(struct expression *expr);
1189 struct sm_state *stored_condition_implication_hook(struct expression *expr,
1190 struct state_list **true_stack,
1191 struct state_list **false_stack);
1192 /* smatch_parsed_conditions.c */
1193 struct sm_state *parsed_condition_implication_hook(struct expression *expr,
1194 struct state_list **true_stack,
1195 struct state_list **false_stack);
1196
1197 /* check_string_len.c */
1198 int get_formatted_string_size(struct expression *call, int arg);
1199 int get_formatted_string_min_size(struct expression *call, int arg);
1200
1201 /* smatch_param_set.c */
1202 int param_was_set(struct expression *expr);
1203 int param_was_set_var_sym(const char *name, struct symbol *sym);
1204 void print_limited_param_set(int return_id, char *return_ranges, struct expression *expr);
1205 /* smatch_param_filter.c */
1206 int param_has_filter_data(struct sm_state *sm);
1207
1208 /* smatch_links.c */
1209 void set_up_link_functions(int id, int linkid);
1210 struct smatch_state *merge_link_states(struct smatch_state *s1, struct smatch_state *s2);
1211 void store_link(int link_id, const char *name, struct symbol *sym, const char *link_name, struct symbol *link_sym);
1212
1213 /* check_buf_comparison */
1214 const char *limit_type_str(unsigned int limit_type);
1215 struct expression *get_size_variable(struct expression *buf, int *limit_type);
1223 void mark_all_params_untracked(int return_id, char *return_ranges, struct expression *expr);
1224
1225 /* smatch_strings.c */
1226 struct state_list *get_strings(struct expression *expr);
1227 struct expression *fake_string_from_mtag(mtag_t tag);
1228
1229 /* smatch_estate.c */
1230 int estate_get_single_value(struct smatch_state *state, sval_t *sval);
1231
1232 /* smatch_address.c */
1233 int get_address_rl(struct expression *expr, struct range_list **rl);
1234 int get_member_offset(struct symbol *type, const char *member_name);
1235 int get_member_offset_from_deref(struct expression *expr);
1236
1237 /* for now this is in smatch_used_parameter.c */
1238 void __get_state_hook(int owner, const char *name, struct symbol *sym);
1239
1240 /* smatch_buf_comparison.c */
1241 int db_var_is_array_limit(struct expression *array, const char *name, struct var_sym_list *vsl);
1242
1243 struct stree *get_all_return_states(void);
1244 struct stree_stack *get_all_return_strees(void);
1245 int on_atomic_dec_path(void);
1246 int was_inced(const char *name, struct symbol *sym);
1247
1248 /* smatch_constraints.c */
1249 char *get_constraint_str(struct expression *expr);
1250 struct constraint_list *get_constraints(struct expression *expr);
1251 char *unmet_constraint(struct expression *data, struct expression *offset);
1252 char *get_required_constraint(const char *data_str);
1253
1254 /* smatch_container_of.c */
1255 int get_param_from_container_of(struct expression *expr);
1256 int get_offset_from_container_of(struct expression *expr);
1257 char *get_container_name(struct expression *container, struct expression *expr);
1258
1259 /* smatch_mtag.c */
1260 mtag_t str_to_mtag(const char *str);
1261 int get_string_mtag(struct expression *expr, mtag_t *tag);
1262 int get_toplevel_mtag(struct symbol *sym, mtag_t *tag);
1263 int create_mtag_alias(mtag_t tag, struct expression *expr, mtag_t *new);
1264 int expr_to_mtag_offset(struct expression *expr, mtag_t *tag, int *offset);
1265 void update_mtag_data(struct expression *expr, struct smatch_state *state);
1266 int get_mtag_sval(struct expression *expr, sval_t *sval);
|
179 void add_function_hook(const char *look_for, func_hook *call_back, void *data);
180
181 void add_function_assign_hook(const char *look_for, func_hook *call_back,
182 void *info);
183 void add_implied_return_hook(const char *look_for,
184 implied_return_hook *call_back,
185 void *info);
186 void add_macro_assign_hook(const char *look_for, func_hook *call_back,
187 void *info);
188 void add_macro_assign_hook_extra(const char *look_for, func_hook *call_back,
189 void *info);
190 void return_implies_state(const char *look_for, long long start, long long end,
191 implication_hook *call_back, void *info);
192 void return_implies_state_sval(const char *look_for, sval_t start, sval_t end,
193 implication_hook *call_back, void *info);
194 void select_return_states_hook(int type, return_implies_hook *callback);
195 void select_return_states_before(void (*fn)(void));
196 void select_return_states_after(void (*fn)(void));
197 int get_implied_return(struct expression *expr, struct range_list **rl);
198 void allocate_hook_memory(void);
199 void allocate_tracker_array(int num_checks);
200
201 struct modification_data {
202 struct smatch_state *prev;
203 struct expression *cur;
204 };
205
206 typedef void (modification_hook)(struct sm_state *sm, struct expression *mod_expr);
207 void add_modification_hook(int owner, modification_hook *call_back);
208 void add_modification_hook_late(int owner, modification_hook *call_back);
209 struct smatch_state *get_modification_state(struct expression *expr);
210
211 int outside_of_function(void);
212 const char *get_filename(void);
213 const char *get_base_file(void);
214 char *get_function(void);
215 int get_lineno(void);
216 extern int final_pass;
217 extern struct symbol *cur_func_sym;
218 extern int option_debug;
219 extern int local_debug;
372
373 struct stree *get_all_states_from_stree(int owner, struct stree *source);
374 struct stree *get_all_states_stree(int id);
375 struct stree *__get_cur_stree(void);
376 int is_reachable(void);
377 void add_get_state_hook(void (*fn)(int owner, const char *name, struct symbol *sym));
378
379 /* smatch_helper.c */
380 DECLARE_PTR_LIST(int_stack, int);
381 char *alloc_string(const char *str);
382 char *alloc_string_newline(const char *str);
383 void free_string(char *str);
384 void append(char *dest, const char *data, int buff_len);
385 void remove_parens(char *str);
386 struct smatch_state *alloc_state_num(int num);
387 struct smatch_state *alloc_state_str(const char *name);
388 struct smatch_state *merge_str_state(struct smatch_state *s1, struct smatch_state *s2);
389 struct smatch_state *alloc_state_expr(struct expression *expr);
390 struct expression *get_argument_from_call_expr(struct expression_list *args,
391 int num);
392 struct expression *get_array_expr(struct expression *expr);
393
394 char *expr_to_var(struct expression *expr);
395 struct symbol *expr_to_sym(struct expression *expr);
396 char *expr_to_str(struct expression *expr);
397 char *expr_to_str_sym(struct expression *expr,
398 struct symbol **sym_ptr);
399 char *expr_to_var_sym(struct expression *expr,
400 struct symbol **sym_ptr);
401 char *expr_to_known_chunk_sym(struct expression *expr, struct symbol **sym);
402 char *expr_to_chunk_sym_vsl(struct expression *expr, struct symbol **sym, struct var_sym_list **vsl);
403 int get_complication_score(struct expression *expr);
404
405 int sym_name_is(const char *name, struct expression *expr);
406 int get_const_value(struct expression *expr, sval_t *sval);
407 int get_value(struct expression *expr, sval_t *val);
408 int get_implied_value(struct expression *expr, sval_t *val);
409 int get_implied_value_fast(struct expression *expr, sval_t *sval);
410 int get_implied_min(struct expression *expr, sval_t *sval);
411 int get_implied_max(struct expression *expr, sval_t *val);
412 int get_hard_max(struct expression *expr, sval_t *sval);
431
432 int is_array(struct expression *expr);
433 struct expression *get_array_base(struct expression *expr);
434 struct expression *get_array_offset(struct expression *expr);
435 const char *show_state(struct smatch_state *state);
436 struct statement *get_expression_statement(struct expression *expr);
437 struct expression *strip_parens(struct expression *expr);
438 struct expression *strip_expr(struct expression *expr);
439 struct expression *strip_expr_set_parent(struct expression *expr);
440 void scoped_state(int my_id, const char *name, struct symbol *sym);
441 int is_error_return(struct expression *expr);
442 int getting_address(struct expression *expr);
443 int get_struct_and_member(struct expression *expr, const char **type, const char **member);
444 char *get_member_name(struct expression *expr);
445 char *get_fnptr_name(struct expression *expr);
446 int cmp_pos(struct position pos1, struct position pos2);
447 int positions_eq(struct position pos1, struct position pos2);
448 struct statement *get_current_statement(void);
449 struct statement *get_prev_statement(void);
450 struct expression *get_last_expr_from_expression_stmt(struct expression *expr);
451
452 #define RETURN_VAR -1
453 #define LOCAL_SCOPE -2
454 #define FILE_SCOPE -3
455 #define GLOBAL_SCOPE -4
456 #define UNKNOWN_SCOPE -5
457 int get_param_num_from_sym(struct symbol *sym);
458 int get_param_num(struct expression *expr);
459 struct symbol *get_param_sym_from_num(int num);
460
461 int ms_since(struct timeval *start);
462 int parent_is_gone_var_sym(const char *name, struct symbol *sym);
463 int parent_is_gone(struct expression *expr);
464 int invert_op(int op);
465 int op_remove_assign(int op);
466 int expr_equiv(struct expression *one, struct expression *two);
467 void push_int(struct int_stack **stack, int num);
468 int pop_int(struct int_stack **stack);
469
470 /* smatch_type.c */
471 struct symbol *get_real_base_type(struct symbol *sym);
472 int type_bytes(struct symbol *type);
473 int array_bytes(struct symbol *type);
474 struct symbol *get_pointer_type(struct expression *expr);
475 struct symbol *get_type(struct expression *expr);
476 struct symbol *get_final_type(struct expression *expr);
477 struct symbol *get_promoted_type(struct symbol *left, struct symbol *right);
478 int type_signed(struct symbol *base_type);
479 int expr_unsigned(struct expression *expr);
480 int expr_signed(struct expression *expr);
481 int returns_unsigned(struct symbol *base_type);
482 int is_pointer(struct expression *expr);
483 int returns_pointer(struct symbol *base_type);
484 sval_t sval_type_max(struct symbol *base_type);
485 sval_t sval_type_min(struct symbol *base_type);
486 int nr_bits(struct expression *expr);
487 int is_void_pointer(struct expression *expr);
488 int is_char_pointer(struct expression *expr);
489 int is_string(struct expression *expr);
490 bool is_struct_ptr(struct symbol *type);
491 int is_static(struct expression *expr);
492 bool is_local_variable(struct expression *expr);
493 int types_equiv(struct symbol *one, struct symbol *two);
494 bool type_fits(struct symbol *type, struct symbol *test);
495 int fn_static(void);
496 const char *global_static();
497 struct symbol *cur_func_return_type(void);
498 struct symbol *get_arg_type(struct expression *fn, int arg);
499 struct symbol *get_member_type_from_key(struct expression *expr, const char *key);
500 struct symbol *get_arg_type_from_key(struct expression *fn, int param, struct expression *arg, const char *key);
501 int is_struct(struct expression *expr);
502 char *type_to_str(struct symbol *type);
503
504 /* smatch_ignore.c */
505 void add_ignore(int owner, const char *name, struct symbol *sym);
506 int is_ignored(int owner, const char *name, struct symbol *sym);
507 void add_ignore_expr(int owner, struct expression *expr);
508 int is_ignored_expr(int owner, struct expression *expr);
509
510 /* smatch_var_sym */
511 struct var_sym *alloc_var_sym(const char *var, struct symbol *sym);
512 struct var_sym_list *expr_to_vsl(struct expression *expr);
513 void add_var_sym(struct var_sym_list **list, const char *var, struct symbol *sym);
514 void add_var_sym_expr(struct var_sym_list **list, struct expression *expr);
575 int time_parsing_function(void);
576 bool taking_too_long(void);
577
578 /* smatch_struct_assignment.c */
579 struct expression *get_faked_expression(void);
580 void __fake_struct_member_assignments(struct expression *expr);
581
582 /* smatch_project.c */
583 int is_no_inline_function(const char *function);
584
585 /* smatch_conditions */
586 void __split_whole_condition(struct expression *expr);
587 void __handle_logic(struct expression *expr);
588 int is_condition(struct expression *expr);
589 int __handle_condition_assigns(struct expression *expr);
590 int __handle_select_assigns(struct expression *expr);
591 int __handle_expr_statement_assigns(struct expression *expr);
592
593 /* smatch_implied.c */
594 struct range_list_stack;
595 void param_limit_implications(struct expression *expr, int param, char *key, char *value, struct stree **implied);
596 struct stree *__implied_case_stree(struct expression *switch_expr,
597 struct range_list *case_rl,
598 struct range_list_stack **remaining_cases,
599 struct stree **raw_stree);
600 void overwrite_states_using_pool(struct sm_state *gate_sm, struct sm_state *pool_sm);
601 int assume(struct expression *expr);
602 void end_assume(void);
603 int impossible_assumption(struct expression *left, int op, sval_t sval);
604
605 /* smatch_slist.h */
606 bool has_dynamic_states(unsigned short owner);
607 void set_dynamic_states(unsigned short owner);
608
609 /* smatch_extras.c */
610 int in_warn_on_macro(void);
611 #define SMATCH_EXTRA 5 /* this is my_id from smatch extra set in smatch.c */
612 extern int RETURN_ID;
613
614 struct data_range {
615 sval_t min;
774 void __process_breaks(void);
775 int __has_breaks(void);
776 void __merge_breaks(void);
777 void __use_breaks(void);
778
779 void __save_switch_states(struct expression *switch_expr);
780 void __discard_switches(void);
781 int have_remaining_cases(void);
782 void __merge_switches(struct expression *switch_expr, struct range_list *case_rl);
783 void __push_default(void);
784 void __set_default(void);
785 int __pop_default(void);
786
787 void __push_conditions(void);
788 void __discard_conditions(void);
789
790 void __save_gotos(const char *name, struct symbol *sym);
791 void __merge_gotos(const char *name, struct symbol *sym);
792
793 void __print_cur_stree(void);
794 bool __print_states(const char *owner);
795 typedef void (check_tracker_hook)(int owner, const char *name, struct symbol *sym, struct smatch_state *state);
796 void add_check_tracker(const char *check_name, check_tracker_hook *fn);
797
798 /* smatch_hooks.c */
799 void __pass_to_client(void *data, enum hook_type type);
800 void __pass_case_to_client(struct expression *switch_expr,
801 struct range_list *rl);
802 int __has_merge_function(int client_id);
803 struct smatch_state *__client_merge_function(int owner,
804 struct smatch_state *s1,
805 struct smatch_state *s2);
806 struct smatch_state *__client_unmatched_state_function(struct sm_state *sm);
807 void call_pre_merge_hook(struct sm_state *cur, struct sm_state *other);
808 void __push_scope_hooks(void);
809 void __call_scope_hooks(void);
810
811 /* smatch_function_hooks.c */
812 void create_function_hook_hash(void);
813 void __match_initializer_call(struct symbol *sym);
814
815 /* smatch_db.c */
816 enum info_type {
844 CONTAINER = 1020,
845 CASTED_CALL = 1021,
846 TYPE_LINK = 1022,
847 UNTRACKED_PARAM = 1023,
848 LOST_PARAM = 2023,
849 CULL_PATH = 1024,
850 PARAM_SET = 1025,
851 PARAM_USED = 1026,
852 BYTE_UNITS = 1027,
853 COMPARE_LIMIT = 1028,
854 PARAM_COMPARE = 1029,
855 CONSTRAINT = 1031,
856 PASSES_TYPE = 1032,
857 CONSTRAINT_REQUIRED = 1033,
858 BIT_INFO = 1034,
859 NOSPEC = 1035,
860 NOSPEC_WB = 1036,
861 STMT_CNT = 1037,
862 TERMINATED = 1038,
863 FRESH_ALLOC = 1044,
864 ALLOCATOR = 1045,
865
866 /* put random temporary stuff in the 7000-7999 range for testing */
867 USER_DATA = 8017,
868 USER_DATA_SET = 9017,
869 NO_OVERFLOW = 8018,
870 NO_OVERFLOW_SIMPLE = 8019,
871 LOCKED = 8020,
872 UNLOCKED = 8021,
873 HALF_LOCKED = 9022,
874 LOCK_RESTORED = 9023,
875 KNOWN_LOCKED = 9024,
876 KNOWN_UNLOCKED = 9025,
877 SET_FS = 8022,
878 ATOMIC_INC = 8023,
879 ATOMIC_DEC = 8024,
880 REFCOUNT = 9025,
881 NO_SIDE_EFFECT = 8025,
882 FN_ARG_LINK = 8028,
883 DATA_VALUE = 8029,
884 ARRAYSIZE_ARG = 8033,
885 SIZEOF_ARG = 8034,
886 MEMORY_TAG = 8036,
887 MTAG_ASSIGN = 8035,
888 STRING_VALUE = 8041,
889
890 BYTE_COUNT = 8050,
891 ELEM_COUNT = 8051,
892 ELEM_LAST = 8052,
893 USED_LAST = 8053,
894 USED_COUNT = 8054,
895 };
896
897 extern struct sqlite3 *smatch_db;
898 extern struct sqlite3 *mem_db;
899 extern struct sqlite3 *cache_db;
900
901 void db_ignore_states(int id);
902 void select_caller_info_hook(void (*callback)(const char *name, struct symbol *sym, char *key, char *value), int type);
903 void add_member_info_callback(int owner, void (*callback)(struct expression *call, int param, char *printed_name, struct sm_state *sm));
904 void add_caller_info_callback(int owner, void (*callback)(struct expression *call, int param, char *printed_name, struct sm_state *sm));
905 void add_split_return_callback(void (*fn)(int return_id, char *return_ranges, struct expression *returned_expr));
906 void add_returned_member_callback(int owner, void (*callback)(int return_id, char *return_ranges, struct expression *expr, char *printed_name, struct smatch_state *state));
907 void select_call_implies_hook(int type, void (*callback)(struct expression *call, struct expression *arg, char *key, char *value));
908 void select_return_implies_hook(int type, void (*callback)(struct expression *call, struct expression *arg, char *key, char *value));
909 struct range_list *db_return_vals(struct expression *expr);
910 struct range_list *db_return_vals_from_str(const char *fn_name);
911 struct range_list *db_return_vals_no_args(struct expression *expr);
912 char *return_state_to_var_sym(struct expression *expr, int param, const char *key, struct symbol **sym);
913 char *get_chunk_from_key(struct expression *arg, char *key, struct symbol **sym, struct var_sym_list **vsl);
914 char *get_variable_from_key(struct expression *arg, const char *key, struct symbol **sym);
915 const char *state_name_to_param_name(const char *state_name, const char *param_name);
916 const char *get_param_name_var_sym(const char *name, struct symbol *sym);
917 const char *get_param_name(struct sm_state *sm);
918 const char *get_mtag_name_var_sym(const char *state_name, struct symbol *sym);
919 const char *get_mtag_name_expr(struct expression *expr);
920 char *get_data_info_name(struct expression *expr);
921 char *sm_to_arg_name(struct expression *expr, struct sm_state *sm);
922 int is_recursive_member(const char *param_name);
923
924 char *escape_newlines(const char *str);
996 void sql_insert_caller_info(struct expression *call, int type, int param,
997 const char *key, const char *value);
998 void sql_insert_function_ptr(const char *fn, const char *struct_name);
999 void sql_insert_return_values(const char *return_values);
1000 void sql_insert_return_implies(int type, int param, const char *key, const char *value);
1001 void sql_insert_function_type_size(const char *member, const char *ranges);
1002 void sql_insert_function_type_info(int type, const char *struct_type, const char *member, const char *value);
1003 void sql_insert_type_info(int type, const char *member, const char *value);
1004 void sql_insert_local_values(const char *name, const char *value);
1005 void sql_insert_function_type_value(const char *type, const char *value);
1006 void sql_insert_function_type(int param, const char *value);
1007 void sql_insert_parameter_name(int param, const char *value);
1008 void sql_insert_data_info(struct expression *data, int type, const char *value);
1009 void sql_insert_data_info_var_sym(const char *var, struct symbol *sym, int type, const char *value);
1010 void sql_save_constraint(const char *con);
1011 void sql_save_constraint_required(const char *data, int op, const char *limit);
1012 void sql_copy_constraint_required(const char *new_limit, const char *old_limit);
1013 void sql_insert_fn_ptr_data_link(const char *ptr, const char *data);
1014 void sql_insert_fn_data_link(struct expression *fn, int type, int param, const char *key, const char *value);
1015 void sql_insert_mtag_about(mtag_t tag, const char *left_name, const char *right_name);
1016 void sql_insert_mtag_info(mtag_t tag, int type, const char *value);
1017 void sql_insert_mtag_map(mtag_t container, int container_offset, mtag_t tag, int tag_offset);
1018 void sql_insert_mtag_alias(mtag_t orig, mtag_t alias);
1019 int mtag_map_select_container(mtag_t tag, int container_offset, mtag_t *container);
1020 int mtag_map_select_tag(mtag_t container, int offset, mtag_t *tag);
1021 struct smatch_state *get_mtag_return(struct expression *expr, struct smatch_state *state);
1022 struct range_list *swap_mtag_seed(struct expression *expr, struct range_list *rl);
1023
1024 void sql_select_return_states(const char *cols, struct expression *call,
1025 int (*callback)(void*, int, char**, char**), void *info);
1026 void sql_select_call_implies(const char *cols, struct expression *call,
1027 int (*callback)(void*, int, char**, char**));
1028
1029 void open_smatch_db(char *db_file);
1030
1031 /* smatch_files.c */
1032 int open_data_file(const char *filename);
1033 int open_schema_file(const char *schema);
1034 struct token *get_tokens_file(const char *filename);
1035
1036 /* smatch.c */
1037 extern char *option_debug_check;
1038 extern char *option_project_str;
1039 extern char *bin_dir;
1040 extern char *data_dir;
1041 extern int option_no_data;
1070
1071 /* smatch_capped.c */
1072 int is_capped(struct expression *expr);
1073 int is_capped_var_sym(const char *name, struct symbol *sym);
1074
1075 /* check_user_data.c */
1076 int is_user_macro(struct expression *expr);
1077 int is_capped_user_data(struct expression *expr);
1078 int implied_user_data(struct expression *expr, struct range_list **rl);
1079 struct stree *get_user_stree(void);
1080 int get_user_rl(struct expression *expr, struct range_list **rl);
1081 int is_user_rl(struct expression *expr);
1082 int get_user_rl_var_sym(const char *name, struct symbol *sym, struct range_list **rl);
1083 bool user_rl_capped(struct expression *expr);
1084 struct range_list *var_user_rl(struct expression *expr);
1085
1086 /* check_locking.c */
1087 void print_held_locks();
1088
1089 /* check_assigned_expr.c */
1090 extern int check_assigned_expr_id;
1091 struct expression *get_assigned_expr(struct expression *expr);
1092 struct expression *get_assigned_expr_name_sym(const char *name, struct symbol *sym);
1093 /* smatch_return_to_param.c */
1094 void __add_return_to_param_mapping(struct expression *assign, const char *return_string);
1095 char *map_call_to_param_name_sym(struct expression *expr, struct symbol **sym);
1096
1097 /* smatch_comparison.c */
1098 extern int comparison_id;
1099 #define UNKNOWN_COMPARISON 0
1100 #define IMPOSSIBLE_COMPARISON -1
1101 struct compare_data {
1102 /* The ->left and ->right expression pointers might be NULL (I'm lazy) */
1103 struct expression *left;
1104 const char *left_var;
1105 struct var_sym_list *left_vsl;
1106 int comparison;
1107 struct expression *right;
1108 const char *right_var;
1109 struct var_sym_list *right_vsl;
1110 };
1121 int state_to_comparison(struct smatch_state *state);
1122 struct smatch_state *merge_compare_states(struct smatch_state *s1, struct smatch_state *s2);
1123 int get_comparison(struct expression *left, struct expression *right);
1124 int get_comparison_no_extra(struct expression *a, struct expression *b);
1125 int get_comparison_strings(const char *one, const char *two);
1126 int possible_comparison(struct expression *a, int comparison, struct expression *b);
1127 struct state_list *get_all_comparisons(struct expression *expr);
1128 struct state_list *get_all_possible_equal_comparisons(struct expression *expr);
1129 void __add_return_comparison(struct expression *call, const char *range);
1130 void __add_comparison_info(struct expression *expr, struct expression *call, const char *range);
1131 char *get_printed_param_name(struct expression *call, const char *param_name, struct symbol *param_sym);
1132 char *name_sym_to_param_comparison(const char *name, struct symbol *sym);
1133 char *expr_equal_to_param(struct expression *expr, int ignore);
1134 char *expr_lte_to_param(struct expression *expr, int ignore);
1135 char *expr_param_comparison(struct expression *expr, int ignore);
1136 int flip_comparison(int op);
1137 int negate_comparison(int op);
1138 int remove_unsigned_from_comparison(int op);
1139 int param_compare_limit_is_impossible(struct expression *expr, int left_param, char *left_key, char *value);
1140 void filter_by_comparison(struct range_list **rl, int comparison, struct range_list *right);
1141 void __compare_param_limit_hook(struct expression *left_expr, struct expression *right_expr,
1142 const char *state_name,
1143 struct smatch_state *true_state, struct smatch_state *false_state);
1144 int impossibly_high_comparison(struct expression *expr);
1145
1146 /* smatch_sval.c */
1147 sval_t *sval_alloc(sval_t sval);
1148 sval_t *sval_alloc_permanent(sval_t sval);
1149 sval_t sval_blank(struct expression *expr);
1150 sval_t sval_type_val(struct symbol *type, long long val);
1151 sval_t sval_type_fval(struct symbol *type, long double fval);
1152 sval_t sval_from_val(struct expression *expr, long long val);
1153 sval_t sval_from_fval(struct expression *expr, long double fval);
1154 int sval_is_ptr(sval_t sval);
1155 bool sval_is_fp(sval_t sval);
1156 int sval_unsigned(sval_t sval);
1157 int sval_signed(sval_t sval);
1158 int sval_bits(sval_t sval);
1159 int sval_bits_used(sval_t sval);
1160 int sval_is_negative(sval_t sval);
1192 struct string_list *combine_string_lists(struct string_list *one, struct string_list *two);
1193
1194 /* smatch_start_states.c */
1195 struct stree *get_start_states(void);
1196
1197 /* smatch_recurse.c */
1198 int has_symbol(struct expression *expr, struct symbol *sym);
1199 int has_variable(struct expression *expr, struct expression *var);
1200 int has_inc_dec(struct expression *expr);
1201
1202 /* smatch_stored_conditions.c */
1203 struct smatch_state *get_stored_condition(struct expression *expr);
1204 struct expression_list *get_conditions(struct expression *expr);
1205 struct sm_state *stored_condition_implication_hook(struct expression *expr,
1206 struct state_list **true_stack,
1207 struct state_list **false_stack);
1208 /* smatch_parsed_conditions.c */
1209 struct sm_state *parsed_condition_implication_hook(struct expression *expr,
1210 struct state_list **true_stack,
1211 struct state_list **false_stack);
1212 /* smatch_comparison.c */
1213 struct sm_state *comparison_implication_hook(struct expression *expr,
1214 struct state_list **true_stack,
1215 struct state_list **false_stack);
1216
1217 /* check_string_len.c */
1218 int get_formatted_string_size(struct expression *call, int arg);
1219 int get_formatted_string_min_size(struct expression *call, int arg);
1220
1221 /* smatch_param_set.c */
1222 int param_was_set(struct expression *expr);
1223 int param_was_set_var_sym(const char *name, struct symbol *sym);
1224 void print_limited_param_set(int return_id, char *return_ranges, struct expression *expr);
1225 /* smatch_param_filter.c */
1226 int param_has_filter_data(struct sm_state *sm);
1227
1228 /* smatch_links.c */
1229 void set_up_link_functions(int id, int linkid);
1230 struct smatch_state *merge_link_states(struct smatch_state *s1, struct smatch_state *s2);
1231 void store_link(int link_id, const char *name, struct symbol *sym, const char *link_name, struct symbol *link_sym);
1232
1233 /* check_buf_comparison */
1234 const char *limit_type_str(unsigned int limit_type);
1235 struct expression *get_size_variable(struct expression *buf, int *limit_type);
1243 void mark_all_params_untracked(int return_id, char *return_ranges, struct expression *expr);
1244
1245 /* smatch_strings.c */
1246 struct state_list *get_strings(struct expression *expr);
1247 struct expression *fake_string_from_mtag(mtag_t tag);
1248
1249 /* smatch_estate.c */
1250 int estate_get_single_value(struct smatch_state *state, sval_t *sval);
1251
1252 /* smatch_address.c */
1253 int get_address_rl(struct expression *expr, struct range_list **rl);
1254 int get_member_offset(struct symbol *type, const char *member_name);
1255 int get_member_offset_from_deref(struct expression *expr);
1256
1257 /* for now this is in smatch_used_parameter.c */
1258 void __get_state_hook(int owner, const char *name, struct symbol *sym);
1259
1260 /* smatch_buf_comparison.c */
1261 int db_var_is_array_limit(struct expression *array, const char *name, struct var_sym_list *vsl);
1262
1263 struct range_list *get_fs(void);
1264
1265 struct stree *get_all_return_states(void);
1266 struct stree_stack *get_all_return_strees(void);
1267 int on_atomic_dec_path(void);
1268 int was_inced(const char *name, struct symbol *sym);
1269 void set_refcount_inc(char *name, struct symbol *sym);
1270 void set_refcount_dec(char *name, struct symbol *sym);
1271
1272 /* smatch_constraints.c */
1273 char *get_constraint_str(struct expression *expr);
1274 struct constraint_list *get_constraints(struct expression *expr);
1275 char *unmet_constraint(struct expression *data, struct expression *offset);
1276 char *get_required_constraint(const char *data_str);
1277
1278 /* smatch_container_of.c */
1279 int get_param_from_container_of(struct expression *expr);
1280 int get_offset_from_container_of(struct expression *expr);
1281 char *get_container_name(struct expression *container, struct expression *expr);
1282
1283 /* smatch_mtag.c */
1284 mtag_t str_to_mtag(const char *str);
1285 int get_string_mtag(struct expression *expr, mtag_t *tag);
1286 int get_toplevel_mtag(struct symbol *sym, mtag_t *tag);
1287 int create_mtag_alias(mtag_t tag, struct expression *expr, mtag_t *new);
1288 int expr_to_mtag_offset(struct expression *expr, mtag_t *tag, int *offset);
1289 void update_mtag_data(struct expression *expr, struct smatch_state *state);
1290 int get_mtag_sval(struct expression *expr, sval_t *sval);
|