1 /* Tree-dumping functionality for intermediate representation.
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 Free Software Foundation, Inc.
4 Written by Mark Mitchell <mark@codesourcery.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to
20 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
25 #include "coretypes.h"
29 #include "tree-dump.h"
31 static void dump_access (dump_info_p, tree);
33 static void dump_op (dump_info_p, tree);
35 /* Dump a representation of the accessibility information associated
39 dump_access (dump_info_p di, tree t)
41 if (TREE_PROTECTED(t))
42 dump_string_field (di, "accs", "prot");
43 else if (TREE_PRIVATE(t))
44 dump_string_field (di, "accs", "priv");
46 dump_string_field (di, "accs", "pub");
49 /* Dump a representation of the specific operator for an overloaded
50 operator associated with node t. */
53 dump_op (dump_info_p di, tree t)
55 switch (DECL_OVERLOADED_OPERATOR_P (t)) {
57 dump_string (di, "new");
60 dump_string (di, "vecnew");
63 dump_string (di, "delete");
66 dump_string (di, "vecdelete");
69 dump_string (di, "pos");
72 dump_string (di, "neg");
75 dump_string (di, "addr");
78 dump_string(di, "deref");
81 dump_string(di, "not");
84 dump_string(di, "lnot");
86 case PREINCREMENT_EXPR:
87 dump_string(di, "preinc");
89 case PREDECREMENT_EXPR:
90 dump_string(di, "predec");
93 if (DECL_ASSIGNMENT_OPERATOR_P (t))
94 dump_string (di, "plusassign");
96 dump_string(di, "plus");
99 if (DECL_ASSIGNMENT_OPERATOR_P (t))
100 dump_string (di, "minusassign");
102 dump_string(di, "minus");
105 if (DECL_ASSIGNMENT_OPERATOR_P (t))
106 dump_string (di, "multassign");
108 dump_string (di, "mult");
111 if (DECL_ASSIGNMENT_OPERATOR_P (t))
112 dump_string (di, "divassign");
114 dump_string (di, "div");
117 if (DECL_ASSIGNMENT_OPERATOR_P (t))
118 dump_string (di, "modassign");
120 dump_string (di, "mod");
123 if (DECL_ASSIGNMENT_OPERATOR_P (t))
124 dump_string (di, "andassign");
126 dump_string (di, "and");
129 if (DECL_ASSIGNMENT_OPERATOR_P (t))
130 dump_string (di, "orassign");
132 dump_string (di, "or");
135 if (DECL_ASSIGNMENT_OPERATOR_P (t))
136 dump_string (di, "xorassign");
138 dump_string (di, "xor");
141 if (DECL_ASSIGNMENT_OPERATOR_P (t))
142 dump_string (di, "lshiftassign");
144 dump_string (di, "lshift");
147 if (DECL_ASSIGNMENT_OPERATOR_P (t))
148 dump_string (di, "rshiftassign");
150 dump_string (di, "rshift");
153 dump_string (di, "eq");
156 dump_string (di, "ne");
159 dump_string (di, "lt");
162 dump_string (di, "gt");
165 dump_string (di, "le");
168 dump_string (di, "ge");
170 case TRUTH_ANDIF_EXPR:
171 dump_string (di, "land");
173 case TRUTH_ORIF_EXPR:
174 dump_string (di, "lor");
177 dump_string (di, "compound");
180 dump_string (di, "memref");
183 dump_string (di, "ref");
186 dump_string (di, "subs");
188 case POSTINCREMENT_EXPR:
189 dump_string (di, "postinc");
191 case POSTDECREMENT_EXPR:
192 dump_string (di, "postdec");
195 dump_string (di, "call");
198 if (DECL_ASSIGNMENT_OPERATOR_P (t))
199 dump_string (di, "assign");
207 cp_dump_tree (void* dump_info, tree t)
210 dump_info_p di = (dump_info_p) dump_info;
212 /* Figure out what kind of node this is. */
213 code = TREE_CODE (t);
217 if (DECL_LANG_SPECIFIC (t) && DECL_LANGUAGE (t) != lang_cplusplus)
218 dump_string_field (di, "lang", language_to_string (DECL_LANGUAGE (t)));
223 case IDENTIFIER_NODE:
224 if (IDENTIFIER_OPNAME_P (t))
226 dump_string_field (di, "note", "operator");
229 else if (IDENTIFIER_TYPENAME_P (t))
231 dump_child ("tynm", TREE_TYPE (t));
237 dump_string_field (di, "note", "ptrmem");
238 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
239 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
243 if (TYPE_PTRMEMFUNC_P (t))
245 dump_string_field (di, "note", "ptrmem");
246 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
247 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
253 /* Is it a type used as a base? */
254 if (TYPE_CONTEXT (t) && TREE_CODE (TYPE_CONTEXT (t)) == TREE_CODE (t)
255 && CLASSTYPE_AS_BASE (TYPE_CONTEXT (t)) == t)
257 dump_child ("bfld", TYPE_CONTEXT (t));
261 if (! IS_AGGR_TYPE (t))
264 dump_child ("vfld", TYPE_VFIELD (t));
265 if (CLASSTYPE_TEMPLATE_SPECIALIZATION(t))
266 dump_string(di, "spec");
268 if (!dump_flag (di, TDF_SLIM, t) && TYPE_BINFO (t))
274 for (binfo = TYPE_BINFO (t), i = 0;
275 BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
277 dump_child ("base", BINFO_TYPE (base_binfo));
278 if (BINFO_VIRTUAL_P (base_binfo))
279 dump_string_field (di, "spec", "virt");
280 dump_access (di, base_binfo);
287 if (DECL_MUTABLE_P (t))
288 dump_string_field (di, "spec", "mutable");
292 if (TREE_CODE (CP_DECL_CONTEXT (t)) == RECORD_TYPE)
294 if (TREE_STATIC (t) && !TREE_PUBLIC (t))
295 dump_string_field (di, "link", "static");
299 if (!DECL_THUNK_P (t))
301 if (DECL_OVERLOADED_OPERATOR_P (t)) {
302 dump_string_field (di, "note", "operator");
305 if (DECL_FUNCTION_MEMBER_P (t))
307 dump_string_field (di, "note", "member");
310 if (DECL_PURE_VIRTUAL_P (t))
311 dump_string_field (di, "spec", "pure");
312 if (DECL_VIRTUAL_P (t))
313 dump_string_field (di, "spec", "virt");
314 if (DECL_CONSTRUCTOR_P (t))
315 dump_string_field (di, "note", "constructor");
316 if (DECL_DESTRUCTOR_P (t))
317 dump_string_field (di, "note", "destructor");
318 if (DECL_CONV_FN_P (t))
319 dump_string_field (di, "note", "conversion");
320 if (DECL_GLOBAL_CTOR_P (t))
321 dump_string_field (di, "note", "global init");
322 if (DECL_GLOBAL_DTOR_P (t))
323 dump_string_field (di, "note", "global fini");
324 if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t))
325 dump_string_field (di, "note", "pseudo tmpl");
329 tree virt = THUNK_VIRTUAL_OFFSET (t);
331 dump_string_field (di, "note", "thunk");
332 if (DECL_THIS_THUNK_P (t))
333 dump_string_field (di, "note", "this adjusting");
336 dump_string_field (di, "note", "result adjusting");
338 virt = BINFO_VPTR_FIELD (virt);
340 dump_int (di, "fixd", THUNK_FIXED_OFFSET (t));
342 dump_int (di, "virt", tree_low_cst (virt, 0));
343 dump_child ("fn", DECL_INITIAL (t));
348 if (DECL_NAMESPACE_ALIAS (t))
349 dump_child ("alis", DECL_NAMESPACE_ALIAS (t));
350 else if (!dump_flag (di, TDF_SLIM, t))
351 dump_child ("dcls", cp_namespace_decls (t));
355 dump_child ("rslt", DECL_TEMPLATE_RESULT (t));
356 dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t));
357 dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t));
358 dump_child ("prms", DECL_TEMPLATE_PARMS (t));
362 dump_child ("crnt", OVL_CURRENT (t));
363 dump_child ("chan", OVL_CHAIN (t));
369 dump_string_field (di, "note", "cleanup");
370 dump_child ("body", TRY_STMTS (t));
371 dump_child ("hdlr", TRY_HANDLERS (t));
376 dump_child ("body", EH_SPEC_STMTS (t));
377 dump_child ("raises", EH_SPEC_RAISES (t));
381 dump_child ("clas", PTRMEM_CST_CLASS (t));
382 dump_child ("mbr", PTRMEM_CST_MEMBER (t));
386 /* These nodes are unary, but do not have code class `1'. */
387 dump_child ("op 0", TREE_OPERAND (t, 0));
391 dump_int (di, "ctor", AGGR_INIT_VIA_CTOR_P (t));
392 dump_child ("fn", TREE_OPERAND (t, 0));
393 dump_child ("args", TREE_OPERAND (t, 1));
394 dump_child ("decl", TREE_OPERAND (t, 2));
399 dump_child ("parm", HANDLER_PARMS (t));
400 dump_child ("body", HANDLER_BODY (t));
403 case MUST_NOT_THROW_EXPR:
405 dump_child ("body", TREE_OPERAND (t, 0));
410 dump_child ("nmsp", USING_STMT_NAMESPACE (t));
415 dump_child ("decl", CLEANUP_DECL (t));
416 dump_child ("expr", CLEANUP_EXPR (t));
417 dump_child ("body", CLEANUP_BODY (t));
422 dump_child ("cond", IF_COND (t));
423 dump_child ("then", THEN_CLAUSE (t));
424 dump_child ("else", ELSE_CLAUSE (t));
434 dump_child ("body", DO_BODY (t));
435 dump_child ("cond", DO_COND (t));
436 /* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
437 dump_child ("attrs", DO_ATTRIBUTES (t));
438 /* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
443 dump_child ("init", FOR_INIT_STMT (t));
444 dump_child ("cond", FOR_COND (t));
445 dump_child ("expr", FOR_EXPR (t));
446 dump_child ("body", FOR_BODY (t));
447 /* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
448 dump_child ("attrs", FOR_ATTRIBUTES (t));
449 /* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
454 dump_child ("cond", SWITCH_STMT_COND (t));
455 dump_child ("body", SWITCH_STMT_BODY (t));
460 dump_child ("cond", WHILE_COND (t));
461 dump_child ("body", WHILE_BODY (t));
462 /* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
463 dump_child ("attrs", WHILE_ATTRIBUTES (t));
464 /* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
468 dump_child ("stmt", STMT_EXPR_STMT (t));
473 dump_child ("expr", EXPR_STMT_EXPR (t));
480 return c_dump_tree (di, t);