1 /* Tree-dumping functionality for intermediate representation.
2 Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
3 Written by Mark Mitchell <mark@codesourcery.com>
5 This file is part of GCC.
7 GCC 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 GCC 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 GCC; 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 (dump_info_p
, tree
);
32 static void dump_op (dump_info_p
, tree
);
34 /* Dump a representation of the accessibility information associated
38 dump_access (dump_info_p di
, tree t
)
40 if (TREE_PROTECTED(t
))
41 dump_string (di
, "protected");
42 else if (TREE_PRIVATE(t
))
43 dump_string (di
, "private");
45 dump_string (di
, "public");
48 /* Dump a representation of the specific operator for an overloaded
49 operator associated with node t. */
52 dump_op (dump_info_p di
, tree t
)
54 switch (DECL_OVERLOADED_OPERATOR_P (t
)) {
56 dump_string (di
, "new");
59 dump_string (di
, "vecnew");
62 dump_string (di
, "delete");
65 dump_string (di
, "vecdelete");
68 dump_string (di
, "pos");
71 dump_string (di
, "neg");
74 dump_string (di
, "addr");
77 dump_string(di
, "deref");
80 dump_string(di
, "not");
83 dump_string(di
, "lnot");
85 case PREINCREMENT_EXPR
:
86 dump_string(di
, "preinc");
88 case PREDECREMENT_EXPR
:
89 dump_string(di
, "predec");
92 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
93 dump_string (di
, "plusassign");
95 dump_string(di
, "plus");
98 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
99 dump_string (di
, "minusassign");
101 dump_string(di
, "minus");
104 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
105 dump_string (di
, "multassign");
107 dump_string (di
, "mult");
110 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
111 dump_string (di
, "divassign");
113 dump_string (di
, "div");
116 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
117 dump_string (di
, "modassign");
119 dump_string (di
, "mod");
122 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
123 dump_string (di
, "andassign");
125 dump_string (di
, "and");
128 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
129 dump_string (di
, "orassign");
131 dump_string (di
, "or");
134 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
135 dump_string (di
, "xorassign");
137 dump_string (di
, "xor");
140 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
141 dump_string (di
, "lshiftassign");
143 dump_string (di
, "lshift");
146 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
147 dump_string (di
, "rshiftassign");
149 dump_string (di
, "rshift");
152 dump_string (di
, "eq");
155 dump_string (di
, "ne");
158 dump_string (di
, "lt");
161 dump_string (di
, "gt");
164 dump_string (di
, "le");
167 dump_string (di
, "ge");
169 case TRUTH_ANDIF_EXPR
:
170 dump_string (di
, "land");
172 case TRUTH_ORIF_EXPR
:
173 dump_string (di
, "lor");
176 dump_string (di
, "compound");
179 dump_string (di
, "memref");
182 dump_string (di
, "ref");
185 dump_string (di
, "subs");
187 case POSTINCREMENT_EXPR
:
188 dump_string (di
, "postinc");
190 case POSTDECREMENT_EXPR
:
191 dump_string (di
, "postdec");
194 dump_string (di
, "call");
197 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
198 dump_string (di
, "assign");
206 cp_dump_tree (void* dump_info
, tree t
)
209 dump_info_p di
= (dump_info_p
) dump_info
;
211 /* Figure out what kind of node this is. */
212 code
= TREE_CODE (t
);
216 if (DECL_LANG_SPECIFIC (t
) && DECL_LANGUAGE (t
) != lang_cplusplus
)
217 dump_string (di
, language_to_string (DECL_LANGUAGE (t
)));
222 case IDENTIFIER_NODE
:
223 if (IDENTIFIER_OPNAME_P (t
))
225 dump_string (di
, "operator");
228 else if (IDENTIFIER_TYPENAME_P (t
))
230 dump_child ("tynm", TREE_TYPE (t
));
236 dump_string (di
, "ptrmem");
237 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t
));
238 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t
));
242 if (TYPE_PTRMEMFUNC_P (t
))
244 dump_string (di
, "ptrmem");
245 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t
));
246 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t
));
252 /* Is it a type used as a base? */
253 if (TYPE_CONTEXT (t
) && TREE_CODE (TYPE_CONTEXT (t
)) == TREE_CODE (t
)
254 && CLASSTYPE_AS_BASE (TYPE_CONTEXT (t
)) == t
)
256 dump_child ("bfld", TYPE_CONTEXT (t
));
260 if (! IS_AGGR_TYPE (t
))
263 dump_child ("vfld", TYPE_VFIELD (t
));
264 if (CLASSTYPE_TEMPLATE_SPECIALIZATION(t
))
265 dump_string(di
, "spec");
267 if (!dump_flag (di
, TDF_SLIM
, t
) && TYPE_BINFO (t
))
273 for (binfo
= TYPE_BINFO (t
), i
= 0;
274 BINFO_BASE_ITERATE (binfo
, i
, base_binfo
); ++i
)
276 dump_child ("base", BINFO_TYPE (base_binfo
));
277 if (BINFO_VIRTUAL_P (base_binfo
))
278 dump_string (di
, "virtual");
279 dump_access (di
, base_binfo
);
286 if (DECL_MUTABLE_P (t
))
287 dump_string(di
, "mutable");
291 if (TREE_CODE (CP_DECL_CONTEXT (t
)) == RECORD_TYPE
)
293 if (TREE_STATIC (t
) && !TREE_PUBLIC (t
))
294 dump_string (di
, "static");
298 if (!DECL_THUNK_P (t
))
300 if (DECL_OVERLOADED_OPERATOR_P (t
)) {
301 dump_string (di
, "operator");
304 if (DECL_FUNCTION_MEMBER_P (t
))
306 dump_string (di
, "member");
309 if (DECL_PURE_VIRTUAL_P (t
))
310 dump_string (di
, "pure");
311 if (DECL_VIRTUAL_P (t
))
312 dump_string (di
, "virtual");
313 if (DECL_CONSTRUCTOR_P (t
))
314 dump_string (di
, "constructor");
315 if (DECL_DESTRUCTOR_P (t
))
316 dump_string (di
, "destructor");
317 if (DECL_CONV_FN_P (t
))
318 dump_string (di
, "conversion");
319 if (DECL_GLOBAL_CTOR_P (t
))
320 dump_string (di
, "global init");
321 if (DECL_GLOBAL_DTOR_P (t
))
322 dump_string (di
, "global fini");
323 if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t
))
324 dump_string (di
, "pseudo tmpl");
328 tree virt
= THUNK_VIRTUAL_OFFSET (t
);
330 dump_string (di
, "thunk");
331 if (DECL_THIS_THUNK_P (t
))
332 dump_string (di
, "this adjusting");
335 dump_string (di
, "result adjusting");
337 virt
= BINFO_VPTR_FIELD (virt
);
339 dump_int (di
, "fixd", THUNK_FIXED_OFFSET (t
));
341 dump_int (di
, "virt", tree_low_cst (virt
, 0));
342 dump_child ("fn", DECL_INITIAL (t
));
347 if (DECL_NAMESPACE_ALIAS (t
))
348 dump_child ("alis", DECL_NAMESPACE_ALIAS (t
));
349 else if (!dump_flag (di
, TDF_SLIM
, t
))
350 dump_child ("dcls", cp_namespace_decls (t
));
354 dump_child ("rslt", DECL_TEMPLATE_RESULT (t
));
355 dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t
));
356 dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t
));
357 dump_child ("prms", DECL_TEMPLATE_PARMS (t
));
361 dump_child ("crnt", OVL_CURRENT (t
));
362 dump_child ("chan", OVL_CHAIN (t
));
368 dump_string (di
, "cleanup");
369 dump_child ("body", TRY_STMTS (t
));
370 dump_child ("hdlr", TRY_HANDLERS (t
));
375 dump_child ("body", EH_SPEC_STMTS (t
));
376 dump_child ("raises", EH_SPEC_RAISES (t
));
380 dump_child ("clas", PTRMEM_CST_CLASS (t
));
381 dump_child ("mbr", PTRMEM_CST_MEMBER (t
));
385 /* These nodes are unary, but do not have code class `1'. */
386 dump_child ("op 0", TREE_OPERAND (t
, 0));
390 dump_int (di
, "ctor", AGGR_INIT_VIA_CTOR_P (t
));
391 dump_child ("fn", TREE_OPERAND (t
, 0));
392 dump_child ("args", TREE_OPERAND (t
, 1));
393 dump_child ("decl", TREE_OPERAND (t
, 2));
398 dump_child ("parm", HANDLER_PARMS (t
));
399 dump_child ("body", HANDLER_BODY (t
));
402 case MUST_NOT_THROW_EXPR
:
404 dump_child ("body", TREE_OPERAND (t
, 0));
409 dump_child ("nmsp", USING_STMT_NAMESPACE (t
));
414 dump_child ("decl", CLEANUP_DECL (t
));
415 dump_child ("expr", CLEANUP_EXPR (t
));
416 dump_child ("body", CLEANUP_BODY (t
));
421 dump_child ("cond", IF_COND (t
));
422 dump_child ("then", THEN_CLAUSE (t
));
423 dump_child ("else", ELSE_CLAUSE (t
));
430 return c_dump_tree (di
, t
);