1 /* Tree-dumping functionality for intermediate representation.
2 Copyright (C) 1999, 2000, 2001 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. */
26 #include "tree-dump.h"
28 static void dump_access
29 PARAMS ((dump_info_p
, tree
));
32 PARAMS ((dump_info_p
, tree
));
34 /* Dump a representation of the accessibility information associated
42 if (TREE_PROTECTED(t
))
43 dump_string (di
, "protected");
44 else if (TREE_PRIVATE(t
))
45 dump_string (di
, "private");
47 dump_string (di
, "public");
50 /* Dump a representation of the specific operator for an overloaded
51 operator associated with node t.
59 switch (DECL_OVERLOADED_OPERATOR_P (t
)) {
61 dump_string (di
, "new");
64 dump_string (di
, "vecnew");
67 dump_string (di
, "delete");
70 dump_string (di
, "vecdelete");
73 dump_string (di
, "pos");
76 dump_string (di
, "neg");
79 dump_string (di
, "addr");
82 dump_string(di
, "deref");
85 dump_string(di
, "not");
88 dump_string(di
, "lnot");
90 case PREINCREMENT_EXPR
:
91 dump_string(di
, "preinc");
93 case PREDECREMENT_EXPR
:
94 dump_string(di
, "predec");
97 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
98 dump_string (di
, "plusassign");
100 dump_string(di
, "plus");
103 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
104 dump_string (di
, "minusassign");
106 dump_string(di
, "minus");
109 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
110 dump_string (di
, "multassign");
112 dump_string (di
, "mult");
115 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
116 dump_string (di
, "divassign");
118 dump_string (di
, "div");
121 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
122 dump_string (di
, "modassign");
124 dump_string (di
, "mod");
127 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
128 dump_string (di
, "andassign");
130 dump_string (di
, "and");
133 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
134 dump_string (di
, "orassign");
136 dump_string (di
, "or");
139 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
140 dump_string (di
, "xorassign");
142 dump_string (di
, "xor");
145 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
146 dump_string (di
, "lshiftassign");
148 dump_string (di
, "lshift");
151 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
152 dump_string (di
, "rshiftassign");
154 dump_string (di
, "rshift");
157 dump_string (di
, "eq");
160 dump_string (di
, "ne");
163 dump_string (di
, "lt");
166 dump_string (di
, "gt");
169 dump_string (di
, "le");
172 dump_string (di
, "ge");
174 case TRUTH_ANDIF_EXPR
:
175 dump_string (di
, "land");
177 case TRUTH_ORIF_EXPR
:
178 dump_string (di
, "lor");
181 dump_string (di
, "compound");
184 dump_string (di
, "memref");
187 dump_string (di
, "ref");
190 dump_string (di
, "subs");
192 case POSTINCREMENT_EXPR
:
193 dump_string (di
, "postinc");
195 case POSTDECREMENT_EXPR
:
196 dump_string (di
, "postdec");
199 dump_string (di
, "call");
202 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
203 dump_string (di
, "assign");
211 cp_dump_tree (dump_info
, t
)
216 dump_info_p di
= (dump_info_p
) dump_info
;
218 /* Figure out what kind of node this is. */
219 code
= TREE_CODE (t
);
223 if (DECL_LANG_SPECIFIC (t
) && DECL_LANGUAGE (t
) != lang_cplusplus
)
224 dump_string (di
, language_to_string (DECL_LANGUAGE (t
), 0));
229 case IDENTIFIER_NODE
:
230 if (IDENTIFIER_OPNAME_P (t
))
232 dump_string (di
, "operator");
235 else if (IDENTIFIER_TYPENAME_P (t
))
237 dump_child ("tynm", TREE_TYPE (t
));
240 else if (t
== anonymous_namespace_name
)
242 dump_string (di
, "unnamed");
248 if (TYPE_PTRMEM_P (t
))
250 dump_string (di
, "ptrmem");
251 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t
));
252 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t
));
259 if (TYPE_PTRMEMFUNC_P (t
))
261 dump_string (di
, "ptrmem");
262 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t
));
263 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t
));
267 dump_child ("vfld", TYPE_VFIELD (t
));
268 if (CLASSTYPE_TEMPLATE_SPECIALIZATION(t
))
269 dump_string(di
, "spec");
271 if (!dump_flag (di
, TDF_SLIM
, t
))
275 for (i
= 0; i
< CLASSTYPE_N_BASECLASSES (t
); ++i
)
277 tree base_binfo
= BINFO_BASETYPE (TYPE_BINFO (t
), i
);
278 dump_child ("base", BINFO_TYPE (base_binfo
));
279 if (TREE_VIA_VIRTUAL (base_binfo
))
280 dump_string (di
, "virtual");
281 dump_access (di
, base_binfo
);
288 if (DECL_MUTABLE_P (t
))
289 dump_string(di
, "mutable");
293 if (TREE_CODE (CP_DECL_CONTEXT (t
)) == RECORD_TYPE
)
295 if (TREE_STATIC (t
) && !TREE_PUBLIC (t
))
296 dump_string (di
, "static");
300 if (!DECL_THUNK_P (t
))
302 if (DECL_OVERLOADED_OPERATOR_P (t
)) {
303 dump_string (di
, "operator");
306 if (DECL_FUNCTION_MEMBER_P (t
))
308 dump_string (di
, "member");
311 if (DECL_PURE_VIRTUAL_P (t
))
312 dump_string (di
, "pure");
313 if (DECL_VIRTUAL_P (t
))
314 dump_string (di
, "virtual");
315 if (DECL_CONSTRUCTOR_P (t
))
316 dump_string (di
, "constructor");
317 if (DECL_DESTRUCTOR_P (t
))
318 dump_string (di
, "destructor");
319 if (DECL_CONV_FN_P (t
))
320 dump_string (di
, "conversion");
321 if (DECL_GLOBAL_CTOR_P (t
) || DECL_GLOBAL_DTOR_P (t
))
323 if (DECL_GLOBAL_CTOR_P (t
))
324 dump_string (di
, "global init");
325 if (DECL_GLOBAL_DTOR_P (t
))
326 dump_string (di
, "global fini");
327 dump_int (di
, "prio", GLOBAL_INIT_PRIORITY (t
));
329 if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t
))
330 dump_string (di
, "pseudo tmpl");
334 dump_string (di
, "thunk");
335 dump_int (di
, "dlta", THUNK_DELTA (t
));
336 dump_child ("vcll", THUNK_VCALL_OFFSET (t
));
337 dump_child ("fn", DECL_INITIAL (t
));
342 if (DECL_NAMESPACE_ALIAS (t
))
343 dump_child ("alis", DECL_NAMESPACE_ALIAS (t
));
344 else if (!dump_flag (di
, TDF_SLIM
, t
))
345 dump_child ("dcls", cp_namespace_decls (t
));
349 dump_child ("rslt", DECL_TEMPLATE_RESULT (t
));
350 dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t
));
351 dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t
));
352 dump_child ("prms", DECL_TEMPLATE_PARMS (t
));
356 dump_child ("crnt", OVL_CURRENT (t
));
357 dump_child ("chan", OVL_CHAIN (t
));
363 dump_string (di
, "cleanup");
364 dump_child ("body", TRY_STMTS (t
));
365 dump_child ("hdlr", TRY_HANDLERS (t
));
366 dump_next_stmt (di
, t
);
371 dump_child ("body", EH_SPEC_STMTS (t
));
372 dump_child ("raises", EH_SPEC_RAISES (t
));
373 dump_next_stmt (di
, t
);
377 dump_child ("clas", PTRMEM_CST_CLASS (t
));
378 dump_child ("mbr", PTRMEM_CST_MEMBER (t
));
382 /* These nodes are unary, but do not have code class `1'. */
383 dump_child ("op 0", TREE_OPERAND (t
, 0));
387 dump_int (di
, "ctor", AGGR_INIT_VIA_CTOR_P (t
));
388 dump_child ("fn", TREE_OPERAND (t
, 0));
389 dump_child ("args", TREE_OPERAND (t
, 1));
390 dump_child ("decl", TREE_OPERAND (t
, 2));
395 dump_child ("decl", CLEANUP_DECL (t
));
396 dump_child ("expr", CLEANUP_EXPR (t
));
397 dump_next_stmt (di
, t
);
402 if (CTOR_BEGIN_P (t
))
403 dump_string (di
, "begn");
405 dump_string (di
, "end");
406 dump_next_stmt (di
, t
);
411 dump_child ("parm", HANDLER_PARMS (t
));
412 dump_child ("body", HANDLER_BODY (t
));
413 dump_next_stmt (di
, t
);
416 case MUST_NOT_THROW_EXPR
:
418 dump_child ("body", TREE_OPERAND (t
, 0));
419 dump_next_stmt (di
, t
);
424 dump_child ("clnp", TREE_OPERAND (t
, 0));
425 dump_next_stmt (di
, t
);
430 dump_child ("nmsp", USING_STMT_NAMESPACE (t
));
431 dump_next_stmt (di
, t
);