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. */
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. */
58 switch (DECL_OVERLOADED_OPERATOR_P (t
)) {
60 dump_string (di
, "new");
63 dump_string (di
, "vecnew");
66 dump_string (di
, "delete");
69 dump_string (di
, "vecdelete");
72 dump_string (di
, "pos");
75 dump_string (di
, "neg");
78 dump_string (di
, "addr");
81 dump_string(di
, "deref");
84 dump_string(di
, "not");
87 dump_string(di
, "lnot");
89 case PREINCREMENT_EXPR
:
90 dump_string(di
, "preinc");
92 case PREDECREMENT_EXPR
:
93 dump_string(di
, "predec");
96 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
97 dump_string (di
, "plusassign");
99 dump_string(di
, "plus");
102 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
103 dump_string (di
, "minusassign");
105 dump_string(di
, "minus");
108 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
109 dump_string (di
, "multassign");
111 dump_string (di
, "mult");
114 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
115 dump_string (di
, "divassign");
117 dump_string (di
, "div");
120 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
121 dump_string (di
, "modassign");
123 dump_string (di
, "mod");
126 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
127 dump_string (di
, "andassign");
129 dump_string (di
, "and");
132 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
133 dump_string (di
, "orassign");
135 dump_string (di
, "or");
138 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
139 dump_string (di
, "xorassign");
141 dump_string (di
, "xor");
144 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
145 dump_string (di
, "lshiftassign");
147 dump_string (di
, "lshift");
150 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
151 dump_string (di
, "rshiftassign");
153 dump_string (di
, "rshift");
156 dump_string (di
, "eq");
159 dump_string (di
, "ne");
162 dump_string (di
, "lt");
165 dump_string (di
, "gt");
168 dump_string (di
, "le");
171 dump_string (di
, "ge");
173 case TRUTH_ANDIF_EXPR
:
174 dump_string (di
, "land");
176 case TRUTH_ORIF_EXPR
:
177 dump_string (di
, "lor");
180 dump_string (di
, "compound");
183 dump_string (di
, "memref");
186 dump_string (di
, "ref");
189 dump_string (di
, "subs");
191 case POSTINCREMENT_EXPR
:
192 dump_string (di
, "postinc");
194 case POSTDECREMENT_EXPR
:
195 dump_string (di
, "postdec");
198 dump_string (di
, "call");
201 if (DECL_ASSIGNMENT_OPERATOR_P (t
))
202 dump_string (di
, "assign");
210 cp_dump_tree (dump_info
, t
)
215 dump_info_p di
= (dump_info_p
) dump_info
;
217 /* Figure out what kind of node this is. */
218 code
= TREE_CODE (t
);
222 if (DECL_LANG_SPECIFIC (t
) && DECL_LANGUAGE (t
) != lang_cplusplus
)
223 dump_string (di
, language_to_string (DECL_LANGUAGE (t
), 0));
228 case IDENTIFIER_NODE
:
229 if (IDENTIFIER_OPNAME_P (t
))
231 dump_string (di
, "operator");
234 else if (IDENTIFIER_TYPENAME_P (t
))
236 dump_child ("tynm", TREE_TYPE (t
));
239 else if (t
== anonymous_namespace_name
)
241 dump_string (di
, "unnamed");
247 if (TYPE_PTRMEM_P (t
))
249 dump_string (di
, "ptrmem");
250 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t
));
251 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t
));
258 if (TYPE_PTRMEMFUNC_P (t
))
260 dump_string (di
, "ptrmem");
261 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t
));
262 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t
));
266 dump_child ("vfld", TYPE_VFIELD (t
));
267 if (CLASSTYPE_TEMPLATE_SPECIALIZATION(t
))
268 dump_string(di
, "spec");
270 if (!dump_flag (di
, TDF_SLIM
, t
))
274 for (i
= 0; i
< CLASSTYPE_N_BASECLASSES (t
); ++i
)
276 tree base_binfo
= BINFO_BASETYPE (TYPE_BINFO (t
), i
);
277 dump_child ("base", BINFO_TYPE (base_binfo
));
278 if (TREE_VIA_VIRTUAL (base_binfo
))
279 dump_string (di
, "virtual");
280 dump_access (di
, base_binfo
);
287 if (DECL_MUTABLE_P (t
))
288 dump_string(di
, "mutable");
292 if (TREE_CODE (CP_DECL_CONTEXT (t
)) == RECORD_TYPE
)
294 if (TREE_STATIC (t
) && !TREE_PUBLIC (t
))
295 dump_string (di
, "static");
299 if (!DECL_THUNK_P (t
))
301 if (DECL_OVERLOADED_OPERATOR_P (t
)) {
302 dump_string (di
, "operator");
305 if (DECL_FUNCTION_MEMBER_P (t
))
307 dump_string (di
, "member");
310 if (DECL_PURE_VIRTUAL_P (t
))
311 dump_string (di
, "pure");
312 if (DECL_VIRTUAL_P (t
))
313 dump_string (di
, "virtual");
314 if (DECL_CONSTRUCTOR_P (t
))
315 dump_string (di
, "constructor");
316 if (DECL_DESTRUCTOR_P (t
))
317 dump_string (di
, "destructor");
318 if (DECL_CONV_FN_P (t
))
319 dump_string (di
, "conversion");
320 if (DECL_GLOBAL_CTOR_P (t
) || DECL_GLOBAL_DTOR_P (t
))
322 if (DECL_GLOBAL_CTOR_P (t
))
323 dump_string (di
, "global init");
324 if (DECL_GLOBAL_DTOR_P (t
))
325 dump_string (di
, "global fini");
326 dump_int (di
, "prio", GLOBAL_INIT_PRIORITY (t
));
328 if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t
))
329 dump_string (di
, "pseudo tmpl");
333 dump_string (di
, "thunk");
334 dump_int (di
, "dlta", THUNK_DELTA (t
));
335 dump_child ("vcll", THUNK_VCALL_OFFSET (t
));
336 dump_child ("fn", DECL_INITIAL (t
));
341 if (DECL_NAMESPACE_ALIAS (t
))
342 dump_child ("alis", DECL_NAMESPACE_ALIAS (t
));
343 else if (!dump_flag (di
, TDF_SLIM
, t
))
344 dump_child ("dcls", cp_namespace_decls (t
));
348 dump_child ("rslt", DECL_TEMPLATE_RESULT (t
));
349 dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t
));
350 dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t
));
351 dump_child ("prms", DECL_TEMPLATE_PARMS (t
));
355 dump_child ("crnt", OVL_CURRENT (t
));
356 dump_child ("chan", OVL_CHAIN (t
));
362 dump_string (di
, "cleanup");
363 dump_child ("body", TRY_STMTS (t
));
364 dump_child ("hdlr", TRY_HANDLERS (t
));
365 dump_next_stmt (di
, t
);
370 dump_child ("body", EH_SPEC_STMTS (t
));
371 dump_child ("raises", EH_SPEC_RAISES (t
));
372 dump_next_stmt (di
, t
);
376 dump_child ("clas", PTRMEM_CST_CLASS (t
));
377 dump_child ("mbr", PTRMEM_CST_MEMBER (t
));
381 /* These nodes are unary, but do not have code class `1'. */
382 dump_child ("op 0", TREE_OPERAND (t
, 0));
386 dump_int (di
, "ctor", AGGR_INIT_VIA_CTOR_P (t
));
387 dump_child ("fn", TREE_OPERAND (t
, 0));
388 dump_child ("args", TREE_OPERAND (t
, 1));
389 dump_child ("decl", TREE_OPERAND (t
, 2));
394 dump_child ("parm", HANDLER_PARMS (t
));
395 dump_child ("body", HANDLER_BODY (t
));
396 dump_next_stmt (di
, t
);
399 case MUST_NOT_THROW_EXPR
:
401 dump_child ("body", TREE_OPERAND (t
, 0));
402 dump_next_stmt (di
, t
);
407 dump_child ("nmsp", USING_STMT_NAMESPACE (t
));
408 dump_next_stmt (di
, t
);
415 return c_dump_tree (di
, t
);