1 /* Tree-dumping functionality for intermediate representation.
2 Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3 Written by Mark Mitchell <mark@codesourcery.com>
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "coretypes.h"
28 #include "tree-dump.h"
30 static void dump_access
31 PARAMS ((dump_info_p, tree));
34 PARAMS ((dump_info_p, tree));
36 /* Dump a representation of the accessibility information associated
44 if (TREE_PROTECTED(t))
45 dump_string (di, "protected");
46 else if (TREE_PRIVATE(t))
47 dump_string (di, "private");
49 dump_string (di, "public");
52 /* Dump a representation of the specific operator for an overloaded
53 operator associated with node t. */
60 switch (DECL_OVERLOADED_OPERATOR_P (t)) {
62 dump_string (di, "new");
65 dump_string (di, "vecnew");
68 dump_string (di, "delete");
71 dump_string (di, "vecdelete");
74 dump_string (di, "pos");
77 dump_string (di, "neg");
80 dump_string (di, "addr");
83 dump_string(di, "deref");
86 dump_string(di, "not");
89 dump_string(di, "lnot");
91 case PREINCREMENT_EXPR:
92 dump_string(di, "preinc");
94 case PREDECREMENT_EXPR:
95 dump_string(di, "predec");
98 if (DECL_ASSIGNMENT_OPERATOR_P (t))
99 dump_string (di, "plusassign");
101 dump_string(di, "plus");
104 if (DECL_ASSIGNMENT_OPERATOR_P (t))
105 dump_string (di, "minusassign");
107 dump_string(di, "minus");
110 if (DECL_ASSIGNMENT_OPERATOR_P (t))
111 dump_string (di, "multassign");
113 dump_string (di, "mult");
116 if (DECL_ASSIGNMENT_OPERATOR_P (t))
117 dump_string (di, "divassign");
119 dump_string (di, "div");
122 if (DECL_ASSIGNMENT_OPERATOR_P (t))
123 dump_string (di, "modassign");
125 dump_string (di, "mod");
128 if (DECL_ASSIGNMENT_OPERATOR_P (t))
129 dump_string (di, "andassign");
131 dump_string (di, "and");
134 if (DECL_ASSIGNMENT_OPERATOR_P (t))
135 dump_string (di, "orassign");
137 dump_string (di, "or");
140 if (DECL_ASSIGNMENT_OPERATOR_P (t))
141 dump_string (di, "xorassign");
143 dump_string (di, "xor");
146 if (DECL_ASSIGNMENT_OPERATOR_P (t))
147 dump_string (di, "lshiftassign");
149 dump_string (di, "lshift");
152 if (DECL_ASSIGNMENT_OPERATOR_P (t))
153 dump_string (di, "rshiftassign");
155 dump_string (di, "rshift");
158 dump_string (di, "eq");
161 dump_string (di, "ne");
164 dump_string (di, "lt");
167 dump_string (di, "gt");
170 dump_string (di, "le");
173 dump_string (di, "ge");
175 case TRUTH_ANDIF_EXPR:
176 dump_string (di, "land");
178 case TRUTH_ORIF_EXPR:
179 dump_string (di, "lor");
182 dump_string (di, "compound");
185 dump_string (di, "memref");
188 dump_string (di, "ref");
191 dump_string (di, "subs");
193 case POSTINCREMENT_EXPR:
194 dump_string (di, "postinc");
196 case POSTDECREMENT_EXPR:
197 dump_string (di, "postdec");
200 dump_string (di, "call");
203 if (DECL_ASSIGNMENT_OPERATOR_P (t))
204 dump_string (di, "assign");
212 cp_dump_tree (dump_info, t)
217 dump_info_p di = (dump_info_p) dump_info;
219 /* Figure out what kind of node this is. */
220 code = TREE_CODE (t);
224 if (DECL_LANG_SPECIFIC (t) && DECL_LANGUAGE (t) != lang_cplusplus)
225 dump_string (di, language_to_string (DECL_LANGUAGE (t), 0));
230 case IDENTIFIER_NODE:
231 if (IDENTIFIER_OPNAME_P (t))
233 dump_string (di, "operator");
236 else if (IDENTIFIER_TYPENAME_P (t))
238 dump_child ("tynm", TREE_TYPE (t));
241 else if (t == anonymous_namespace_name)
243 dump_string (di, "unnamed");
249 if (TYPE_PTRMEM_P (t))
251 dump_string (di, "ptrmem");
252 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
253 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
260 if (TYPE_PTRMEMFUNC_P (t))
262 dump_string (di, "ptrmem");
263 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
264 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
268 /* Is it a type used as a base? */
269 if (TYPE_CONTEXT (t) && TREE_CODE (TYPE_CONTEXT (t)) == TREE_CODE (t)
270 && CLASSTYPE_AS_BASE (TYPE_CONTEXT (t)) == t)
272 dump_child ("bfld", TYPE_CONTEXT (t));
276 dump_child ("vfld", TYPE_VFIELD (t));
277 if (CLASSTYPE_TEMPLATE_SPECIALIZATION(t))
278 dump_string(di, "spec");
280 if (!dump_flag (di, TDF_SLIM, t))
284 for (i = 0; i < CLASSTYPE_N_BASECLASSES (t); ++i)
286 tree base_binfo = BINFO_BASETYPE (TYPE_BINFO (t), i);
287 dump_child ("base", BINFO_TYPE (base_binfo));
288 if (TREE_VIA_VIRTUAL (base_binfo))
289 dump_string (di, "virtual");
290 dump_access (di, base_binfo);
297 if (DECL_MUTABLE_P (t))
298 dump_string(di, "mutable");
302 if (TREE_CODE (CP_DECL_CONTEXT (t)) == RECORD_TYPE)
304 if (TREE_STATIC (t) && !TREE_PUBLIC (t))
305 dump_string (di, "static");
309 if (!DECL_THUNK_P (t))
311 if (DECL_OVERLOADED_OPERATOR_P (t)) {
312 dump_string (di, "operator");
315 if (DECL_FUNCTION_MEMBER_P (t))
317 dump_string (di, "member");
320 if (DECL_PURE_VIRTUAL_P (t))
321 dump_string (di, "pure");
322 if (DECL_VIRTUAL_P (t))
323 dump_string (di, "virtual");
324 if (DECL_CONSTRUCTOR_P (t))
325 dump_string (di, "constructor");
326 if (DECL_DESTRUCTOR_P (t))
327 dump_string (di, "destructor");
328 if (DECL_CONV_FN_P (t))
329 dump_string (di, "conversion");
330 if (DECL_GLOBAL_CTOR_P (t))
331 dump_string (di, "global init");
332 if (DECL_GLOBAL_DTOR_P (t))
333 dump_string (di, "global fini");
334 if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t))
335 dump_string (di, "pseudo tmpl");
339 dump_string (di, "thunk");
340 if (DECL_THIS_THUNK_P (t))
341 dump_string (di, "this adjusting");
343 dump_string (di, "result adjusting");
344 dump_int (di, "fixd", THUNK_FIXED_OFFSET (t));
345 dump_child ("virt", THUNK_VIRTUAL_OFFSET (t));
346 dump_child ("fn", DECL_INITIAL (t));
351 if (DECL_NAMESPACE_ALIAS (t))
352 dump_child ("alis", DECL_NAMESPACE_ALIAS (t));
353 else if (!dump_flag (di, TDF_SLIM, t))
354 dump_child ("dcls", cp_namespace_decls (t));
358 dump_child ("rslt", DECL_TEMPLATE_RESULT (t));
359 dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t));
360 dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t));
361 dump_child ("prms", DECL_TEMPLATE_PARMS (t));
365 dump_child ("crnt", OVL_CURRENT (t));
366 dump_child ("chan", OVL_CHAIN (t));
372 dump_string (di, "cleanup");
373 dump_child ("body", TRY_STMTS (t));
374 dump_child ("hdlr", TRY_HANDLERS (t));
375 dump_next_stmt (di, t);
380 dump_child ("body", EH_SPEC_STMTS (t));
381 dump_child ("raises", EH_SPEC_RAISES (t));
382 dump_next_stmt (di, t);
386 dump_child ("clas", PTRMEM_CST_CLASS (t));
387 dump_child ("mbr", PTRMEM_CST_MEMBER (t));
391 /* These nodes are unary, but do not have code class `1'. */
392 dump_child ("op 0", TREE_OPERAND (t, 0));
396 dump_int (di, "ctor", AGGR_INIT_VIA_CTOR_P (t));
397 dump_child ("fn", TREE_OPERAND (t, 0));
398 dump_child ("args", TREE_OPERAND (t, 1));
399 dump_child ("decl", TREE_OPERAND (t, 2));
404 dump_child ("parm", HANDLER_PARMS (t));
405 dump_child ("body", HANDLER_BODY (t));
406 dump_next_stmt (di, t);
409 case MUST_NOT_THROW_EXPR:
411 dump_child ("body", TREE_OPERAND (t, 0));
412 dump_next_stmt (di, t);
417 dump_child ("nmsp", USING_STMT_NAMESPACE (t));
418 dump_next_stmt (di, t);
425 return c_dump_tree (di, t);