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()); \
67 int get_state(const char *name
, int owner
, struct symbol
*sym
);
68 void add_state(const char *name
, int owner
, struct symbol
*sym
, int state
);
69 void set_state(const char *name
, int owner
, struct symbol
*sym
, int 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 int true_state
, int false_state
);
73 int state_defined(const char *name
, int owner
, struct symbol
*sym
);
75 struct state_list
*get_all_states();
77 void clear_all_states();
85 char *alloc_string(char *str
);
86 void free_string(char *str
);
87 struct expression
*get_argument_from_call_expr(struct expression_list
*args
,
89 char * get_variable_from_expr(struct expression
* expr
,
90 struct symbol
**sym_ptr
);
91 char * get_variable_from_expr_simple(struct expression
* expr
,
92 struct symbol
**sym_ptr
);
94 /* ----------------------------------------------------------------
95 The stuff below is all used internally and shouldn't
96 be called from other programs
97 -----------------------------------------------------------------*/
104 void smatch (int argc
, char **argv
);
105 void split_conditions(struct expression
*expr
);
106 unsigned int get_path_id();
108 /* smatch_states.c */
110 void __first_and_clump();
111 void __merge_and_clump();
112 void __use_and_clumps();
113 void __split_true_false_paths();
114 void __split_false_states_mini();
115 void __use_false_states_mini();
116 void __pop_false_states_mini();
117 void __use_true_states();
118 void __use_false_states();
119 void __pop_false_states();
120 void __merge_false_states();
121 void __merge_true_states();
122 void __pop_true_states();
124 void __push_continues();
125 void __pop_continues();
126 void __process_continues();
127 void __merge_continues();
129 void __push_breaks();
131 void __process_breaks();
132 void __merge_breaks();
134 void __save_switch_states();
135 void __pop_switches();
136 void __merge_switches();
137 void __push_default();
138 void __set_default();
141 void __push_conditions();
142 void __pop_conditions();
143 void __overwrite_true_states();
145 void __save_gotos(const char *name
);
146 void __merge_gotos(const char *name
);
149 void __pass_to_client(void *data
, enum hook_type type
);
150 void __pass_declarations_to_client(struct symbol_list
*sym_list
);
151 int __has_merge_function(int client_id
);
152 int __client_merge_function(int owner
, const char *name
, struct symbol
*sym
,
155 #endif /* !SMATCH_H_ */