4 * Copyright (C) 2006 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
19 #include "expression.h"
23 struct state_history
{
26 DECLARE_PTR_LIST(history_list
, struct state_history
);
33 struct history_list
*line_history
;
34 struct history_list
*path_history
;
43 ASSIGNMENT_AFTER_HOOK
,
47 FUNCTION_CALL_AFTER_HOOK
,
55 void add_hook(void *func
, enum hook_type type
);
56 typedef int (merge_func_t
)(const char *name
, struct symbol
*sym
, int s1
,
58 void add_merge_hook(int client_id
, merge_func_t
*func
);
60 #define smatch_msg(msg...) \
62 printf("%s %d %s(%d) ", get_filename(), get_lineno(), \
63 get_function(), get_func_pos()); \
68 #define SM_DEBUG(msg...) do { if (debug_states) printf(msg); } while (0)
70 #define NOTFOUND INT_MIN
71 #define UNDEFINED INT_MIN + 1
73 int get_state(const char *name
, int owner
, struct symbol
*sym
);
74 void add_state(const char *name
, int owner
, struct symbol
*sym
, int state
);
75 void set_state(const char *name
, int owner
, struct symbol
*sym
, int state
);
76 void delete_state(const char *name
, int owner
, struct symbol
*sym
);
77 void set_true_false_states(const char *name
, int owner
, struct symbol
*sym
,
78 int true_state
, int false_state
);
79 int state_defined(const char *name
, int owner
, struct symbol
*sym
);
81 struct state_list
*get_all_states();
84 void __unnullify_path();
85 void clear_all_states();
93 char *alloc_string(char *str
);
94 void free_string(char *str
);
95 struct expression
*get_argument_from_call_expr(struct expression_list
*args
,
97 char * get_variable_from_expr(struct expression
* expr
,
98 struct symbol
**sym_ptr
);
99 char * get_variable_from_expr_simple(struct expression
* expr
,
100 struct symbol
**sym_ptr
);
101 int sym_name_is(const char *name
, struct expression
*expr
);
102 int get_value(struct expression
*expr
, int *discard
);
103 int is_zero(struct expression
*expr
);
105 /* ----------------------------------------------------------------
106 The stuff below is all used internally and shouldn't
107 be called from other programs
108 -----------------------------------------------------------------*/
112 void smatch (int argc
, char **argv
);
113 void __split_expr(struct expression
*expr
);
115 /* smatch_conditions */
116 void __split_whole_condition(struct expression
*expr
);
118 /* smatch_extras.c */
119 int known_condition_true(struct expression
*expr
);
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 int __break_called();
149 void __push_breaks();
151 void __process_breaks();
152 void __merge_breaks();
155 void __save_switch_states();
156 void __pop_switches();
157 void __merge_switches();
158 void __push_default();
159 void __set_default();
162 void __push_conditions();
163 void __pop_conditions();
164 void __overwrite_true_states();
166 void __save_gotos(const char *name
);
167 void __merge_gotos(const char *name
);
169 void __print_cur_slist();
172 void __pass_to_client(void *data
, enum hook_type type
);
173 void __pass_declarations_to_client(struct symbol_list
*sym_list
);
174 int __has_merge_function(int client_id
);
175 int __client_merge_function(int owner
, const char *name
, struct symbol
*sym
,
178 #endif /* !SMATCH_H_ */