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
,
49 void add_hook(void *func
, enum hook_type type
);
50 typedef struct smatch_state
*(merge_func_t
)(const char *name
, struct symbol
*sym
, struct smatch_state
*s1
,
51 struct smatch_state
*s2
);
52 void add_merge_hook(int client_id
, merge_func_t
*func
);
54 #define smatch_msg(msg...) \
56 printf("%s %d %s(%d) ", get_filename(), get_lineno(), \
57 get_function(), get_func_pos()); \
62 #define SM_DEBUG(msg...) do { if (debug_states) printf(msg); } while (0)
64 #define UNDEFINED INT_MIN
66 struct smatch_state
*get_state(const char *name
, int owner
, struct symbol
*sym
);
67 void add_state(const char *name
, int owner
, struct symbol
*sym
, struct smatch_state
*state
);
68 void set_state(const char *name
, int owner
, struct symbol
*sym
, struct smatch_state
*state
);
69 void delete_state(const char *name
, int owner
, struct symbol
*sym
);
70 void set_true_false_states(const char *name
, int owner
, struct symbol
*sym
,
71 struct smatch_state
*true_state
, struct smatch_state
*false_state
);
72 int state_defined(const char *name
, int owner
, struct symbol
*sym
);
74 struct state_list
*get_all_states();
76 void __unnullify_path();
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
);
93 int sym_name_is(const char *name
, struct expression
*expr
);
94 int get_value(struct expression
*expr
, int *discard
);
95 int is_zero(struct expression
*expr
);
97 /* ----------------------------------------------------------------
98 The stuff below is all used internally and shouldn't
99 be called from other programs
100 -----------------------------------------------------------------*/
104 void smatch (int argc
, char **argv
);
105 void __split_expr(struct expression
*expr
);
107 /* smatch_conditions */
108 void __split_whole_condition(struct expression
*expr
);
110 /* smatch_extras.c */
111 int known_condition_true(struct expression
*expr
);
113 /* smatch_states.c */
115 extern int debug_states
;
117 void __use_false_only_stack();
118 void __pop_false_only_stack();
119 void __push_true_states();
120 void __use_false_states();
121 void __pop_false_states();
122 void __merge_false_states();
123 void __merge_true_states();
125 void __negate_cond_stacks();
126 void __use_cond_true_states();
127 void __use_cond_false_states();
128 void __push_cond_stacks();
129 void __and_cond_states();
130 void __or_cond_states();
131 void __save_pre_cond_states();
132 void __pop_pre_cond_states();
133 void __use_cond_states();
135 void __push_continues();
136 void __pop_continues();
137 void __process_continues();
138 void __merge_continues();
140 void __push_breaks();
141 void __process_breaks();
142 void __merge_breaks();
145 void __save_switch_states();
146 void __pop_switches();
147 void __merge_switches();
148 void __push_default();
149 void __set_default();
152 void __push_conditions();
153 void __pop_conditions();
154 void __overwrite_true_states();
156 void __save_gotos(const char *name
);
157 void __merge_gotos(const char *name
);
159 void __print_cur_slist();
162 void __pass_to_client(void *data
, enum hook_type type
);
163 void __pass_declarations_to_client(struct symbol_list
*sym_list
);
164 int __has_merge_function(int client_id
);
165 struct smatch_state
*__client_merge_function(int owner
, const char *name
, struct symbol
*sym
,
166 struct smatch_state
*s1
, struct smatch_state
*s2
);
168 #endif /* !SMATCH_H_ */