1 /* Tree-dumping functionality for intermediate representation.
2 Copyright (C) 1999-2020 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 3, 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 COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
25 #include "tree-dump.h"
27 /* Dump a representation of the accessibility information associated
31 dump_access (dump_info_p di
, tree t
)
33 if (TREE_PROTECTED(t
))
34 dump_string_field (di
, "accs", "prot");
35 else if (TREE_PRIVATE(t
))
36 dump_string_field (di
, "accs", "priv");
38 dump_string_field (di
, "accs", "pub");
41 /* Dump information common to statements from STMT. */
44 dump_stmt (dump_info_p di
, const_tree t
)
46 if (EXPR_HAS_LOCATION (t
))
47 dump_int (di
, "line", EXPR_LINENO (t
));
51 cp_dump_tree (void* dump_info
, tree t
)
54 dump_info_p di
= (dump_info_p
) dump_info
;
56 /* Figure out what kind of node this is. */
61 if (DECL_LANG_SPECIFIC (t
) && DECL_LANGUAGE (t
) != lang_cplusplus
)
62 dump_string_field (di
, "lang", language_to_string (DECL_LANGUAGE (t
)));
68 if (IDENTIFIER_ANY_OP_P (t
))
70 dump_string_field (di
, "note", "operator");
73 else if (IDENTIFIER_CONV_OP_P (t
))
75 dump_child ("tynm", TREE_TYPE (t
));
81 dump_string_field (di
, "note", "ptrmem");
82 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t
));
83 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t
));
87 if (TYPE_PTRMEMFUNC_P (t
))
89 dump_string_field (di
, "note", "ptrmem");
90 dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t
));
91 dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t
));
97 /* Is it a type used as a base? */
98 if (TYPE_CONTEXT (t
) && TREE_CODE (TYPE_CONTEXT (t
)) == TREE_CODE (t
)
99 && CLASSTYPE_AS_BASE (TYPE_CONTEXT (t
)) == t
)
101 dump_child ("bfld", TYPE_CONTEXT (t
));
105 if (! MAYBE_CLASS_TYPE_P (t
))
108 dump_child ("vfld", TYPE_VFIELD (t
));
109 if (CLASSTYPE_TEMPLATE_SPECIALIZATION(t
))
110 dump_string(di
, "spec");
112 if (!dump_flag (di
, TDF_SLIM
, t
) && TYPE_BINFO (t
))
118 for (binfo
= TYPE_BINFO (t
), i
= 0;
119 BINFO_BASE_ITERATE (binfo
, i
, base_binfo
); ++i
)
121 dump_child ("base", BINFO_TYPE (base_binfo
));
122 if (BINFO_VIRTUAL_P (base_binfo
))
123 dump_string_field (di
, "spec", "virt");
124 dump_access (di
, base_binfo
);
131 if (DECL_MUTABLE_P (t
))
132 dump_string_field (di
, "spec", "mutable");
136 if (TREE_CODE (CP_DECL_CONTEXT (t
)) == RECORD_TYPE
)
138 if (TREE_STATIC (t
) && !TREE_PUBLIC (t
))
139 dump_string_field (di
, "link", "static");
143 if (!DECL_THUNK_P (t
))
145 if (DECL_OVERLOADED_OPERATOR_P (t
))
146 dump_string_field (di
, "note", "operator");
147 if (DECL_FUNCTION_MEMBER_P (t
))
149 dump_string_field (di
, "note", "member");
152 if (DECL_PURE_VIRTUAL_P (t
))
153 dump_string_field (di
, "spec", "pure");
154 if (DECL_VIRTUAL_P (t
))
155 dump_string_field (di
, "spec", "virt");
156 if (DECL_CONSTRUCTOR_P (t
))
157 dump_string_field (di
, "note", "constructor");
158 if (DECL_DESTRUCTOR_P (t
))
159 dump_string_field (di
, "note", "destructor");
160 if (DECL_CONV_FN_P (t
))
161 dump_string_field (di
, "note", "conversion");
162 if (DECL_GLOBAL_CTOR_P (t
))
163 dump_string_field (di
, "note", "global init");
164 if (DECL_GLOBAL_DTOR_P (t
))
165 dump_string_field (di
, "note", "global fini");
166 if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t
))
167 dump_string_field (di
, "note", "pseudo tmpl");
171 tree virt
= THUNK_VIRTUAL_OFFSET (t
);
173 dump_string_field (di
, "note", "thunk");
174 if (DECL_THIS_THUNK_P (t
))
175 dump_string_field (di
, "note", "this adjusting");
178 dump_string_field (di
, "note", "result adjusting");
180 virt
= BINFO_VPTR_FIELD (virt
);
182 dump_int (di
, "fixd", THUNK_FIXED_OFFSET (t
));
184 dump_int (di
, "virt", tree_to_shwi (virt
));
185 dump_child ("fn", DECL_INITIAL (t
));
190 if (DECL_NAMESPACE_ALIAS (t
))
191 dump_child ("alis", DECL_NAMESPACE_ALIAS (t
));
192 else if (!dump_flag (di
, TDF_SLIM
, t
))
193 dump_child ("dcls", cp_namespace_decls (t
));
197 dump_child ("rslt", DECL_TEMPLATE_RESULT (t
));
198 dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t
));
199 dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t
));
200 dump_child ("prms", DECL_TEMPLATE_PARMS (t
));
204 dump_child ("name", OVL_NAME (t
));
205 if (!dump_flag (di
, TDF_SLIM
, t
))
206 for (lkp_iterator
iter (t
); iter
; ++iter
)
207 dump_child ("chld", *iter
);
213 dump_string_field (di
, "note", "cleanup");
214 dump_child ("body", TRY_STMTS (t
));
215 dump_child ("hdlr", TRY_HANDLERS (t
));
220 dump_child ("body", EH_SPEC_STMTS (t
));
221 dump_child ("raises", EH_SPEC_RAISES (t
));
225 dump_child ("clas", PTRMEM_CST_CLASS (t
));
226 dump_child ("mbr", PTRMEM_CST_MEMBER (t
));
230 /* These nodes are unary, but do not have code class `1'. */
231 dump_child ("op 0", TREE_OPERAND (t
, 0));
238 aggr_init_expr_arg_iterator iter
;
239 dump_int (di
, "ctor", AGGR_INIT_VIA_CTOR_P (t
));
240 dump_child ("fn", AGGR_INIT_EXPR_FN (t
));
241 FOR_EACH_AGGR_INIT_EXPR_ARG (arg
, iter
, t
)
244 sprintf (buffer
, "%u", i
);
245 dump_child (buffer
, arg
);
248 dump_child ("decl", AGGR_INIT_EXPR_SLOT (t
));
254 dump_child ("parm", HANDLER_PARMS (t
));
255 dump_child ("body", HANDLER_BODY (t
));
258 case MUST_NOT_THROW_EXPR
:
260 dump_child ("body", TREE_OPERAND (t
, 0));
261 dump_child ("cond", MUST_NOT_THROW_COND (t
));
266 dump_child ("nmsp", USING_STMT_NAMESPACE (t
));
271 dump_child ("decl", CLEANUP_DECL (t
));
272 dump_child ("expr", CLEANUP_EXPR (t
));
273 dump_child ("body", CLEANUP_BODY (t
));
278 dump_child ("cond", IF_COND (t
));
279 dump_child ("then", THEN_CLAUSE (t
));
280 dump_child ("else", ELSE_CLAUSE (t
));
285 dump_child ("init", RANGE_FOR_INIT_STMT (t
));
286 dump_child ("decl", RANGE_FOR_DECL (t
));
287 dump_child ("expr", RANGE_FOR_EXPR (t
));
288 dump_child ("body", RANGE_FOR_BODY (t
));
292 dump_child ("stmt", STMT_EXPR_STMT (t
));
297 dump_child ("expr", EXPR_STMT_EXPR (t
));
302 dump_child ("depobj", OMP_DEPOBJ_DEPOBJ (t
));
303 dump_child ("clauses", OMP_DEPOBJ_CLAUSES (t
));
310 return c_dump_tree (di
, t
);