19 * If you have code like:
20 * do {
21 * if (xxx)
22 * continue;
23 * while (0);
24 *
25 * Then the continue is equivalent of a break. So what was really intended?
26 */
27
28 #include "smatch.h"
29 #include "smatch_slist.h"
30
31 static int my_id;
32
33 static struct statement_list *iterator_stack;
34
35 static int is_do_while_zero(struct statement *stmt)
36 {
37 if (!stmt->iterator_post_condition)
38 return 0;
39 if (!is_zero(stmt->iterator_post_condition))
40 return 0;
41 return 1;
42 }
43
44 static void push_statement(struct statement_list **stack, struct statement *stmt)
45 {
46 add_ptr_list(stack, stmt);
47 }
48
49 static void pop_statement(struct statement_list **stack)
50 {
51 delete_ptr_list_last((struct ptr_list **)stack);
52 }
53
54 static int inside_do_while_zero(void)
55 {
56 struct statement *stmt;
57
58 stmt = last_ptr_list((struct ptr_list *)iterator_stack);
59 return !!stmt;
|
19 * If you have code like:
20 * do {
21 * if (xxx)
22 * continue;
23 * while (0);
24 *
25 * Then the continue is equivalent of a break. So what was really intended?
26 */
27
28 #include "smatch.h"
29 #include "smatch_slist.h"
30
31 static int my_id;
32
33 static struct statement_list *iterator_stack;
34
35 static int is_do_while_zero(struct statement *stmt)
36 {
37 if (!stmt->iterator_post_condition)
38 return 0;
39 if (!expr_is_zero(stmt->iterator_post_condition))
40 return 0;
41 return 1;
42 }
43
44 static void push_statement(struct statement_list **stack, struct statement *stmt)
45 {
46 add_ptr_list(stack, stmt);
47 }
48
49 static void pop_statement(struct statement_list **stack)
50 {
51 delete_ptr_list_last((struct ptr_list **)stack);
52 }
53
54 static int inside_do_while_zero(void)
55 {
56 struct statement *stmt;
57
58 stmt = last_ptr_list((struct ptr_list *)iterator_stack);
59 return !!stmt;
|