Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-iterator.c @ 132:d34655255c78
update gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 10:21:07 +0900 |
parents | 84e7813d76e9 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
130:e108057fa461 | 132:d34655255c78 |
---|---|
1 /* Iterator routines for manipulating GENERIC and GIMPLE tree statements. | 1 /* Iterator routines for manipulating GENERIC and GIMPLE tree statements. |
2 Copyright (C) 2003-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2003-2018 Free Software Foundation, Inc. |
3 Contributed by Andrew MacLeod <amacleod@redhat.com> | 3 Contributed by Andrew MacLeod <amacleod@redhat.com> |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify | 7 GCC is free software; you can redistribute it and/or modify |
39 list = stmt_list_cache->pop (); | 39 list = stmt_list_cache->pop (); |
40 memset (list, 0, sizeof (struct tree_base)); | 40 memset (list, 0, sizeof (struct tree_base)); |
41 TREE_SET_CODE (list, STATEMENT_LIST); | 41 TREE_SET_CODE (list, STATEMENT_LIST); |
42 } | 42 } |
43 else | 43 else |
44 list = make_node (STATEMENT_LIST); | 44 { |
45 list = make_node (STATEMENT_LIST); | |
46 TREE_SIDE_EFFECTS (list) = 0; | |
47 } | |
45 TREE_TYPE (list) = void_type_node; | 48 TREE_TYPE (list) = void_type_node; |
46 return list; | 49 return list; |
47 } | 50 } |
48 | 51 |
49 void | 52 void |
87 If T is an expression with no effects, it is ignored. */ | 90 If T is an expression with no effects, it is ignored. */ |
88 | 91 |
89 void | 92 void |
90 append_to_statement_list (tree t, tree *list_p) | 93 append_to_statement_list (tree t, tree *list_p) |
91 { | 94 { |
92 if (t && TREE_SIDE_EFFECTS (t)) | 95 if (t && (TREE_SIDE_EFFECTS (t) || TREE_CODE (t) == DEBUG_BEGIN_STMT)) |
93 append_to_statement_list_1 (t, list_p); | 96 append_to_statement_list_1 (t, list_p); |
94 } | 97 } |
95 | 98 |
96 /* Similar, but the statement is always added, regardless of side effects. */ | 99 /* Similar, but the statement is always added, regardless of side effects. */ |
97 | 100 |
135 head->next = NULL; | 138 head->next = NULL; |
136 head->stmt = t; | 139 head->stmt = t; |
137 tail = head; | 140 tail = head; |
138 } | 141 } |
139 | 142 |
140 TREE_SIDE_EFFECTS (i->container) = 1; | 143 if (TREE_CODE (t) != DEBUG_BEGIN_STMT) |
144 TREE_SIDE_EFFECTS (i->container) = 1; | |
141 | 145 |
142 cur = i->ptr; | 146 cur = i->ptr; |
143 | 147 |
144 /* Link it into the list. */ | 148 /* Link it into the list. */ |
145 if (cur) | 149 if (cur) |
211 head->next = NULL; | 215 head->next = NULL; |
212 head->stmt = t; | 216 head->stmt = t; |
213 tail = head; | 217 tail = head; |
214 } | 218 } |
215 | 219 |
216 TREE_SIDE_EFFECTS (i->container) = 1; | 220 if (TREE_CODE (t) != DEBUG_BEGIN_STMT) |
221 TREE_SIDE_EFFECTS (i->container) = 1; | |
217 | 222 |
218 cur = i->ptr; | 223 cur = i->ptr; |
219 | 224 |
220 /* Link it into the list. */ | 225 /* Link it into the list. */ |
221 if (cur) | 226 if (cur) |
277 TREE_SIDE_EFFECTS (i->container) = 0; | 282 TREE_SIDE_EFFECTS (i->container) = 0; |
278 | 283 |
279 i->ptr = next; | 284 i->ptr = next; |
280 } | 285 } |
281 | 286 |
282 /* Return the first expression in a sequence of COMPOUND_EXPRs, | 287 /* Return the first expression in a sequence of COMPOUND_EXPRs, or in |
283 or in a STATEMENT_LIST. */ | 288 a STATEMENT_LIST, disregarding DEBUG_BEGIN_STMTs, recursing into a |
289 STATEMENT_LIST if that's the first non-DEBUG_BEGIN_STMT. */ | |
284 | 290 |
285 tree | 291 tree |
286 expr_first (tree expr) | 292 expr_first (tree expr) |
287 { | 293 { |
288 if (expr == NULL_TREE) | 294 if (expr == NULL_TREE) |
289 return expr; | 295 return expr; |
290 | 296 |
291 if (TREE_CODE (expr) == STATEMENT_LIST) | 297 if (TREE_CODE (expr) == STATEMENT_LIST) |
292 { | 298 { |
293 struct tree_statement_list_node *n = STATEMENT_LIST_HEAD (expr); | 299 struct tree_statement_list_node *n = STATEMENT_LIST_HEAD (expr); |
294 return n ? n->stmt : NULL_TREE; | 300 if (!n) |
301 return NULL_TREE; | |
302 while (TREE_CODE (n->stmt) == DEBUG_BEGIN_STMT) | |
303 { | |
304 n = n->next; | |
305 if (!n) | |
306 return NULL_TREE; | |
307 } | |
308 /* If the first non-debug stmt is not a statement list, we | |
309 already know it's what we're looking for. */ | |
310 if (TREE_CODE (n->stmt) != STATEMENT_LIST) | |
311 return n->stmt; | |
312 | |
313 return expr_first (n->stmt); | |
295 } | 314 } |
296 | 315 |
297 while (TREE_CODE (expr) == COMPOUND_EXPR) | 316 while (TREE_CODE (expr) == COMPOUND_EXPR) |
298 expr = TREE_OPERAND (expr, 0); | 317 expr = TREE_OPERAND (expr, 0); |
299 | 318 |
300 return expr; | 319 return expr; |
301 } | 320 } |
302 | 321 |
303 /* Return the last expression in a sequence of COMPOUND_EXPRs, | 322 /* Return the last expression in a sequence of COMPOUND_EXPRs, or in a |
304 or in a STATEMENT_LIST. */ | 323 STATEMENT_LIST, disregarding DEBUG_BEGIN_STMTs, recursing into a |
324 STATEMENT_LIST if that's the last non-DEBUG_BEGIN_STMT. */ | |
305 | 325 |
306 tree | 326 tree |
307 expr_last (tree expr) | 327 expr_last (tree expr) |
308 { | 328 { |
309 if (expr == NULL_TREE) | 329 if (expr == NULL_TREE) |
310 return expr; | 330 return expr; |
311 | 331 |
312 if (TREE_CODE (expr) == STATEMENT_LIST) | 332 if (TREE_CODE (expr) == STATEMENT_LIST) |
313 { | 333 { |
314 struct tree_statement_list_node *n = STATEMENT_LIST_TAIL (expr); | 334 struct tree_statement_list_node *n = STATEMENT_LIST_TAIL (expr); |
315 return n ? n->stmt : NULL_TREE; | 335 if (!n) |
336 return NULL_TREE; | |
337 while (TREE_CODE (n->stmt) == DEBUG_BEGIN_STMT) | |
338 { | |
339 n = n->prev; | |
340 if (!n) | |
341 return NULL_TREE; | |
342 } | |
343 /* If the last non-debug stmt is not a statement list, we | |
344 already know it's what we're looking for. */ | |
345 if (TREE_CODE (n->stmt) != STATEMENT_LIST) | |
346 return n->stmt; | |
347 | |
348 return expr_last (n->stmt); | |
316 } | 349 } |
317 | 350 |
318 while (TREE_CODE (expr) == COMPOUND_EXPR) | 351 while (TREE_CODE (expr) == COMPOUND_EXPR) |
319 expr = TREE_OPERAND (expr, 1); | 352 expr = TREE_OPERAND (expr, 1); |
320 | 353 |