Print this page
new smatch
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/parse.h
+++ new/usr/src/tools/smatch/src/parse.h
1 1 #ifndef PARSE_H
2 2 #define PARSE_H
3 3 /*
4 4 * Basic parsing data structures. Statements and symbols.
5 5 *
6 6 * Copyright (C) 2003 Transmeta Corp.
7 7 * 2003 Linus Torvalds
8 8 *
9 9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 10 * of this software and associated documentation files (the "Software"), to deal
11 11 * in the Software without restriction, including without limitation the rights
12 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 13 * copies of the Software, and to permit persons to whom the Software is
14 14 * furnished to do so, subject to the following conditions:
15 15 *
16 16 * The above copyright notice and this permission notice shall be included in
17 17 * all copies or substantial portions of the Software.
18 18 *
19 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 25 * THE SOFTWARE.
26 26 */
27 27
28 28 #include "symbol.h"
29 29
30 30 enum statement_type {
31 31 STMT_NONE,
32 32 STMT_DECLARATION,
33 33 STMT_EXPRESSION,
34 34 STMT_COMPOUND,
35 35 STMT_IF,
36 36 STMT_RETURN,
37 37 STMT_CASE,
38 38 STMT_SWITCH,
39 39 STMT_ITERATOR,
40 40 STMT_LABEL,
41 41 STMT_GOTO,
42 42 STMT_ASM,
43 43 STMT_CONTEXT,
44 44 STMT_RANGE,
45 45 };
46 46
47 47 struct statement {
48 48 enum statement_type type;
49 49 struct position pos;
50 50 struct statement *parent;
51 51 union {
52 52 struct /* declaration */ {
53 53 struct symbol_list *declaration;
54 54 };
55 55 struct /* context */ {
56 56 struct expression *expression;
57 57 struct expression *context;
58 58 };
59 59 struct /* return_statement */ {
60 60 struct expression *ret_value;
61 61 struct symbol *ret_target;
62 62 };
63 63 struct /* if_statement */ {
64 64 struct expression *if_conditional;
65 65 struct statement *if_true;
66 66 struct statement *if_false;
67 67 };
68 68 struct /* compound_struct */ {
69 69 struct statement_list *stmts;
70 70 struct symbol *ret;
71 71 struct symbol *inline_fn;
72 72 struct statement *args;
73 73 };
74 74 struct /* labeled_struct */ {
75 75 struct symbol *label_identifier;
76 76 struct statement *label_statement;
77 77 };
78 78 struct /* case_struct */ {
79 79 struct expression *case_expression;
80 80 struct expression *case_to;
81 81 struct statement *case_statement;
82 82 struct symbol *case_label;
83 83 };
84 84 struct /* switch_struct */ {
85 85 struct expression *switch_expression;
86 86 struct statement *switch_statement;
87 87 struct symbol *switch_break, *switch_case;
88 88 };
89 89 struct /* iterator_struct */ {
90 90 struct symbol *iterator_break;
91 91 struct symbol *iterator_continue;
92 92 struct symbol_list *iterator_syms;
93 93 struct statement *iterator_pre_statement;
94 94 struct expression *iterator_pre_condition;
95 95
96 96 struct statement *iterator_statement;
97 97
98 98 struct statement *iterator_post_statement;
99 99 struct expression *iterator_post_condition;
100 100 };
101 101 struct /* goto_struct */ {
102 102 struct symbol *goto_label;
103 103
104 104 /* computed gotos have these: */
105 105 struct expression *goto_expression;
106 106 struct symbol_list *target_list;
107 107 };
108 108 struct /* asm */ {
109 109 struct expression *asm_string;
110 110 struct expression_list *asm_outputs;
111 111 struct expression_list *asm_inputs;
112 112 struct expression_list *asm_clobbers;
113 113 struct symbol_list *asm_labels;
114 114 };
115 115 struct /* range */ {
116 116 struct expression *range_expression;
117 117 struct expression *range_low;
118 118 struct expression *range_high;
119 119 };
120 120 };
121 121 };
122 122
123 123 extern struct symbol_list *function_computed_target_list;
124 124 extern struct statement_list *function_computed_goto_list;
125 125
126 126 extern struct token *parse_expression(struct token *, struct expression **);
127 127 extern struct symbol *label_symbol(struct token *token);
↓ open down ↓ |
127 lines elided |
↑ open up ↑ |
128 128
129 129 extern int show_statement(struct statement *);
130 130 extern void show_statement_list(struct statement_list *, const char *);
131 131 extern int show_expression(struct expression *);
132 132
133 133 typedef void (*validate_decl_t)(struct symbol *decl);
134 134 extern struct token *external_declaration(struct token *, struct symbol_list **, validate_decl_t);
135 135
136 136 extern struct symbol *ctype_integer(int size, int want_unsigned);
137 137
138 -extern void copy_statement(struct statement *src, struct statement *dst);
139 138 extern int inline_function(struct expression *expr, struct symbol *sym);
140 139 extern void uninline(struct symbol *sym);
141 140 extern void init_parser(int);
142 141
143 142 static inline void stmt_set_parent_stmt(struct statement *stmt, struct statement *parent)
144 143 {
145 144 if (!stmt)
146 145 return;
147 146 stmt->parent = parent;
148 147 }
149 148
150 149 static inline struct statement *stmt_get_parent_stmt(struct statement *stmt)
151 150 {
152 151 return stmt->parent;
153 152 }
154 153
155 154 #endif /* PARSE_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX