Branch data Line data Source code
1 : : /* Prints out tree in human readable form - GCC
2 : : Copyright (C) 1990-2025 Free Software Foundation, Inc.
3 : :
4 : : This file is part of GCC.
5 : :
6 : : GCC is free software; you can redistribute it and/or modify it under
7 : : the terms of the GNU General Public License as published by the Free
8 : : Software Foundation; either version 3, or (at your option) any later
9 : : version.
10 : :
11 : : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : : for more details.
15 : :
16 : : You should have received a copy of the GNU General Public License
17 : : along with GCC; see the file COPYING3. If not see
18 : : <http://www.gnu.org/licenses/>. */
19 : :
20 : :
21 : : #include "config.h"
22 : : #include "system.h"
23 : : #include "coretypes.h"
24 : : #include "tm.h"
25 : : #include "tree.h"
26 : : #include "cgraph.h"
27 : : #include "diagnostic.h"
28 : : #include "varasm.h"
29 : : #include "print-rtl.h"
30 : : #include "stor-layout.h"
31 : : #include "langhooks.h"
32 : : #include "tree-iterator.h"
33 : : #include "gimple-pretty-print.h" /* FIXME */
34 : : #include "tree-cfg.h"
35 : : #include "dumpfile.h"
36 : : #include "print-tree.h"
37 : : #include "file-prefix-map.h"
38 : :
39 : : /* Define the hash table of nodes already seen.
40 : : Such nodes are not repeated; brief cross-references are used. */
41 : :
42 : : #define HASH_SIZE 37
43 : :
44 : : static hash_set<tree> *table = NULL;
45 : :
46 : : /* Print PREFIX and ADDR to FILE. */
47 : : void
48 : 33903 : dump_addr (FILE *file, const char *prefix, const void *addr)
49 : : {
50 : 33903 : if (flag_dump_noaddr || flag_dump_unnumbered)
51 : 23622 : fprintf (file, "%s#", prefix);
52 : : else
53 : 10281 : fprintf (file, "%s" HOST_PTR_PRINTF, prefix, addr);
54 : 33903 : }
55 : :
56 : : /* Print to FILE a NODE representing a REAL_CST constant, including
57 : : Infinity and NaN. Be verbose when BFRIEF is false. */
58 : :
59 : : static void
60 : 0 : print_real_cst (FILE *file, const_tree node, bool brief)
61 : : {
62 : 0 : if (TREE_OVERFLOW (node))
63 : 0 : fprintf (file, " overflow");
64 : :
65 : 0 : REAL_VALUE_TYPE d = TREE_REAL_CST (node);
66 : 0 : if (REAL_VALUE_ISINF (d))
67 : 0 : fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
68 : 0 : else if (REAL_VALUE_ISNAN (d))
69 : : {
70 : : /* Print a NaN in the format [-][Q]NaN[(significand[exponent])]
71 : : where significand is a hexadecimal string that starts with
72 : : the 0x prefix followed by 0 if the number is not canonical
73 : : and a non-zero digit if it is, and exponent is decimal. */
74 : 0 : unsigned start = 0;
75 : : const char *psig = (const char *) d.sig;
76 : 0 : for (unsigned i = 0; i != sizeof d.sig; ++i)
77 : 0 : if (psig[i])
78 : : {
79 : : start = i;
80 : : break;
81 : : }
82 : :
83 : 0 : fprintf (file, " %s%sNaN", d.sign ? "-" : "",
84 : 0 : d.signalling ? "S" : "Q");
85 : :
86 : 0 : if (brief)
87 : 0 : return;
88 : :
89 : 0 : if (start)
90 : 0 : fprintf (file, "(0x%s", d.canonical ? "" : "0");
91 : 0 : else if (d.uexp)
92 : 0 : fprintf (file, "(%s", d.canonical ? "" : "0");
93 : 0 : else if (!d.canonical)
94 : : {
95 : 0 : fprintf (file, "(0)");
96 : 0 : return;
97 : : }
98 : :
99 : 0 : if (psig[start])
100 : : {
101 : 0 : for (unsigned i = start; i != sizeof d.sig; ++i)
102 : 0 : if (i == start)
103 : 0 : fprintf (file, "%x", psig[i]);
104 : : else
105 : 0 : fprintf (file, "%02x", psig[i]);
106 : : }
107 : :
108 : 0 : if (d.uexp)
109 : 0 : fprintf (file, "%se%u)", psig[start] ? "," : "", d.uexp);
110 : 0 : else if (psig[start])
111 : 0 : fputc (')', file);
112 : : }
113 : : else
114 : : {
115 : 0 : char string[64];
116 : 0 : real_to_decimal (string, &d, sizeof (string), 0, 1);
117 : 0 : fprintf (file, " %s", string);
118 : : }
119 : : }
120 : :
121 : : /* Print a node in brief fashion, with just the code, address and name. */
122 : :
123 : : void
124 : 30532 : print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
125 : : {
126 : 30532 : enum tree_code_class tclass;
127 : :
128 : 30532 : if (node == 0)
129 : : return;
130 : :
131 : 30357 : tclass = TREE_CODE_CLASS (TREE_CODE (node));
132 : :
133 : : /* Always print the slot this node is in, and its code, address and
134 : : name if any. */
135 : 30357 : if (indent > 0)
136 : 30019 : fprintf (file, " ");
137 : 30357 : fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node)));
138 : 30357 : dump_addr (file, " ", node);
139 : :
140 : 30357 : if (tclass == tcc_declaration)
141 : : {
142 : 28968 : if (DECL_NAME (node))
143 : 28896 : fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
144 : 72 : else if (TREE_CODE (node) == LABEL_DECL
145 : 72 : && LABEL_DECL_UID (node) != -1)
146 : : {
147 : 36 : if (dump_flags & TDF_NOUID)
148 : 0 : fprintf (file, " L.xxxx");
149 : : else
150 : 36 : fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
151 : : }
152 : : else
153 : : {
154 : 36 : if (dump_flags & TDF_NOUID)
155 : 24 : fprintf (file, " %c.xxxx",
156 : : TREE_CODE (node) == CONST_DECL ? 'C' : 'D');
157 : : else
158 : 24 : fprintf (file, " %c.%u",
159 : : TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
160 : 24 : DECL_UID (node));
161 : : }
162 : : }
163 : 1389 : else if (tclass == tcc_type)
164 : : {
165 : 581 : if (TYPE_NAME (node))
166 : : {
167 : 176 : if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
168 : 157 : fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
169 : 19 : else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
170 : 19 : && DECL_NAME (TYPE_NAME (node)))
171 : 38 : fprintf (file, " %s",
172 : 19 : IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
173 : : }
174 : 581 : if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
175 : 0 : fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node));
176 : : }
177 : 30357 : if (TREE_CODE (node) == IDENTIFIER_NODE)
178 : 168 : fprintf (file, " %s", IDENTIFIER_POINTER (node));
179 : :
180 : : /* We might as well always print the value of an integer or real. */
181 : 30357 : if (TREE_CODE (node) == INTEGER_CST)
182 : : {
183 : 300 : if (TREE_OVERFLOW (node))
184 : 0 : fprintf (file, " overflow");
185 : :
186 : 300 : fprintf (file, " ");
187 : 300 : print_dec (wi::to_wide (node), file, TYPE_SIGN (TREE_TYPE (node)));
188 : : }
189 : 30357 : if (TREE_CODE (node) == REAL_CST)
190 : 0 : print_real_cst (file, node, true);
191 : 30357 : if (TREE_CODE (node) == FIXED_CST)
192 : : {
193 : 0 : FIXED_VALUE_TYPE f;
194 : 0 : char string[60];
195 : :
196 : 0 : if (TREE_OVERFLOW (node))
197 : 0 : fprintf (file, " overflow");
198 : :
199 : 0 : f = TREE_FIXED_CST (node);
200 : 0 : fixed_to_decimal (string, &f, sizeof (string));
201 : 0 : fprintf (file, " %s", string);
202 : : }
203 : :
204 : 30357 : fprintf (file, ">");
205 : : }
206 : :
207 : : void
208 : 332 : indent_to (FILE *file, int column)
209 : : {
210 : 332 : int i;
211 : :
212 : : /* Since this is the long way, indent to desired column. */
213 : 332 : if (column > 0)
214 : 306 : fprintf (file, "\n");
215 : 2511 : for (i = 0; i < column; i++)
216 : 2179 : fprintf (file, " ");
217 : 332 : }
218 : :
219 : : /* Print the node NODE in full on file FILE, preceded by PREFIX,
220 : : starting in column INDENT. */
221 : :
222 : : void
223 : 340 : print_node (FILE *file, const char *prefix, tree node, int indent,
224 : : bool brief_for_visited)
225 : : {
226 : 340 : machine_mode mode;
227 : 340 : enum tree_code_class tclass;
228 : 340 : int len;
229 : 340 : int i;
230 : 340 : expanded_location xloc;
231 : 340 : enum tree_code code;
232 : :
233 : 340 : if (node == 0)
234 : 153 : return;
235 : :
236 : 230 : code = TREE_CODE (node);
237 : :
238 : : /* It is unsafe to look at any other fields of a node with ERROR_MARK or
239 : : invalid code. */
240 : 230 : if (code == ERROR_MARK || code >= MAX_TREE_CODES)
241 : : {
242 : 0 : print_node_brief (file, prefix, node, indent);
243 : 0 : return;
244 : : }
245 : :
246 : 230 : tclass = TREE_CODE_CLASS (code);
247 : :
248 : : /* Don't get too deep in nesting. If the user wants to see deeper,
249 : : it is easy to use the address of a lowest-level node
250 : : as an argument in another call to debug_tree. */
251 : :
252 : 230 : if (indent > 24)
253 : : {
254 : 0 : print_node_brief (file, prefix, node, indent);
255 : 0 : return;
256 : : }
257 : :
258 : 230 : if (indent > 8 && (tclass == tcc_type || tclass == tcc_declaration))
259 : : {
260 : 13 : print_node_brief (file, prefix, node, indent);
261 : 13 : return;
262 : : }
263 : :
264 : : /* Allow this function to be called if the table is not there. */
265 : 217 : if (table)
266 : : {
267 : : /* If node is in the table, just mention its address. */
268 : 165 : if (table->contains (node) && brief_for_visited)
269 : : {
270 : 30 : print_node_brief (file, prefix, node, indent);
271 : 30 : return;
272 : : }
273 : :
274 : 135 : table->add (node);
275 : : }
276 : :
277 : : /* Indent to the specified column, since this is the long form. */
278 : 187 : indent_to (file, indent);
279 : :
280 : : /* Print the slot this node is in, and its code, and address. */
281 : 187 : fprintf (file, "%s <%s", prefix, get_tree_code_name (code));
282 : 187 : dump_addr (file, " ", node);
283 : :
284 : : /* Print the name, if any. */
285 : 187 : if (tclass == tcc_declaration)
286 : : {
287 : 16 : if (DECL_NAME (node))
288 : 16 : fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
289 : 0 : else if (code == LABEL_DECL
290 : 0 : && LABEL_DECL_UID (node) != -1)
291 : : {
292 : 0 : if (dump_flags & TDF_NOUID)
293 : 0 : fprintf (file, " L.xxxx");
294 : : else
295 : 0 : fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
296 : : }
297 : : else
298 : : {
299 : 0 : if (dump_flags & TDF_NOUID)
300 : 0 : fprintf (file, " %c.xxxx", code == CONST_DECL ? 'C' : 'D');
301 : : else
302 : 0 : fprintf (file, " %c.%u", code == CONST_DECL ? 'C' : 'D',
303 : 0 : DECL_UID (node));
304 : : }
305 : : }
306 : 171 : else if (tclass == tcc_type)
307 : : {
308 : 55 : if (TYPE_NAME (node))
309 : : {
310 : 27 : if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
311 : 5 : fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
312 : 22 : else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
313 : 22 : && DECL_NAME (TYPE_NAME (node)))
314 : 44 : fprintf (file, " %s",
315 : 22 : IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
316 : : }
317 : : }
318 : 187 : if (code == IDENTIFIER_NODE)
319 : 0 : fprintf (file, " %s", IDENTIFIER_POINTER (node));
320 : :
321 : 187 : if (code == INTEGER_CST)
322 : : {
323 : 112 : if (indent <= 4)
324 : 32 : print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
325 : : }
326 : 75 : else if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
327 : : {
328 : 75 : print_node (file, "type", TREE_TYPE (node), indent + 4);
329 : 75 : if (TREE_TYPE (node))
330 : 44 : indent_to (file, indent + 3);
331 : : }
332 : :
333 : 187 : if (!TYPE_P (node) && TREE_SIDE_EFFECTS (node))
334 : 0 : fputs (" side-effects", file);
335 : :
336 : 187 : if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
337 : 7 : fputs (" readonly", file);
338 : 187 : if (TYPE_P (node) && TYPE_ATOMIC (node))
339 : 0 : fputs (" atomic", file);
340 : 187 : if (!TYPE_P (node) && TREE_CONSTANT (node))
341 : 112 : fputs (" constant", file);
342 : 75 : else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
343 : 2 : fputs (" sizes-gimplified", file);
344 : :
345 : 187 : if (TYPE_P (node) && !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
346 : 0 : fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node));
347 : :
348 : 187 : if (TREE_ADDRESSABLE (node))
349 : 1 : fputs (" addressable", file);
350 : 187 : if (TREE_THIS_VOLATILE (node))
351 : 0 : fputs (" volatile", file);
352 : 187 : if (TREE_ASM_WRITTEN (node))
353 : 0 : fputs (" asm_written", file);
354 : 187 : if (TREE_USED (node))
355 : 6 : fputs (" used", file);
356 : 187 : if (TREE_NOTHROW (node))
357 : 0 : fputs (" nothrow", file);
358 : 187 : if (TREE_PUBLIC (node))
359 : 27 : fputs (" public", file);
360 : 187 : if (TREE_PRIVATE (node))
361 : 0 : fputs (" private", file);
362 : 187 : if (TREE_PROTECTED (node))
363 : 0 : fputs (" protected", file);
364 : 187 : if (TREE_STATIC (node))
365 : 12 : fputs (code == CALL_EXPR ? " must-tail-call" : " static", file);
366 : 187 : if (TREE_DEPRECATED (node))
367 : 0 : fputs (" deprecated", file);
368 : 187 : if (TREE_VISITED (node))
369 : 10 : fputs (" visited", file);
370 : :
371 : 187 : if (code != TREE_VEC && code != INTEGER_CST && code != SSA_NAME)
372 : : {
373 : 75 : if (TREE_UNAVAILABLE (node))
374 : 0 : fputs (" unavailable", file);
375 : 75 : if (TREE_LANG_FLAG_0 (node))
376 : 0 : fputs (" tree_0", file);
377 : 75 : if (TREE_LANG_FLAG_1 (node))
378 : 0 : fputs (" tree_1", file);
379 : 75 : if (TREE_LANG_FLAG_2 (node))
380 : 0 : fputs (" tree_2", file);
381 : 75 : if (TREE_LANG_FLAG_3 (node))
382 : 0 : fputs (" tree_3", file);
383 : 75 : if (TREE_LANG_FLAG_4 (node))
384 : 0 : fputs (" tree_4", file);
385 : 75 : if (TREE_LANG_FLAG_5 (node))
386 : 0 : fputs (" tree_5", file);
387 : 75 : if (TREE_LANG_FLAG_6 (node))
388 : 0 : fputs (" tree_6", file);
389 : : }
390 : :
391 : : /* DECL_ nodes have additional attributes. */
392 : :
393 : 187 : switch (TREE_CODE_CLASS (code))
394 : : {
395 : 16 : case tcc_declaration:
396 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
397 : : {
398 : 16 : if (DECL_UNSIGNED (node))
399 : 4 : fputs (" unsigned", file);
400 : 16 : if (DECL_IGNORED_P (node))
401 : 0 : fputs (" ignored", file);
402 : 16 : if (DECL_ABSTRACT_P (node))
403 : 0 : fputs (" abstract", file);
404 : 16 : if (DECL_EXTERNAL (node))
405 : 0 : fputs (" external", file);
406 : 16 : if (DECL_NONLOCAL (node))
407 : 0 : fputs (" nonlocal", file);
408 : : }
409 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
410 : : {
411 : 16 : if (DECL_WEAK (node))
412 : 0 : fputs (" weak", file);
413 : 16 : if (DECL_IN_SYSTEM_HEADER (node))
414 : 0 : fputs (" in_system_header", file);
415 : : }
416 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL)
417 : : && code != LABEL_DECL
418 : 16 : && code != FUNCTION_DECL
419 : 32 : && DECL_REGISTER (node))
420 : 0 : fputs (" regdecl", file);
421 : :
422 : 16 : if (code == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node))
423 : 0 : fputs (" suppress-debug", file);
424 : :
425 : 16 : if (code == FUNCTION_DECL
426 : 16 : && DECL_FUNCTION_SPECIFIC_TARGET (node))
427 : 0 : fputs (" function-specific-target", file);
428 : 16 : if (code == FUNCTION_DECL
429 : 16 : && DECL_FUNCTION_SPECIFIC_OPTIMIZATION (node))
430 : 0 : fputs (" function-specific-opt", file);
431 : 16 : if (code == FUNCTION_DECL && DECL_DECLARED_INLINE_P (node))
432 : 0 : fputs (" autoinline", file);
433 : 16 : if (code == FUNCTION_DECL && DECL_UNINLINABLE (node))
434 : 0 : fputs (" uninlinable", file);
435 : 16 : if (code == FUNCTION_DECL && fndecl_built_in_p (node))
436 : 0 : fputs (" built-in", file);
437 : 16 : if (code == FUNCTION_DECL && DECL_STATIC_CHAIN (node))
438 : 0 : fputs (" static-chain", file);
439 : 16 : if (TREE_CODE (node) == FUNCTION_DECL && decl_is_tm_clone (node))
440 : 0 : fputs (" tm-clone", file);
441 : :
442 : 16 : if (code == FIELD_DECL && DECL_PACKED (node))
443 : 0 : fputs (" packed", file);
444 : 16 : if (code == FIELD_DECL && DECL_BIT_FIELD (node))
445 : 0 : fputs (" bit-field", file);
446 : 16 : if (code == FIELD_DECL && DECL_NONADDRESSABLE_P (node))
447 : 0 : fputs (" nonaddressable", file);
448 : :
449 : 16 : if (code == LABEL_DECL && EH_LANDING_PAD_NR (node))
450 : 0 : fprintf (file, " landing-pad:%d", EH_LANDING_PAD_NR (node));
451 : :
452 : 16 : if (code == VAR_DECL && DECL_IN_TEXT_SECTION (node))
453 : 0 : fputs (" in-text-section", file);
454 : 16 : if (code == VAR_DECL && DECL_IN_CONSTANT_POOL (node))
455 : 0 : fputs (" in-constant-pool", file);
456 : 16 : if (code == VAR_DECL && DECL_COMMON (node))
457 : 1 : fputs (" common", file);
458 : 16 : if ((code == VAR_DECL || code == PARM_DECL) && DECL_READ_P (node))
459 : 6 : fputs (" read", file);
460 : 16 : if (code == VAR_DECL && DECL_THREAD_LOCAL_P (node))
461 : : {
462 : 0 : fputs (" ", file);
463 : 0 : fputs (tls_model_names[DECL_TLS_MODEL (node)], file);
464 : : }
465 : :
466 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
467 : : {
468 : 16 : if (DECL_VIRTUAL_P (node))
469 : 0 : fputs (" virtual", file);
470 : 16 : if (DECL_PRESERVE_P (node))
471 : 0 : fputs (" preserve", file);
472 : 16 : if (DECL_LANG_FLAG_0 (node))
473 : 0 : fputs (" decl_0", file);
474 : 16 : if (DECL_LANG_FLAG_1 (node))
475 : 0 : fputs (" decl_1", file);
476 : 16 : if (DECL_LANG_FLAG_2 (node))
477 : 0 : fputs (" decl_2", file);
478 : 16 : if (DECL_LANG_FLAG_3 (node))
479 : 0 : fputs (" decl_3", file);
480 : 16 : if (DECL_LANG_FLAG_4 (node))
481 : 0 : fputs (" decl_4", file);
482 : 16 : if (DECL_LANG_FLAG_5 (node))
483 : 0 : fputs (" decl_5", file);
484 : 16 : if (DECL_LANG_FLAG_6 (node))
485 : 0 : fputs (" decl_6", file);
486 : 16 : if (DECL_LANG_FLAG_7 (node))
487 : 0 : fputs (" decl_7", file);
488 : 16 : if (DECL_LANG_FLAG_8 (node))
489 : 0 : fputs (" decl_8", file);
490 : :
491 : 16 : mode = DECL_MODE (node);
492 : 16 : fprintf (file, " %s", GET_MODE_NAME (mode));
493 : : }
494 : :
495 : 16 : if ((code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
496 : 16 : && DECL_BY_REFERENCE (node))
497 : 0 : fputs (" passed-by-reference", file);
498 : :
499 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS) && DECL_DEFER_OUTPUT (node))
500 : 0 : fputs (" defer-output", file);
501 : :
502 : :
503 : 16 : xloc = expand_location (DECL_SOURCE_LOCATION (node));
504 : 16 : fprintf (file, " %s:%d:%d", xloc.file, xloc.line,
505 : : xloc.column);
506 : :
507 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
508 : : {
509 : 16 : print_node (file, "size", DECL_SIZE (node), indent + 4);
510 : 16 : print_node (file, "unit-size", DECL_SIZE_UNIT (node), indent + 4);
511 : :
512 : 16 : if (code != FUNCTION_DECL || fndecl_built_in_p (node))
513 : 16 : indent_to (file, indent + 3);
514 : :
515 : 16 : if (DECL_USER_ALIGN (node))
516 : 0 : fprintf (file, " user");
517 : :
518 : 16 : fprintf (file, " align:%d warn_if_not_align:%d",
519 : 16 : DECL_ALIGN (node), DECL_WARN_IF_NOT_ALIGN (node));
520 : 16 : if (code == FIELD_DECL)
521 : : {
522 : 0 : fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
523 : 0 : DECL_OFFSET_ALIGN (node));
524 : 0 : fprintf (file, " decl_not_flexarray: %d",
525 : 0 : DECL_NOT_FLEXARRAY (node));
526 : : }
527 : :
528 : 16 : if (code == FUNCTION_DECL && fndecl_built_in_p (node))
529 : : {
530 : 0 : if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
531 : 0 : fprintf (file, " built-in: BUILT_IN_MD:%d",
532 : : DECL_MD_FUNCTION_CODE (node));
533 : 0 : else if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_FRONTEND)
534 : 0 : fprintf (file, " built-in: BUILT_IN_FRONTEND:%d",
535 : : DECL_FE_FUNCTION_CODE (node));
536 : : else
537 : 0 : fprintf (file, " built-in: %s:%s",
538 : 0 : built_in_class_names[(int) DECL_BUILT_IN_CLASS (node)],
539 : 0 : built_in_names[(int) DECL_FUNCTION_CODE (node)]);
540 : : }
541 : : }
542 : 16 : if (code == FIELD_DECL)
543 : : {
544 : 0 : print_node (file, "offset", DECL_FIELD_OFFSET (node), indent + 4);
545 : 0 : print_node (file, "bit-offset", DECL_FIELD_BIT_OFFSET (node),
546 : : indent + 4);
547 : 0 : if (DECL_BIT_FIELD_TYPE (node))
548 : 0 : print_node (file, "bit_field_type", DECL_BIT_FIELD_TYPE (node),
549 : : indent + 4);
550 : : }
551 : :
552 : 16 : print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
553 : :
554 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
555 : : {
556 : 16 : print_node (file, "attributes",
557 : 16 : DECL_ATTRIBUTES (node), indent + 4);
558 : 16 : if (code != PARM_DECL)
559 : 16 : print_node_brief (file, "initial", DECL_INITIAL (node),
560 : : indent + 4);
561 : : }
562 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
563 : : {
564 : 32 : print_node_brief (file, "abstract_origin",
565 : 16 : DECL_ABSTRACT_ORIGIN (node), indent + 4);
566 : : }
567 : 16 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
568 : : {
569 : 0 : print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
570 : : }
571 : :
572 : 16 : lang_hooks.print_decl (file, node, indent);
573 : :
574 : 16 : if (DECL_RTL_SET_P (node))
575 : : {
576 : 0 : indent_to (file, indent + 4);
577 : 0 : print_rtl (file, DECL_RTL (node));
578 : : }
579 : :
580 : 16 : if (code == PARM_DECL)
581 : : {
582 : 0 : print_node (file, "arg-type", DECL_ARG_TYPE (node), indent + 4);
583 : :
584 : 0 : if (DECL_INCOMING_RTL (node) != 0)
585 : : {
586 : 0 : indent_to (file, indent + 4);
587 : 0 : fprintf (file, "incoming-rtl ");
588 : 0 : print_rtl (file, DECL_INCOMING_RTL (node));
589 : : }
590 : : }
591 : 16 : else if (code == FUNCTION_DECL
592 : 16 : && DECL_STRUCT_FUNCTION (node) != 0)
593 : : {
594 : 0 : print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4);
595 : 0 : indent_to (file, indent + 4);
596 : 0 : dump_addr (file, "struct-function ", DECL_STRUCT_FUNCTION (node));
597 : : }
598 : :
599 : 16 : if ((code == VAR_DECL || code == PARM_DECL)
600 : 16 : && DECL_HAS_VALUE_EXPR_P (node))
601 : 0 : print_node (file, "value-expr", DECL_VALUE_EXPR (node), indent + 4);
602 : :
603 : : /* Print the decl chain only if decl is at second level. */
604 : 16 : if (indent == 4)
605 : 0 : print_node (file, "chain", TREE_CHAIN (node), indent + 4);
606 : : else
607 : 16 : print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
608 : : break;
609 : :
610 : 55 : case tcc_type:
611 : 55 : if (TYPE_UNSIGNED (node))
612 : 9 : fputs (" unsigned", file);
613 : :
614 : 55 : if (TYPE_NO_FORCE_BLK (node))
615 : 0 : fputs (" no-force-blk", file);
616 : :
617 : 55 : if (code == ARRAY_TYPE && TYPE_STRING_FLAG (node))
618 : 0 : fputs (" string-flag", file);
619 : :
620 : 55 : if (TYPE_NEEDS_CONSTRUCTING (node))
621 : 0 : fputs (" needs-constructing", file);
622 : :
623 : 55 : if ((code == RECORD_TYPE
624 : : || code == UNION_TYPE
625 : : || code == QUAL_UNION_TYPE
626 : 55 : || code == ARRAY_TYPE)
627 : 55 : && TYPE_REVERSE_STORAGE_ORDER (node))
628 : 0 : fputs (" reverse-storage-order", file);
629 : :
630 : 55 : if ((code == RECORD_TYPE
631 : 55 : || code == UNION_TYPE)
632 : 55 : && TYPE_CXX_ODR_P (node))
633 : 0 : fputs (" cxx-odr-p", file);
634 : :
635 : 55 : if ((code == RECORD_TYPE
636 : : || code == UNION_TYPE)
637 : 55 : && TYPE_INCLUDES_FLEXARRAY (node))
638 : 0 : fputs (" includes-flexarray", file);
639 : :
640 : : /* The transparent-union flag is used for different things in
641 : : different nodes. */
642 : 55 : if ((code == UNION_TYPE || code == RECORD_TYPE)
643 : 55 : && TYPE_TRANSPARENT_AGGR (node))
644 : 0 : fputs (" transparent-aggr", file);
645 : 55 : else if (code == ARRAY_TYPE
646 : 55 : && TYPE_NONALIASED_COMPONENT (node))
647 : 0 : fputs (" nonaliased-component", file);
648 : :
649 : 55 : if (TYPE_PACKED (node))
650 : 0 : fputs (" packed", file);
651 : :
652 : 55 : if (TYPE_RESTRICT (node))
653 : 0 : fputs (" restrict", file);
654 : :
655 : 55 : if (TYPE_LANG_FLAG_0 (node))
656 : 0 : fputs (" type_0", file);
657 : 55 : if (TYPE_LANG_FLAG_1 (node))
658 : 0 : fputs (" type_1", file);
659 : 55 : if (TYPE_LANG_FLAG_2 (node))
660 : 0 : fputs (" type_2", file);
661 : 55 : if (TYPE_LANG_FLAG_3 (node))
662 : 0 : fputs (" type_3", file);
663 : 55 : if (TYPE_LANG_FLAG_4 (node))
664 : 0 : fputs (" type_4", file);
665 : 55 : if (TYPE_LANG_FLAG_5 (node))
666 : 0 : fputs (" type_5", file);
667 : 55 : if (TYPE_LANG_FLAG_6 (node))
668 : 0 : fputs (" type_6", file);
669 : 55 : if (TYPE_LANG_FLAG_7 (node))
670 : 0 : fputs (" type_7", file);
671 : :
672 : 55 : mode = TYPE_MODE (node);
673 : 55 : fprintf (file, " %s", GET_MODE_NAME (mode));
674 : :
675 : 55 : print_node (file, "size", TYPE_SIZE (node), indent + 4);
676 : 55 : print_node (file, "unit-size", TYPE_SIZE_UNIT (node), indent + 4);
677 : 55 : indent_to (file, indent + 3);
678 : :
679 : 55 : if (TYPE_USER_ALIGN (node))
680 : 0 : fprintf (file, " user");
681 : :
682 : 55 : fprintf (file, " align:%d warn_if_not_align:%d symtab:%d alias-set "
683 : : HOST_WIDE_INT_PRINT_DEC,
684 : 55 : TYPE_ALIGN (node), TYPE_WARN_IF_NOT_ALIGN (node),
685 : 55 : TYPE_SYMTAB_ADDRESS (node),
686 : 55 : (HOST_WIDE_INT) TYPE_ALIAS_SET (node));
687 : :
688 : 55 : if (TYPE_STRUCTURAL_EQUALITY_P (node))
689 : 0 : fprintf (file, " structural-equality");
690 : : else
691 : 55 : dump_addr (file, " canonical-type ", TYPE_CANONICAL (node));
692 : :
693 : 55 : print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
694 : :
695 : 55 : if (INTEGRAL_TYPE_P (node) || code == REAL_TYPE
696 : 18 : || code == FIXED_POINT_TYPE)
697 : : {
698 : 37 : fprintf (file, " precision:%d", TYPE_PRECISION (node));
699 : 37 : print_node_brief (file, "min", TYPE_MIN_VALUE (node), indent + 4);
700 : 37 : print_node_brief (file, "max", TYPE_MAX_VALUE (node), indent + 4);
701 : : }
702 : :
703 : 55 : if (code == ENUMERAL_TYPE)
704 : 0 : print_node (file, "values", TYPE_VALUES (node), indent + 4);
705 : : else if (code == ARRAY_TYPE)
706 : 10 : print_node (file, "domain", TYPE_DOMAIN (node), indent + 4);
707 : : else if (code == VECTOR_TYPE)
708 : : {
709 : 0 : fprintf (file, " nunits:");
710 : 0 : print_dec (TYPE_VECTOR_SUBPARTS (node), file);
711 : : }
712 : : else if (code == RECORD_TYPE
713 : : || code == UNION_TYPE
714 : : || code == QUAL_UNION_TYPE)
715 : 0 : print_node (file, "fields", TYPE_FIELDS (node), indent + 4);
716 : : else if (code == FUNCTION_TYPE
717 : : || code == METHOD_TYPE)
718 : : {
719 : 4 : if (TYPE_METHOD_BASETYPE (node))
720 : 0 : print_node_brief (file, "method basetype",
721 : 0 : TYPE_METHOD_BASETYPE (node), indent + 4);
722 : 4 : print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4);
723 : : }
724 : : else if (code == OFFSET_TYPE)
725 : 0 : print_node_brief (file, "basetype", TYPE_OFFSET_BASETYPE (node),
726 : : indent + 4);
727 : :
728 : 55 : if (TYPE_CONTEXT (node))
729 : 0 : print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4);
730 : :
731 : 55 : lang_hooks.print_type (file, node, indent);
732 : :
733 : 55 : if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
734 : 30 : indent_to (file, indent + 3);
735 : :
736 : 55 : print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node),
737 : : indent + 4);
738 : 55 : print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node),
739 : : indent + 4);
740 : 55 : print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
741 : 55 : break;
742 : :
743 : 0 : case tcc_expression:
744 : 0 : case tcc_comparison:
745 : 0 : case tcc_unary:
746 : 0 : case tcc_binary:
747 : 0 : case tcc_reference:
748 : 0 : case tcc_statement:
749 : 0 : case tcc_vl_exp:
750 : 0 : if (code == BIND_EXPR)
751 : : {
752 : 0 : print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
753 : 0 : print_node (file, "body", TREE_OPERAND (node, 1), indent + 4);
754 : 0 : print_node (file, "block", TREE_OPERAND (node, 2), indent + 4);
755 : 0 : break;
756 : : }
757 : 0 : if (code == CALL_EXPR)
758 : : {
759 : 0 : print_node (file, "fn", CALL_EXPR_FN (node), indent + 4);
760 : 0 : print_node (file, "static_chain", CALL_EXPR_STATIC_CHAIN (node),
761 : : indent + 4);
762 : :
763 : 0 : call_expr_arg_iterator iter;
764 : 0 : init_call_expr_arg_iterator (node, &iter);
765 : 0 : while (more_call_expr_args_p (&iter))
766 : : {
767 : : /* Buffer big enough to format a 32-bit UINT_MAX into, plus
768 : : the text. */
769 : 0 : char temp[15];
770 : 0 : sprintf (temp, "arg:%u", iter.i);
771 : 0 : tree arg = next_call_expr_arg (&iter);
772 : 0 : if (arg)
773 : 0 : print_node (file, temp, arg, indent + 4);
774 : : else
775 : : {
776 : 0 : indent_to (file, indent + 4);
777 : 0 : fprintf (file, "%s NULL", temp);
778 : : }
779 : : }
780 : : }
781 : : else
782 : : {
783 : 0 : len = TREE_OPERAND_LENGTH (node);
784 : :
785 : 0 : for (i = 0; i < len; i++)
786 : : {
787 : : /* Buffer big enough to format a 32-bit UINT_MAX into, plus
788 : : the text. */
789 : 0 : char temp[16];
790 : :
791 : 0 : sprintf (temp, "arg:%d", i);
792 : 0 : print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
793 : : }
794 : : }
795 : 0 : if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
796 : 0 : print_node (file, "chain", TREE_CHAIN (node), indent + 4);
797 : : break;
798 : :
799 : 116 : case tcc_constant:
800 : 116 : case tcc_exceptional:
801 : 116 : switch (code)
802 : : {
803 : 112 : case INTEGER_CST:
804 : 112 : if (TREE_OVERFLOW (node))
805 : 0 : fprintf (file, " overflow");
806 : :
807 : 112 : fprintf (file, " ");
808 : 112 : print_dec (wi::to_wide (node), file, TYPE_SIGN (TREE_TYPE (node)));
809 : 112 : break;
810 : :
811 : 0 : case REAL_CST:
812 : 0 : print_real_cst (file, node, false);
813 : 0 : break;
814 : :
815 : 0 : case FIXED_CST:
816 : 0 : {
817 : 0 : FIXED_VALUE_TYPE f;
818 : 0 : char string[64];
819 : :
820 : 0 : if (TREE_OVERFLOW (node))
821 : 0 : fprintf (file, " overflow");
822 : :
823 : 0 : f = TREE_FIXED_CST (node);
824 : 0 : fixed_to_decimal (string, &f, sizeof (string));
825 : 0 : fprintf (file, " %s", string);
826 : : }
827 : 0 : break;
828 : :
829 : 0 : case VECTOR_CST:
830 : 0 : {
831 : : /* Big enough for UINT_MAX plus the string below. */
832 : 0 : char buf[32];
833 : :
834 : 0 : fprintf (file, " npatterns:%u nelts-per-pattern:%u",
835 : 0 : VECTOR_CST_NPATTERNS (node),
836 : 0 : VECTOR_CST_NELTS_PER_PATTERN (node));
837 : 0 : unsigned int count = vector_cst_encoded_nelts (node);
838 : 0 : for (unsigned int i = 0; i < count; ++i)
839 : : {
840 : 0 : sprintf (buf, "elt:%u: ", i);
841 : 0 : print_node (file, buf, VECTOR_CST_ENCODED_ELT (node, i),
842 : : indent + 4);
843 : : }
844 : : }
845 : 0 : break;
846 : :
847 : 0 : case COMPLEX_CST:
848 : 0 : print_node (file, "real", TREE_REALPART (node), indent + 4);
849 : 0 : print_node (file, "imag", TREE_IMAGPART (node), indent + 4);
850 : 0 : break;
851 : :
852 : 0 : case STRING_CST:
853 : 0 : {
854 : 0 : const char *p = TREE_STRING_POINTER (node);
855 : 0 : int i = TREE_STRING_LENGTH (node);
856 : 0 : fputs (" \"", file);
857 : 0 : while (--i >= 0)
858 : : {
859 : 0 : char ch = *p++;
860 : 0 : if (ch >= ' ' && ch < 127)
861 : 0 : putc (ch, file);
862 : : else
863 : 0 : fprintf (file, "\\%03o", ch & 0xFF);
864 : : }
865 : 0 : fputc ('\"', file);
866 : : }
867 : 0 : break;
868 : :
869 : : case POLY_INT_CST:
870 : : {
871 : : char buf[10];
872 : 0 : for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
873 : : {
874 : 0 : snprintf (buf, sizeof (buf), "elt%u:", i);
875 : 0 : print_node (file, buf, POLY_INT_CST_COEFF (node, i),
876 : : indent + 4);
877 : : }
878 : : }
879 : 0 : break;
880 : :
881 : 0 : case IDENTIFIER_NODE:
882 : 0 : lang_hooks.print_identifier (file, node, indent);
883 : 0 : break;
884 : :
885 : 4 : case TREE_LIST:
886 : 4 : print_node (file, "purpose", TREE_PURPOSE (node), indent + 4);
887 : 4 : print_node (file, "value", TREE_VALUE (node), indent + 4);
888 : 4 : print_node (file, "chain", TREE_CHAIN (node), indent + 4);
889 : 4 : break;
890 : :
891 : 0 : case TREE_VEC:
892 : 0 : len = TREE_VEC_LENGTH (node);
893 : 0 : fprintf (file, " length:%d", len);
894 : 0 : for (i = 0; i < len; i++)
895 : 0 : if (TREE_VEC_ELT (node, i))
896 : : {
897 : : /* Buffer big enough to format a 32-bit UINT_MAX into, plus
898 : : the text. */
899 : 0 : char temp[16];
900 : 0 : sprintf (temp, "elt:%d", i);
901 : 0 : print_node (file, temp, TREE_VEC_ELT (node, i), indent + 4);
902 : : }
903 : : break;
904 : :
905 : 0 : case CONSTRUCTOR:
906 : 0 : {
907 : 0 : unsigned HOST_WIDE_INT cnt;
908 : 0 : tree index, value;
909 : 0 : len = CONSTRUCTOR_NELTS (node);
910 : 0 : fprintf (file, " length:%d", len);
911 : 0 : FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node),
912 : : cnt, index, value)
913 : : {
914 : 0 : print_node (file, "idx", index, indent + 4, false);
915 : 0 : print_node (file, "val", value, indent + 4, false);
916 : : }
917 : : }
918 : : break;
919 : :
920 : 0 : case STATEMENT_LIST:
921 : 0 : dump_addr (file, " head ", node->stmt_list.head);
922 : 0 : dump_addr (file, " tail ", node->stmt_list.tail);
923 : 0 : fprintf (file, " stmts");
924 : 0 : {
925 : 0 : tree_stmt_iterator i;
926 : 0 : for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
927 : : {
928 : : /* Not printing the addresses of the (not-a-tree)
929 : : 'struct tree_stmt_list_node's. */
930 : 0 : dump_addr (file, " ", tsi_stmt (i));
931 : : }
932 : 0 : fprintf (file, "\n");
933 : 0 : for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
934 : : {
935 : : /* Not printing the addresses of the (not-a-tree)
936 : : 'struct tree_stmt_list_node's. */
937 : 0 : print_node (file, "stmt", tsi_stmt (i), indent + 4);
938 : : }
939 : : }
940 : 0 : break;
941 : :
942 : 0 : case BLOCK:
943 : 0 : print_node (file, "vars", BLOCK_VARS (node), indent + 4);
944 : 0 : print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node),
945 : : indent + 4);
946 : 0 : print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
947 : 0 : print_node (file, "chain", BLOCK_CHAIN (node), indent + 4);
948 : 0 : print_node (file, "abstract_origin",
949 : 0 : BLOCK_ABSTRACT_ORIGIN (node), indent + 4);
950 : 0 : break;
951 : :
952 : 0 : case SSA_NAME:
953 : 0 : print_node_brief (file, "var", SSA_NAME_VAR (node), indent + 4);
954 : 0 : indent_to (file, indent + 4);
955 : 0 : fprintf (file, "def_stmt ");
956 : 0 : {
957 : 0 : pretty_printer pp;
958 : 0 : pp.set_output_stream (file);
959 : 0 : pp_gimple_stmt_1 (&pp, SSA_NAME_DEF_STMT (node), indent + 4,
960 : : TDF_NONE);
961 : 0 : pp_flush (&pp);
962 : 0 : }
963 : :
964 : 0 : indent_to (file, indent + 4);
965 : 0 : fprintf (file, "version:%u", SSA_NAME_VERSION (node));
966 : 0 : if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
967 : 0 : fprintf (file, " in-abnormal-phi");
968 : 0 : if (SSA_NAME_IN_FREE_LIST (node))
969 : 0 : fprintf (file, " in-free-list");
970 : :
971 : 0 : if (SSA_NAME_PTR_INFO (node))
972 : : {
973 : 0 : indent_to (file, indent + 3);
974 : 0 : if (SSA_NAME_PTR_INFO (node))
975 : 0 : dump_addr (file, " ptr-info ", SSA_NAME_PTR_INFO (node));
976 : : }
977 : : break;
978 : :
979 : 0 : case OMP_CLAUSE:
980 : 0 : {
981 : 0 : int i;
982 : 0 : fprintf (file, " %s",
983 : 0 : omp_clause_code_name[OMP_CLAUSE_CODE (node)]);
984 : 0 : for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (node)]; i++)
985 : : {
986 : 0 : indent_to (file, indent + 4);
987 : 0 : fprintf (file, "op-%d:", i);
988 : 0 : print_node_brief (file, "", OMP_CLAUSE_OPERAND (node, i), 0);
989 : : }
990 : : }
991 : : break;
992 : :
993 : 0 : case OPTIMIZATION_NODE:
994 : 0 : cl_optimization_print (file, indent + 4, TREE_OPTIMIZATION (node));
995 : 0 : break;
996 : :
997 : 0 : case TARGET_OPTION_NODE:
998 : 0 : cl_target_option_print (file, indent + 4, TREE_TARGET_OPTION (node));
999 : 0 : break;
1000 : 0 : case IMPORTED_DECL:
1001 : 0 : fprintf (file, " imported-declaration");
1002 : 0 : print_node_brief (file, "associated-declaration",
1003 : 0 : IMPORTED_DECL_ASSOCIATED_DECL (node),
1004 : : indent + 4);
1005 : 0 : break;
1006 : :
1007 : 0 : case TREE_BINFO:
1008 : 0 : fprintf (file, " bases:%d",
1009 : 0 : vec_safe_length (BINFO_BASE_BINFOS (node)));
1010 : 0 : print_node_brief (file, "offset", BINFO_OFFSET (node), indent + 4);
1011 : 0 : print_node_brief (file, "virtuals", BINFO_VIRTUALS (node),
1012 : : indent + 4);
1013 : 0 : print_node_brief (file, "inheritance-chain",
1014 : 0 : BINFO_INHERITANCE_CHAIN (node),
1015 : : indent + 4);
1016 : 0 : break;
1017 : :
1018 : 0 : default:
1019 : 0 : lang_hooks.print_xnode (file, node, indent);
1020 : 0 : break;
1021 : : }
1022 : :
1023 : : break;
1024 : : }
1025 : :
1026 : 187 : if (EXPR_HAS_LOCATION (node))
1027 : : {
1028 : 0 : expanded_location xloc = expand_location (EXPR_LOCATION (node));
1029 : 0 : indent_to (file, indent+4);
1030 : 0 : fprintf (file, "%s:%d:%d", xloc.file, xloc.line, xloc.column);
1031 : :
1032 : : /* Print the range, if any */
1033 : 0 : source_range r = EXPR_LOCATION_RANGE (node);
1034 : 0 : if (r.m_start)
1035 : : {
1036 : 0 : xloc = expand_location (r.m_start);
1037 : 0 : fprintf (file, " start: %s:%d:%d", xloc.file, xloc.line, xloc.column);
1038 : : }
1039 : : else
1040 : : {
1041 : 0 : fprintf (file, " start: unknown");
1042 : : }
1043 : 0 : if (r.m_finish)
1044 : : {
1045 : 0 : xloc = expand_location (r.m_finish);
1046 : 0 : fprintf (file, " finish: %s:%d:%d", xloc.file, xloc.line, xloc.column);
1047 : : }
1048 : : else
1049 : : {
1050 : 0 : fprintf (file, " finish: unknown");
1051 : : }
1052 : : }
1053 : :
1054 : 187 : fprintf (file, ">");
1055 : : }
1056 : :
1057 : : /* Print the identifier for DECL according to FLAGS. */
1058 : :
1059 : : void
1060 : 337 : print_decl_identifier (FILE *file, tree decl, int flags)
1061 : : {
1062 : 337 : bool needs_colon = false;
1063 : 337 : const char *name;
1064 : 337 : char c;
1065 : :
1066 : 337 : if (flags & PRINT_DECL_ORIGIN)
1067 : : {
1068 : 331 : if (DECL_IS_UNDECLARED_BUILTIN (decl))
1069 : 0 : fputs ("<built-in>", file);
1070 : : else
1071 : : {
1072 : 331 : expanded_location loc
1073 : 331 : = expand_location (DECL_SOURCE_LOCATION (decl));
1074 : 331 : const char *f = flags & PRINT_DECL_REMAP_DEBUG
1075 : 331 : ? remap_debug_filename (loc.file)
1076 : 331 : : loc.file;
1077 : 331 : fprintf (file, "%s:%d:%d", f, loc.line, loc.column);
1078 : : }
1079 : : needs_colon = true;
1080 : : }
1081 : :
1082 : 337 : if (flags & PRINT_DECL_UNIQUE_NAME)
1083 : : {
1084 : 4 : name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
1085 : 4 : if (!TREE_PUBLIC (decl)
1086 : 4 : || (DECL_WEAK (decl) && !DECL_EXTERNAL (decl)))
1087 : : /* The symbol has internal or weak linkage so its assembler name
1088 : : is not necessarily unique among the compilation units of the
1089 : : program. We therefore have to further mangle it. But we can't
1090 : : simply use DECL_SOURCE_FILE because it contains the name of the
1091 : : file the symbol originates from so, e.g. for function templates
1092 : : in C++ where the templates are defined in a header file, we can
1093 : : have symbols with the same assembler name and DECL_SOURCE_FILE.
1094 : : That's why we use the name of the top-level source file of the
1095 : : compilation unit. ??? Unnecessary for Ada. */
1096 : 0 : name = ACONCAT ((main_input_filename, ":", name, NULL));
1097 : : }
1098 : 333 : else if (flags & PRINT_DECL_NAME)
1099 : : {
1100 : : /* We don't want to print the full qualified name because it can be long,
1101 : : so we strip the scope prefix, but we may need to deal with the suffix
1102 : : created by the compiler. */
1103 : 331 : const char *suffix = strchr (IDENTIFIER_POINTER (DECL_NAME (decl)), '.');
1104 : 331 : name = lang_hooks.decl_printable_name (decl, 2);
1105 : 331 : if (suffix)
1106 : : {
1107 : 0 : const char *dot = strchr (name, '.');
1108 : 0 : while (dot && strcasecmp (dot, suffix) != 0)
1109 : : {
1110 : 0 : name = dot + 1;
1111 : 0 : dot = strchr (name, '.');
1112 : : }
1113 : : }
1114 : : else
1115 : : {
1116 : 331 : const char *dot = strrchr (name, '.');
1117 : 331 : if (dot)
1118 : 0 : name = dot + 1;
1119 : : }
1120 : : }
1121 : : else
1122 : : return;
1123 : :
1124 : 335 : if (needs_colon)
1125 : 329 : fputc (':', file);
1126 : :
1127 : 3078 : while ((c = *name++) != '\0')
1128 : : {
1129 : : /* Strip double-quotes because of VCG. */
1130 : 2743 : if (c == '"')
1131 : 0 : continue;
1132 : 2743 : fputc (c, file);
1133 : : }
1134 : : }
1135 : :
1136 : :
1137 : : /* Print the node NODE on standard error, for debugging.
1138 : : Most nodes referred to by this one are printed recursively
1139 : : down to a depth of six. */
1140 : :
1141 : : DEBUG_FUNCTION void
1142 : 20 : debug_tree (tree node)
1143 : : {
1144 : 20 : table = new hash_set<tree> (HASH_SIZE);
1145 : 20 : print_node (stderr, "", node, 0);
1146 : 40 : delete table;
1147 : 20 : table = NULL;
1148 : 20 : putc ('\n', stderr);
1149 : 20 : }
1150 : :
1151 : : DEBUG_FUNCTION void
1152 : 0 : debug_raw (const tree_node &ref)
1153 : : {
1154 : 0 : debug_tree (const_cast <tree> (&ref));
1155 : 0 : }
1156 : :
1157 : : DEBUG_FUNCTION void
1158 : 0 : debug_raw (const tree_node *ptr)
1159 : : {
1160 : 0 : if (ptr)
1161 : 0 : debug_raw (*ptr);
1162 : : else
1163 : 0 : fprintf (stderr, "<nil>\n");
1164 : 0 : }
1165 : :
1166 : : static void
1167 : 0 : dump_tree_via_hooks (const tree_node *ptr, dump_flags_t options)
1168 : : {
1169 : 0 : if (DECL_P (ptr))
1170 : 0 : lang_hooks.print_decl (stderr, const_cast <tree_node*> (ptr), 0);
1171 : 0 : else if (TYPE_P (ptr))
1172 : 0 : lang_hooks.print_type (stderr, const_cast <tree_node*> (ptr), 0);
1173 : 0 : else if (TREE_CODE (ptr) == IDENTIFIER_NODE)
1174 : 0 : lang_hooks.print_identifier (stderr, const_cast <tree_node*> (ptr), 0);
1175 : : else
1176 : 0 : print_generic_expr (stderr, const_cast <tree_node*> (ptr), options);
1177 : 0 : fprintf (stderr, "\n");
1178 : 0 : }
1179 : :
1180 : : DEBUG_FUNCTION void
1181 : 0 : debug (const tree_node &ref)
1182 : : {
1183 : 0 : dump_tree_via_hooks (&ref, TDF_NONE);
1184 : 0 : }
1185 : :
1186 : : DEBUG_FUNCTION void
1187 : 0 : debug (const tree_node *ptr)
1188 : : {
1189 : 0 : if (ptr)
1190 : 0 : debug (*ptr);
1191 : : else
1192 : 0 : fprintf (stderr, "<nil>\n");
1193 : 0 : }
1194 : :
1195 : : DEBUG_FUNCTION void
1196 : 0 : debug_head (const tree_node &ref)
1197 : : {
1198 : 0 : debug (ref);
1199 : 0 : }
1200 : :
1201 : : DEBUG_FUNCTION void
1202 : 0 : debug_head (const tree_node *ptr)
1203 : : {
1204 : 0 : if (ptr)
1205 : 0 : debug_head (*ptr);
1206 : : else
1207 : 0 : fprintf (stderr, "<nil>\n");
1208 : 0 : }
1209 : :
1210 : : DEBUG_FUNCTION void
1211 : 0 : debug_body (const tree_node &ref)
1212 : : {
1213 : 0 : if (TREE_CODE (&ref) == FUNCTION_DECL)
1214 : 0 : dump_function_to_file (const_cast <tree_node*> (&ref), stderr, TDF_NONE);
1215 : : else
1216 : 0 : debug (ref);
1217 : 0 : }
1218 : :
1219 : : DEBUG_FUNCTION void
1220 : 0 : debug_body (const tree_node *ptr)
1221 : : {
1222 : 0 : if (ptr)
1223 : 0 : debug_body (*ptr);
1224 : : else
1225 : 0 : fprintf (stderr, "<nil>\n");
1226 : 0 : }
1227 : :
1228 : : /* Print the vector of trees VEC on standard error, for debugging.
1229 : : Most nodes referred to by this one are printed recursively
1230 : : down to a depth of six. */
1231 : :
1232 : : DEBUG_FUNCTION void
1233 : 0 : debug_raw (vec<tree, va_gc> &ref)
1234 : : {
1235 : 0 : tree elt;
1236 : 0 : unsigned ix;
1237 : :
1238 : : /* Print the slot this node is in, and its code, and address. */
1239 : 0 : fprintf (stderr, "<VEC");
1240 : 0 : dump_addr (stderr, " ", ref.address ());
1241 : :
1242 : 0 : FOR_EACH_VEC_ELT (ref, ix, elt)
1243 : : {
1244 : 0 : fprintf (stderr, "elt:%d ", ix);
1245 : 0 : debug_raw (elt);
1246 : : }
1247 : 0 : }
1248 : :
1249 : : DEBUG_FUNCTION void
1250 : 0 : debug_raw (vec<tree, va_gc> *ptr)
1251 : : {
1252 : 0 : if (ptr)
1253 : 0 : debug_raw (*ptr);
1254 : : else
1255 : 0 : fprintf (stderr, "<nil>\n");
1256 : 0 : }
1257 : :
1258 : : static void
1259 : 0 : debug_slim (tree t)
1260 : : {
1261 : 0 : print_node_brief (stderr, "", t, 0);
1262 : 0 : }
1263 : :
1264 : 0 : DEFINE_DEBUG_VEC (tree)
1265 : 0 : DEFINE_DEBUG_HASH_SET (tree)
|