4 * Copyright (C) 2006 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
18 #include "expression.h"
22 struct state_history
{
25 DECLARE_PTR_LIST(history_list
, struct state_history
);
32 struct history_list
*line_history
;
33 struct history_list
*path_history
;
42 ASSIGNMENT_AFTER_HOOK
,
46 FUNCTION_CALL_AFTER_HOOK
,
53 void add_hook(void *func
, enum hook_type type
);
54 typedef int (merge_func_t
)(const char *name
, struct symbol
*sym
, int s1
,
56 void add_merge_hook(int client_id
, merge_func_t
*func
);
58 #define smatch_msg(msg...) \
60 printf("%s %d %s(%d) ", get_filename(), get_lineno(), \
61 get_function(), get_func_pos()); \
66 #define SM_DEBUG(msg...) do { if (debug_states) printf(msg); } while (0)
71 int get_state(const char *name
, int owner
, struct symbol
*sym
);
72 void add_state(const char *name
, int owner
, struct symbol
*sym
, int state
);
73 void set_state(const char *name
, int owner
, struct symbol
*sym
, int state
);
74 void delete_state(const char *name
, int owner
, struct symbol
*sym
);
75 void set_true_false_states(const char *name
, int owner
, struct symbol
*sym
,
76 int true_state
, int false_state
);
77 int state_defined(const char *name
, int owner
, struct symbol
*sym
);
79 struct state_list
*get_all_states();
81 void clear_all_states();
89 char *alloc_string(char *str
);
90 void free_string(char *str
);
91 struct expression
*get_argument_from_call_expr(struct expression_list
*args
,
93 char * get_variable_from_expr(struct expression
* expr
,
94 struct symbol
**sym_ptr
);
95 char * get_variable_from_expr_simple(struct expression
* expr
,
96 struct symbol
**sym_ptr
);
97 int sym_name_is(const char *name
, struct expression
*expr
);
99 /* ----------------------------------------------------------------
100 The stuff below is all used internally and shouldn't
101 be called from other programs
102 -----------------------------------------------------------------*/
106 void smatch (int argc
, char **argv
);
107 void __split_expr(struct expression
*expr
);
109 /* smatch_conditions */
113 void __split_whole_condition(struct expression
*expr
);
115 /* smatch_states.c */
117 extern int debug_states
;
119 void __prep_false_only_stack();
120 void __use_false_only_stack();
121 void __use_true_states();
122 void __use_false_states();
123 void __pop_false_states();
124 void __merge_false_states();
125 void __merge_true_states();
126 void __pop_true_states();
128 void __negate_cond_stacks();
129 void __use_cond_true_states();
130 void __use_cond_false_states();
131 void __push_cond_stacks();
132 void __and_cond_states();
133 void __or_cond_states();
134 void __save_pre_cond_states();
135 void __pop_pre_cond_states();
136 void __use_cond_states();
138 void __push_continues();
139 void __pop_continues();
140 void __process_continues();
141 void __merge_continues();
143 void __push_breaks();
145 void __process_breaks();
146 void __merge_breaks();
148 void __save_switch_states();
149 void __pop_switches();
150 void __merge_switches();
151 void __push_default();
152 void __set_default();
155 void __push_conditions();
156 void __pop_conditions();
157 void __overwrite_true_states();
159 void __save_gotos(const char *name
);
160 void __merge_gotos(const char *name
);
162 void __print_cur_slist();
165 void __pass_to_client(void *data
, enum hook_type type
);
166 void __pass_declarations_to_client(struct symbol_list
*sym_list
);
167 int __has_merge_function(int client_id
);
168 int __client_merge_function(int owner
, const char *name
, struct symbol
*sym
,
171 #endif /* !SMATCH_H_ */