4 * Copyright (C) 2006 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
21 #include "expression.h"
27 unsigned long long uvalue
;
35 #define STATE(_x) static struct smatch_state _x = { .name = #_x }
36 extern struct smatch_state undefined
;
37 extern struct smatch_state merged
;
38 extern struct smatch_state true_state
;
39 extern struct smatch_state false_state
;
40 DECLARE_ALLOCATOR(smatch_state
);
42 static inline void *INT_PTR(int i
)
44 return (void *)(long)i
;
47 static inline int PTR_INT(void *p
)
54 unsigned short merged
:1;
55 unsigned short implied
:1;
56 unsigned int nr_children
;
60 struct smatch_state
*state
;
61 struct state_list
*pool
;
62 struct sm_state
*left
;
63 struct sm_state
*right
;
64 struct state_list
*possible
;
71 DECLARE_ALLOCATOR(var_sym
);
72 DECLARE_PTR_LIST(var_sym_list
, struct var_sym
);
79 DECLARE_ALLOCATOR(tracker
);
80 DECLARE_PTR_LIST(tracker_list
, struct tracker
);
91 GLOBAL_ASSIGNMENT_HOOK
,
98 CALL_HOOK_AFTER_INLINE
,
100 MACRO_ASSIGNMENT_HOOK
,
124 void add_hook(void *func
, enum hook_type type
);
125 typedef struct smatch_state
*(merge_func_t
)(struct smatch_state
*s1
, struct smatch_state
*s2
);
126 typedef struct smatch_state
*(unmatched_func_t
)(struct sm_state
*state
);
127 void add_merge_hook(int client_id
, merge_func_t
*func
);
128 void add_unmatched_state_hook(int client_id
, unmatched_func_t
*func
);
129 typedef void (scope_hook
)(void *data
);
130 void add_scope_hook(scope_hook
*hook
, void *data
);
131 typedef void (func_hook
)(const char *fn
, struct expression
*expr
, void *data
);
132 typedef void (implication_hook
)(const char *fn
, struct expression
*call_expr
,
133 struct expression
*assign_expr
, void *data
);
134 typedef void (return_implies_hook
)(struct expression
*call_expr
,
135 int param
, char *key
, char *value
);
136 typedef int (implied_return_hook
)(struct expression
*call_expr
, void *info
, struct range_list
**rl
);
137 void add_function_hook(const char *look_for
, func_hook
*call_back
, void *data
);
139 void add_function_assign_hook(const char *look_for
, func_hook
*call_back
,
141 void add_implied_return_hook(const char *look_for
,
142 implied_return_hook
*call_back
,
144 void add_macro_assign_hook(const char *look_for
, func_hook
*call_back
,
146 void add_macro_assign_hook_extra(const char *look_for
, func_hook
*call_back
,
148 void return_implies_state(const char *look_for
, long long start
, long long end
,
149 implication_hook
*call_back
, void *info
);
150 void select_return_states_hook(int type
, return_implies_hook
*callback
);
151 void select_return_states_before(void (*fn
)(void));
152 void select_return_states_after(void (*fn
)(void));
153 int get_implied_return(struct expression
*expr
, struct range_list
**rl
);
155 typedef void (modification_hook
)(struct sm_state
*sm
, struct expression
*mod_expr
);
156 void add_modification_hook(int owner
, modification_hook
*call_back
);
157 void add_indirect_modification_hook(int owner
, modification_hook
*call_back
);
159 int outside_of_function(void);
160 const char *get_filename(void);
161 const char *get_base_file(void);
162 char *get_function(void);
163 int get_lineno(void);
164 extern int final_pass
;
165 extern struct symbol
*cur_func_sym
;
166 extern int option_debug
;
167 extern int local_debug
;
168 extern int option_info
;
169 int is_silenced_function(void);
171 extern FILE *sm_outfd
;
172 #define sm_printf(msg...) do { if (final_pass || option_debug) fprintf(sm_outfd, msg); } while (0)
174 static inline void sm_prefix(void)
176 sm_printf("%s:%d %s() ", get_filename(), get_lineno(), get_function());
179 static inline void print_implied_debug_msg();
181 #define sm_msg(msg...) \
183 print_implied_debug_msg(); \
184 if (!option_debug && !final_pass) \
186 if (!option_info && is_silenced_function()) \
193 #define local_debug(msg...) \
199 extern char *implied_debug_msg
;
200 static inline void print_implied_debug_msg()
202 static struct symbol
*last_printed
= NULL
;
204 if (!implied_debug_msg
)
206 if (last_printed
== cur_func_sym
)
208 last_printed
= cur_func_sym
;
209 sm_msg("%s", implied_debug_msg
);
212 #define sm_debug(msg...) do { if (option_debug) sm_printf(msg); } while (0)
214 #define sm_info(msg...) do { \
215 if (option_debug || (option_info && final_pass)) { \
217 sm_printf("info: "); \
223 struct smatch_state
*get_state(int owner
, const char *name
, struct symbol
*sym
);
224 struct smatch_state
*get_state_expr(int owner
, struct expression
*expr
);
225 struct state_list
*get_possible_states(int owner
, const char *name
,
227 struct state_list
*get_possible_states_expr(int owner
, struct expression
*expr
);
228 struct sm_state
*set_state(int owner
, const char *name
, struct symbol
*sym
,
229 struct smatch_state
*state
);
230 struct sm_state
*set_state_expr(int owner
, struct expression
*expr
,
231 struct smatch_state
*state
);
232 void delete_state(int owner
, const char *name
, struct symbol
*sym
);
233 void delete_state_expr(int owner
, struct expression
*expr
);
234 void set_true_false_states(int owner
, const char *name
, struct symbol
*sym
,
235 struct smatch_state
*true_state
,
236 struct smatch_state
*false_state
);
237 void set_true_false_states_expr(int owner
, struct expression
*expr
,
238 struct smatch_state
*true_state
,
239 struct smatch_state
*false_state
);
241 struct state_list
*get_all_states_slist(int owner
, struct state_list
*source
);
242 struct state_list
*get_all_states(int id
);
243 int is_reachable(void);
245 /* smatch_helper.c */
246 char *alloc_string(const char *str
);
247 void free_string(char *str
);
248 void append(char *dest
, const char *data
, int buff_len
);
249 void remove_parens(char *str
);
250 struct smatch_state
*alloc_state_num(int num
);
251 struct expression
*get_argument_from_call_expr(struct expression_list
*args
,
254 char *expr_to_var(struct expression
*expr
);
255 char *expr_to_str(struct expression
*expr
);
256 char *expr_to_str_sym(struct expression
*expr
,
257 struct symbol
**sym_ptr
);
258 char *expr_to_var_sym(struct expression
*expr
,
259 struct symbol
**sym_ptr
);
261 int sym_name_is(const char *name
, struct expression
*expr
);
262 int get_const_value(struct expression
*expr
, sval_t
*sval
);
263 int get_value(struct expression
*expr
, sval_t
*val
);
264 int get_implied_value(struct expression
*expr
, sval_t
*val
);
265 int get_implied_min(struct expression
*expr
, sval_t
*sval
);
266 int get_implied_max(struct expression
*expr
, sval_t
*val
);
267 int get_hard_max(struct expression
*expr
, sval_t
*sval
);
268 int get_fuzzy_min(struct expression
*expr
, sval_t
*min
);
269 int get_fuzzy_max(struct expression
*expr
, sval_t
*max
);
270 int get_absolute_min(struct expression
*expr
, sval_t
*sval
);
271 int get_absolute_max(struct expression
*expr
, sval_t
*sval
);
272 int parse_call_math(struct expression
*expr
, char *math
, sval_t
*val
);
273 int is_zero(struct expression
*expr
);
274 int known_condition_true(struct expression
*expr
);
275 int known_condition_false(struct expression
*expr
);
276 int implied_condition_true(struct expression
*expr
);
277 int implied_condition_false(struct expression
*expr
);
279 int is_array(struct expression
*expr
);
280 struct expression
*get_array_name(struct expression
*expr
);
281 struct expression
*get_array_offset(struct expression
*expr
);
282 const char *show_state(struct smatch_state
*state
);
283 struct statement
*get_expression_statement(struct expression
*expr
);
284 struct expression
*strip_parens(struct expression
*expr
);
285 struct expression
*strip_expr(struct expression
*expr
);
286 void scoped_state(int my_id
, const char *name
, struct symbol
*sym
);
287 int is_error_return(struct expression
*expr
);
288 int getting_address(void);
289 char *get_member_name(struct expression
*expr
);
290 char *get_fnptr_name(struct expression
*expr
);
291 int cmp_pos(struct position pos1
, struct position pos2
);
292 int positions_eq(struct position pos1
, struct position pos2
);
293 struct statement
*get_current_statement(void);
294 int get_param_num_from_sym(struct symbol
*sym
);
295 int get_param_num(struct expression
*expr
);
296 int ms_since(struct timeval
*start
);
299 struct symbol
*get_real_base_type(struct symbol
*sym
);
300 int type_bits(struct symbol
*type
);
301 int type_positive_bits(struct symbol
*type
);
302 struct symbol
*get_pointer_type(struct expression
*expr
);
303 struct symbol
*get_type(struct expression
*expr
);
304 int type_unsigned(struct symbol
*base_type
);
305 int type_signed(struct symbol
*base_type
);
306 int expr_unsigned(struct expression
*expr
);
307 int returns_unsigned(struct symbol
*base_type
);
308 int is_pointer(struct expression
*expr
);
309 int returns_pointer(struct symbol
*base_type
);
310 sval_t
sval_type_max(struct symbol
*base_type
);
311 sval_t
sval_type_min(struct symbol
*base_type
);
312 int nr_bits(struct expression
*expr
);
313 int is_void_pointer(struct expression
*expr
);
314 int is_char_pointer(struct expression
*expr
);
315 int is_static(struct expression
*expr
);
316 int types_equiv(struct symbol
*one
, struct symbol
*two
);
318 const char *global_static();
319 struct symbol
*cur_func_return_type(void);
320 struct symbol
*get_arg_type(struct expression
*fn
, int arg
);
321 struct symbol
*get_member_type_from_key(struct expression
*expr
, char *key
);
323 /* smatch_ignore.c */
324 void add_ignore(int owner
, const char *name
, struct symbol
*sym
);
325 int is_ignored(int owner
, const char *name
, struct symbol
*sym
);
328 struct var_sym
*alloc_var_sym(const char *var
, struct symbol
*sym
);
329 struct var_sym_list
*expr_to_vsl(struct expression
*expr
);
330 void add_var_sym(struct var_sym_list
**list
, const char *var
, struct symbol
*sym
);
331 void add_var_sym_expr(struct var_sym_list
**list
, struct expression
*expr
);
332 void del_var_sym(struct var_sym_list
**list
, const char *var
, struct symbol
*sym
);
333 int in_var_sym_list(struct var_sym_list
*list
, const char *var
, struct symbol
*sym
);
334 struct var_sym_list
*clone_var_sym_list(struct var_sym_list
*from_vsl
);
335 void merge_var_sym_list(struct var_sym_list
**dest
, struct var_sym_list
*src
);
336 struct var_sym_list
*combine_var_sym_lists(struct var_sym_list
*one
, struct var_sym_list
*two
);
337 void free_var_sym_list(struct var_sym_list
**list
);
338 void free_var_syms_and_list(struct var_sym_list
**list
);
341 struct tracker
*alloc_tracker(int owner
, const char *name
, struct symbol
*sym
);
342 void add_tracker(struct tracker_list
**list
, int owner
, const char *name
,
344 void add_tracker_expr(struct tracker_list
**list
, int owner
, struct expression
*expr
);
345 void del_tracker(struct tracker_list
**list
, int owner
, const char *name
,
347 int in_tracker_list(struct tracker_list
*list
, int owner
, const char *name
,
349 void free_tracker_list(struct tracker_list
**list
);
350 void free_trackers_and_list(struct tracker_list
**list
);
352 /* smatch_conditions */
353 int in_condition(void);
357 extern int __in_fake_assign
;
358 void smatch (int argc
, char **argv
);
359 int inside_loop(void);
360 int definitely_inside_loop(void);
361 struct expression
*get_switch_expr(void);
362 int in_expression_statement(void);
363 void __process_post_op_stack(void);
364 void __split_expr(struct expression
*expr
);
365 void __split_stmt(struct statement
*stmt
);
366 extern int __in_function_def
;
367 extern int option_assume_loops
;
368 extern int option_known_conditions
;
369 extern int option_two_passes
;
370 extern int option_no_db
;
371 extern int option_file_output
;
372 extern int option_time
;
373 extern struct expression_list
*big_expression_stack
;
374 extern struct statement_list
*big_statement_stack
;
375 int inlinable(struct expression
*expr
);
376 extern int __inline_call
;
377 extern struct expression
*__inline_fn
;
378 extern int __in_pre_condition
;
379 extern int __bail_on_rest_of_function
;
381 /* smatch_struct_assignment.c */
387 void __struct_members_copy(int mode
, struct expression
*left
, struct expression
*right
);
388 void __fake_struct_member_assignments(struct expression
*expr
);
390 /* smatch_project.c */
391 int is_no_inline_function(const char *function
);
393 /* smatch_conditions */
394 void __split_whole_condition(struct expression
*expr
);
395 void __handle_logic(struct expression
*expr
);
396 int is_condition(struct expression
*expr
);
397 int __handle_condition_assigns(struct expression
*expr
);
398 int __handle_select_assigns(struct expression
*expr
);
399 int __handle_expr_statement_assigns(struct expression
*expr
);
401 /* smatch_implied.c */
402 extern int option_debug_implied
;
403 extern int option_debug_related
;
404 extern int option_no_implied
;
405 struct range_list_stack
;
406 struct state_list
*__implied_case_slist(struct expression
*switch_expr
,
407 struct expression
*case_expr
,
408 struct range_list_stack
**remaining_cases
,
409 struct state_list
**raw_slist
);
410 struct range_list
*__get_implied_values(struct expression
*switch_expr
);
411 void overwrite_states_using_pool(struct sm_state
*sm
);
413 /* smatch_extras.c */
414 #define SMATCH_EXTRA 1 /* this is my_id from smatch extra set in smatch.c */
421 static const long long valid_ptr_max
= LONG_MAX
;
422 static const long long valid_ptr_min
= 4096;
423 static const sval_t valid_ptr_max_sval
= {
427 static const sval_t valid_ptr_min_sval
= {
432 /* smatch_absolute.c */
433 int get_absolute_min_helper(struct expression
*expr
, sval_t
*sval
);
434 int get_absolute_max_helper(struct expression
*expr
, sval_t
*sval
);
436 /* smatch_local_values.c */
437 int get_local_rl(struct expression
*expr
, struct range_list
**rl
);
438 int get_local_max_helper(struct expression
*expr
, sval_t
*sval
);
439 int get_local_min_helper(struct expression
*expr
, sval_t
*sval
);
441 /* smatch_type_value.c */
442 int get_db_type_rl(struct expression
*expr
, struct range_list
**rl
);
444 /* smatch_states.c */
445 void __push_fake_cur_slist();
446 struct state_list
*__pop_fake_cur_slist();
447 void __free_fake_cur_slist();
448 void __set_fake_cur_slist_fast(struct state_list
*slist
);
449 void __pop_fake_cur_slist_fast(void);
450 void __merge_slist_into_cur(struct state_list
*slist
);
452 int unreachable(void);
453 void __set_sm(struct sm_state
*sm
);
454 struct state_list
*__get_cur_slist(void);
455 void __set_true_false_sm(struct sm_state
*true_state
,
456 struct sm_state
*false_state
);
457 void nullify_path(void);
458 void __match_nullify_path_hook(const char *fn
, struct expression
*expr
,
460 void __unnullify_path(void);
461 int __path_is_null(void);
462 void save_all_states(void);
463 void nullify_all_states(void);
464 void restore_all_states(void);
465 void clear_all_states(void);
467 struct sm_state
*get_sm_state(int owner
, const char *name
,
469 struct sm_state
*get_sm_state_expr(int owner
, struct expression
*expr
);
470 void __push_true_states(void);
471 void __use_false_states(void);
472 void __discard_false_states(void);
473 void __merge_false_states(void);
474 void __merge_true_states(void);
476 void __negate_cond_stacks(void);
477 void __use_pre_cond_states(void);
478 void __use_cond_true_states(void);
479 void __use_cond_false_states(void);
480 void __push_cond_stacks(void);
481 struct state_list
*__copy_cond_true_states(void);
482 struct state_list
*__copy_cond_false_states(void);
483 struct state_list
*__pop_cond_true_stack(void);
484 struct state_list
*__pop_cond_false_stack(void);
485 void __and_cond_states(void);
486 void __or_cond_states(void);
487 void __save_pre_cond_states(void);
488 void __discard_pre_cond_states(void);
489 void __use_cond_states(void);
490 extern struct state_list
*__last_base_slist
;
492 void __warn_on_silly_pre_loops(void);
494 void __push_continues(void);
495 void __discard_continues(void);
496 void __process_continues(void);
497 void __merge_continues(void);
499 void __push_breaks(void);
500 void __process_breaks(void);
501 int __has_breaks(void);
502 void __merge_breaks(void);
503 void __use_breaks(void);
505 void __save_switch_states(struct expression
*switch_expr
);
506 void __discard_switches(void);
507 void __merge_switches(struct expression
*switch_expr
, struct expression
*case_expr
);
508 void __push_default(void);
509 void __set_default(void);
510 int __pop_default(void);
512 void __push_conditions(void);
513 void __discard_conditions(void);
515 void __save_gotos(const char *name
);
516 void __merge_gotos(const char *name
);
518 void __print_cur_slist(void);
521 void __pass_to_client(void *data
, enum hook_type type
);
522 void __pass_to_client_no_data(enum hook_type type
);
523 void __pass_case_to_client(struct expression
*switch_expr
,
524 struct expression
*case_expr
);
525 int __has_merge_function(int client_id
);
526 struct smatch_state
*__client_merge_function(int owner
,
527 struct smatch_state
*s1
,
528 struct smatch_state
*s2
);
529 struct smatch_state
*__client_unmatched_state_function(struct sm_state
*sm
);
530 void __push_scope_hooks(void);
531 void __call_scope_hooks(void);
533 /* smatch_function_hooks.c */
534 void create_function_hook_hash(void);
535 void __match_initializer_call(struct symbol
*sym
);
541 * Changing these numbers is a pain. Don't do it. If you ever use a
542 * number it can't be re-used right away so there may be gaps.
543 * We select these in order by type so if the order matters, then give
544 * it a number below 100-999,9000-9999 ranges. */
557 LOCK_RELEASED
= 1009,
558 ABSOLUTE_LIMITS
= 1010,
559 LIMITED_VALUE
= 1011,
567 void debug_sql(const char *sql
);
568 void select_caller_info_hook(void (*callback
)(const char *name
, struct symbol
*sym
, char *key
, char *value
), int type
);
569 void add_member_info_callback(int owner
, void (*callback
)(struct expression
*call
, int param
, char *printed_name
, struct smatch_state
*state
));
570 void add_split_return_callback(void (*fn
)(int return_id
, char *return_ranges
, struct expression
*returned_expr
));
571 void add_returned_member_callback(int owner
, void (*callback
)(int return_id
, char *return_ranges
, char *printed_name
, struct smatch_state
*state
));
572 void select_call_implies_hook(int type
, void (*callback
)(struct expression
*arg
, char *value
));
573 struct range_list
*db_return_vals(struct expression
*expr
);
574 char *return_state_to_var_sym(struct expression
*expr
, int param
, char *key
, struct symbol
**sym
);
575 char *get_variable_from_key(struct expression
*arg
, char *key
, struct symbol
**sym
);
576 const char *get_param_name(struct sm_state
*sm
);
578 #define run_sql(call_back, sql...) \
580 char sql_txt[1024]; \
583 snprintf(sql_txt, 1024, sql); \
584 debug_sql(sql_txt); \
585 sql_exec(call_back, sql_txt); \
588 /* like run_sql() but for the in-memory database */
589 #define mem_sql(call_back, sql...) \
591 char sql_txt[1024]; \
593 snprintf(sql_txt, sizeof(sql_txt), sql); \
594 sm_debug("in-mem: %s\n", sql_txt); \
595 sql_mem_exec(call_back, sql_txt); \
598 void sql_insert_return_states(int return_id
, const char *return_ranges
,
599 int type
, int param
, const char *key
, const char *value
);
600 void sql_insert_caller_info(struct expression
*call
, int type
, int param
,
601 const char *key
, const char *value
);
602 void sql_insert_function_ptr(const char *fn
, const char *struct_name
);
603 void sql_insert_return_values(const char *return_values
);
604 void sql_insert_call_implies(int type
, int param
, int value
);
605 void sql_insert_function_type_size(const char *member
, const char *ranges
);
606 void sql_insert_local_values(const char *name
, const char *value
);
607 void sql_insert_function_type_value(const char *type
, const char *value
);
609 void sql_select_return_states(const char *cols
, struct expression
*call
,
610 int (*callback
)(void*, int, char**, char**));
611 void sql_select_caller_info(const char *cols
, struct symbol
*sym
,
612 int (*callback
)(void*, int, char**, char**));
613 void sql_select_call_implies(const char *cols
, struct expression
*call
,
614 int (*callback
)(void*, int, char**, char**));
616 void sql_exec(int (*callback
)(void*, int, char**, char**), const char *sql
);
617 void sql_mem_exec(int (*callback
)(void*, int, char**, char**), const char *sql
);
619 void open_smatch_db(void);
622 int open_data_file(const char *filename
);
623 struct token
*get_tokens_file(const char *filename
);
626 extern char *option_debug_check
;
627 extern char *option_project_str
;
628 extern char *data_dir
;
629 extern int option_no_data
;
630 extern int option_spammy
;
631 extern int option_full_path
;
632 extern int option_param_mapper
;
633 extern int option_call_tree
;
634 extern int num_checks
;
641 extern enum project_type option_project
;
642 const char *check_name(unsigned short id
);
645 /* smatch_buf_size.c */
646 int get_array_size(struct expression
*expr
);
647 int get_array_size_bytes(struct expression
*expr
);
648 int get_array_size_bytes_min(struct expression
*expr
);
649 int get_array_size_bytes_max(struct expression
*expr
);
650 struct range_list
*get_array_size_bytes_rl(struct expression
*expr
);
651 int get_real_array_size(struct expression
*expr
);
652 /* smatch_strlen.c */
653 int get_implied_strlen(struct expression
*expr
, struct range_list
**rl
);
654 int get_size_from_strlen(struct expression
*expr
);
656 /* smatch_capped.c */
657 int is_capped(struct expression
*expr
);
658 int is_capped_var_sym(const char *name
, struct symbol
*sym
);
660 /* check_user_data.c */
661 int is_user_macro(struct expression
*expr
);
662 int is_user_data(struct expression
*expr
);
663 int is_capped_user_data(struct expression
*expr
);
665 /* check_locking.c */
666 void print_held_locks();
668 /* check_assigned_expr.c */
669 struct expression
*get_assigned_expr(struct expression
*expr
);
671 /* smatch_comparison.c */
672 int get_comparison(struct expression
*left
, struct expression
*right
);
673 int get_comparison_strings(const char *one
, const char *two
);
674 void __add_comparison_info(struct expression
*expr
, struct expression
*call
, const char *range
);
675 char *expr_equal_to_param(struct expression
*expr
);
676 char *expr_lte_to_param(struct expression
*expr
);
679 sval_t
*sval_alloc(sval_t sval
);
680 sval_t
*sval_alloc_permanent(sval_t sval
);
681 sval_t
sval_blank(struct expression
*expr
);
682 sval_t
sval_type_val(struct symbol
*type
, long long val
);
683 sval_t
sval_from_val(struct expression
*expr
, long long val
);
684 int sval_unsigned(sval_t sval
);
685 int sval_signed(sval_t sval
);
686 int sval_bits(sval_t sval
);
687 int sval_positive_bits(sval_t sval
);
688 int sval_bits_used(sval_t sval
);
689 int sval_is_negative(sval_t sval
);
690 int sval_is_positive(sval_t sval
);
691 int sval_is_min(sval_t sval
);
692 int sval_is_max(sval_t sval
);
693 int sval_is_a_min(sval_t sval
);
694 int sval_is_a_max(sval_t sval
);
695 int sval_is_negative_min(sval_t sval
);
696 int sval_cmp(sval_t one
, sval_t two
);
697 int sval_cmp_t(struct symbol
*type
, sval_t one
, sval_t two
);
698 int sval_cmp_val(sval_t one
, long long val
);
699 sval_t
sval_min(sval_t one
, sval_t two
);
700 sval_t
sval_max(sval_t one
, sval_t two
);
701 int sval_too_low(struct symbol
*type
, sval_t sval
);
702 int sval_too_high(struct symbol
*type
, sval_t sval
);
703 int sval_fits(struct symbol
*type
, sval_t sval
);
704 sval_t
sval_cast(struct symbol
*type
, sval_t sval
);
705 sval_t
sval_preop(sval_t sval
, int op
);
706 sval_t
sval_binop(sval_t left
, int op
, sval_t right
);
707 int sval_binop_overflows(sval_t left
, int op
, sval_t right
);
708 const char *sval_to_str(sval_t sval
);
709 const char *sval_to_numstr(sval_t sval
);
710 sval_t
ll_to_sval(long long val
);
712 /* smatch_string_list.c */
713 int list_has_string(struct string_list
*str_list
, char *str
);
714 void insert_string(struct string_list
**str_list
, char *str
);
715 struct string_list
*clone_str_list(struct string_list
*orig
);
716 struct string_list
*combine_string_lists(struct string_list
*one
, struct string_list
*two
);
718 /* smatch_clear_buffer.c */
719 int is_uninitialized(struct expression
*expr
);
720 int has_uninitialized_members(struct expression
*expr
);
722 /* smatch_start_states.c */
723 struct state_list
*get_start_states(void);
725 /* smatch_recurse.c */
726 int has_symbol(struct expression
*expr
, struct symbol
*sym
);
727 int has_variable(struct expression
*expr
, struct expression
*var
);
728 int has_inc_dec(struct expression
*expr
);
730 /* smatch_stored_conditions.c */
731 struct smatch_state
*get_stored_condition(struct expression
*expr
);
733 /* check_string_len.c */
734 int get_formatted_string_size(struct expression
*call
, int arg
);
736 #endif /* !SMATCH_H_ */