4 * Copyright (C) 2006 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
19 #include "expression.h"
26 #define STATE(_x) static struct smatch_state _x = { .name = #_x }
27 extern struct smatch_state undefined
;
28 extern struct smatch_state true_state
;
29 extern struct smatch_state false_state
;
37 ASSIGNMENT_AFTER_HOOK
,
41 FUNCTION_CALL_AFTER_HOOK
,
50 void add_hook(void *func
, enum hook_type type
);
51 typedef struct smatch_state
*(merge_func_t
)(const char *name
, struct symbol
*sym
, struct smatch_state
*s1
,
52 struct smatch_state
*s2
);
53 void add_merge_hook(int client_id
, merge_func_t
*func
);
55 #define smatch_msg(msg...) \
57 printf("%s +%d %s(%d) ", get_filename(), get_lineno(), \
58 get_function(), get_func_pos()); \
63 #define SM_DEBUG(msg...) do { if (debug_states) printf(msg); } while (0)
65 #define UNDEFINED INT_MIN
67 struct smatch_state
*get_state(const char *name
, int owner
, struct symbol
*sym
);
68 void add_state(const char *name
, int owner
, struct symbol
*sym
, struct smatch_state
*state
);
69 void set_state(const char *name
, int owner
, struct symbol
*sym
, struct smatch_state
*state
);
70 void delete_state(const char *name
, int owner
, struct symbol
*sym
);
71 void set_true_false_states(const char *name
, int owner
, struct symbol
*sym
,
72 struct smatch_state
*true_state
, struct smatch_state
*false_state
);
73 int state_defined(const char *name
, int owner
, struct symbol
*sym
);
75 struct state_list
*get_all_states();
77 void __unnullify_path();
78 void clear_all_states();
86 char *alloc_string(char *str
);
87 void free_string(char *str
);
88 struct expression
*get_argument_from_call_expr(struct expression_list
*args
,
90 char * get_variable_from_expr(struct expression
* expr
,
91 struct symbol
**sym_ptr
);
92 char * get_variable_from_expr_simple(struct expression
* expr
,
93 struct symbol
**sym_ptr
);
94 int sym_name_is(const char *name
, struct expression
*expr
);
95 int get_value(struct expression
*expr
, int *discard
);
96 int is_zero(struct expression
*expr
);
97 const char *show_state(struct smatch_state
*state
);
98 struct expression
*strip_expr(struct expression
*expr
);
100 /* ----------------------------------------------------------------
101 The stuff below is all used internally and shouldn't
102 be called from other programs
103 -----------------------------------------------------------------*/
107 void smatch (int argc
, char **argv
);
108 void __split_expr(struct expression
*expr
);
110 /* smatch_conditions */
112 void __split_whole_condition(struct expression
*expr
);
114 /* smatch_extras.c */
115 int known_condition_true(struct expression
*expr
);
117 /* smatch_ignore.c */
118 void add_ignore(const char *name
, int owner
, struct symbol
*sym
);
119 int is_ignored(const char *name
, int owner
, struct symbol
*sym
);
121 /* smatch_states.c */
123 extern int debug_states
;
125 void __use_false_only_stack();
126 void __pop_false_only_stack();
127 void __push_true_states();
128 void __use_false_states();
129 void __pop_false_states();
130 void __merge_false_states();
131 void __merge_true_states();
133 void __negate_cond_stacks();
134 void __use_cond_true_states();
135 void __use_cond_false_states();
136 void __push_cond_stacks();
137 void __and_cond_states();
138 void __or_cond_states();
139 void __save_pre_cond_states();
140 void __pop_pre_cond_states();
141 void __use_cond_states();
143 void __push_continues();
144 void __pop_continues();
145 void __process_continues();
146 void __merge_continues();
148 void __push_breaks();
149 void __process_breaks();
150 void __merge_breaks();
153 void __save_switch_states();
154 void __pop_switches();
155 void __merge_switches();
156 void __push_default();
157 void __set_default();
160 void __push_conditions();
161 void __pop_conditions();
162 void __overwrite_true_states();
164 void __save_gotos(const char *name
);
165 void __merge_gotos(const char *name
);
167 void __print_cur_slist();
170 void __pass_to_client(void *data
, enum hook_type type
);
171 void __pass_to_client_no_data(enum hook_type type
);
172 void __pass_declarations_to_client(struct symbol_list
*sym_list
);
173 int __has_merge_function(int client_id
);
174 struct smatch_state
*__client_merge_function(int owner
, const char *name
, struct symbol
*sym
,
175 struct smatch_state
*s1
, struct smatch_state
*s2
);
177 #endif /* !SMATCH_H_ */