4 * Copyright (C) 2006 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
18 #include "expression.h"
20 struct state_history
{
23 DECLARE_PTR_LIST(history_list
, struct state_history
);
30 struct history_list
*line_history
;
31 struct history_list
*path_history
;
40 ASSIGNMENT_AFTER_HOOK
,
44 FUNCTION_CALL_AFTER_HOOK
,
51 void add_hook(void *func
, enum hook_type type
);
52 typedef int (merge_func_t
)(const char *name
, struct symbol
*sym
, int s1
,
54 void add_merge_hook(int client_id
, merge_func_t
*func
);
56 #define smatch_msg(msg...) \
58 printf("%s %d %s(%d) ", get_filename(), get_lineno(), \
59 get_function(), get_func_pos()); \
64 #define SM_DEBUG(msg...) do { if (debug_states) printf(msg); } while (0)
69 int get_state(const char *name
, int owner
, struct symbol
*sym
);
70 void add_state(const char *name
, int owner
, struct symbol
*sym
, int state
);
71 void set_state(const char *name
, int owner
, struct symbol
*sym
, int state
);
72 void delete_state(const char *name
, int owner
, struct symbol
*sym
);
73 void set_true_false_states(const char *name
, int owner
, struct symbol
*sym
,
74 int true_state
, int false_state
);
75 int state_defined(const char *name
, int owner
, struct symbol
*sym
);
77 struct state_list
*get_all_states();
79 void clear_all_states();
87 char *alloc_string(char *str
);
88 void free_string(char *str
);
89 struct expression
*get_argument_from_call_expr(struct expression_list
*args
,
91 char * get_variable_from_expr(struct expression
* expr
,
92 struct symbol
**sym_ptr
);
93 char * get_variable_from_expr_simple(struct expression
* expr
,
94 struct symbol
**sym_ptr
);
96 /* ----------------------------------------------------------------
97 The stuff below is all used internally and shouldn't
98 be called from other programs
99 -----------------------------------------------------------------*/
106 void smatch (int argc
, char **argv
);
107 void split_conditions(struct expression
*expr
);
108 unsigned int get_path_id();
110 /* smatch_states.c */
112 extern int debug_states
;
114 void __first_and_clump();
115 void __merge_and_clump();
116 void __use_and_clumps();
117 void __split_true_false_paths();
118 void __split_false_states_mini();
119 void __use_false_states_mini();
120 void __pop_false_states_mini();
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 __push_continues();
129 void __pop_continues();
130 void __process_continues();
131 void __merge_continues();
133 void __push_breaks();
135 void __process_breaks();
136 void __merge_breaks();
138 void __save_switch_states();
139 void __pop_switches();
140 void __merge_switches();
141 void __push_default();
142 void __set_default();
145 void __push_conditions();
146 void __pop_conditions();
147 void __overwrite_true_states();
149 void __save_gotos(const char *name
);
150 void __merge_gotos(const char *name
);
153 void __pass_to_client(void *data
, enum hook_type type
);
154 void __pass_declarations_to_client(struct symbol_list
*sym_list
);
155 int __has_merge_function(int client_id
);
156 int __client_merge_function(int owner
, const char *name
, struct symbol
*sym
,
159 #endif /* !SMATCH_H_ */