1 /* Prints out trees in human readable form.
2 Copyright (C) 1992-2015 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.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/>. */
24 #include "coretypes.h"
29 #include "double-int.h"
36 #include "print-tree.h"
40 cxx_print_decl (FILE *file
, tree node
, int indent
)
42 if (TREE_CODE (node
) == FIELD_DECL
)
44 if (DECL_MUTABLE_P (node
))
46 indent_to (file
, indent
+ 3);
47 fprintf (file
, " mutable ");
52 if (!CODE_CONTAINS_STRUCT (TREE_CODE (node
), TS_DECL_COMMON
)
53 || !DECL_LANG_SPECIFIC (node
))
55 if (TREE_CODE (node
) == FUNCTION_DECL
)
57 int flags
= TFF_DECL_SPECIFIERS
|TFF_RETURN_TYPE
58 |TFF_FUNCTION_DEFAULT_ARGUMENTS
|TFF_EXCEPTION_SPECIFICATION
;
59 indent_to (file
, indent
+ 3);
60 fprintf (file
, " full-name \"%s\"", decl_as_string (node
, flags
));
62 else if (TREE_CODE (node
) == TEMPLATE_DECL
)
64 indent_to (file
, indent
+ 3);
65 fprintf (file
, " full-name \"%s\"",
66 decl_as_string (node
, TFF_TEMPLATE_HEADER
));
69 indent_to (file
, indent
+ 3);
70 if (DECL_EXTERNAL (node
) && DECL_NOT_REALLY_EXTERN (node
))
71 fprintf (file
, " not-really-extern");
72 if (TREE_CODE (node
) == FUNCTION_DECL
73 && DECL_PENDING_INLINE_INFO (node
))
74 fprintf (file
, " pending-inline-info %p",
75 (void *) DECL_PENDING_INLINE_INFO (node
));
76 if (VAR_OR_FUNCTION_DECL_P (node
)
77 && DECL_TEMPLATE_INFO (node
))
78 fprintf (file
, " template-info %p",
79 (void *) DECL_TEMPLATE_INFO (node
));
83 cxx_print_type (FILE *file
, tree node
, int indent
)
85 switch (TREE_CODE (node
))
87 case TEMPLATE_TYPE_PARM
:
88 case TEMPLATE_TEMPLATE_PARM
:
89 case BOUND_TEMPLATE_TEMPLATE_PARM
:
90 indent_to (file
, indent
+ 3);
91 fprintf (file
, "index %d level %d orig_level %d",
92 TEMPLATE_TYPE_IDX (node
), TEMPLATE_TYPE_LEVEL (node
),
93 TEMPLATE_TYPE_ORIG_LEVEL (node
));
98 if (TYPE_RAISES_EXCEPTIONS (node
))
99 print_node (file
, "throws", TYPE_RAISES_EXCEPTIONS (node
), indent
+ 4);
107 print_node (file
, "expr", DECLTYPE_TYPE_EXPR (node
), indent
+ 4);
111 print_node (file
, "fullname", TYPENAME_TYPE_FULLNAME (node
),
115 case TYPE_PACK_EXPANSION
:
116 print_node (file
, "args", PACK_EXPANSION_EXTRA_ARGS (node
), indent
+ 4);
123 if (TYPE_PTRMEMFUNC_P (node
))
124 print_node (file
, "ptrmemfunc fn type", TYPE_PTRMEMFUNC_FN_TYPE (node
),
127 if (! CLASS_TYPE_P (node
))
130 indent_to (file
, indent
+ 4);
131 fprintf (file
, "full-name \"%s\"",
132 type_as_string (node
, TFF_CLASS_KEY_OR_ENUM
));
134 indent_to (file
, indent
+ 3);
136 if (TYPE_NEEDS_CONSTRUCTING (node
))
137 fputs ( " needs-constructor", file
);
138 if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (node
))
139 fputs (" needs-destructor", file
);
140 if (TYPE_HAS_DEFAULT_CONSTRUCTOR (node
))
141 fputs (" X()", file
);
142 if (TYPE_HAS_CONVERSION (node
))
143 fputs (" has-type-conversion", file
);
144 if (TYPE_HAS_COPY_CTOR (node
))
146 if (TYPE_HAS_CONST_COPY_CTOR (node
))
147 fputs (" X(constX&)", file
);
149 fputs (" X(X&)", file
);
151 if (TYPE_HAS_NEW_OPERATOR (node
))
152 fputs (" new", file
);
153 if (TYPE_HAS_ARRAY_NEW_OPERATOR (node
))
154 fputs (" new[]", file
);
155 if (TYPE_GETS_DELETE (node
) & 1)
156 fputs (" delete", file
);
157 if (TYPE_GETS_DELETE (node
) & 2)
158 fputs (" delete[]", file
);
159 if (TYPE_HAS_COPY_ASSIGN (node
))
160 fputs (" this=(X&)", file
);
161 if (CLASSTYPE_SORTED_FIELDS (node
))
162 fprintf (file
, " sorted-fields %p",
163 (void *) CLASSTYPE_SORTED_FIELDS (node
));
165 if (TREE_CODE (node
) == RECORD_TYPE
)
167 if (TYPE_BINFO (node
))
168 fprintf (file
, " n_parents=%d",
169 BINFO_N_BASE_BINFOS (TYPE_BINFO (node
)));
171 fprintf (file
, " no-binfo");
173 fprintf (file
, " use_template=%d", CLASSTYPE_USE_TEMPLATE (node
));
174 if (CLASSTYPE_INTERFACE_ONLY (node
))
175 fprintf (file
, " interface-only");
176 if (CLASSTYPE_INTERFACE_UNKNOWN (node
))
177 fprintf (file
, " interface-unknown");
183 cxx_print_binding (FILE *stream
, cxx_binding
*binding
, const char *prefix
)
185 fprintf (stream
, "%s <%p>",
186 prefix
, (void *) binding
);
190 cxx_print_identifier (FILE *file
, tree node
, int indent
)
195 indent_to (file
, indent
+ 4);
196 cxx_print_binding (file
, IDENTIFIER_NAMESPACE_BINDINGS (node
), "bindings");
200 indent_to (file
, indent
+ 4);
201 cxx_print_binding (file
, IDENTIFIER_BINDING (node
), "local bindings");
202 print_node (file
, "label", IDENTIFIER_LABEL_VALUE (node
), indent
+ 4);
203 print_node (file
, "template", IDENTIFIER_TEMPLATE (node
), indent
+ 4);
207 cxx_print_xnode (FILE *file
, tree node
, int indent
)
209 switch (TREE_CODE (node
))
212 print_node (file
, "functions", BASELINK_FUNCTIONS (node
), indent
+ 4);
213 print_node (file
, "binfo", BASELINK_BINFO (node
), indent
+ 4);
214 print_node (file
, "access_binfo", BASELINK_ACCESS_BINFO (node
),
218 print_node (file
, "function", OVL_FUNCTION (node
), indent
+4);
219 print_node (file
, "chain", TREE_CHAIN (node
), indent
+4);
221 case TEMPLATE_PARM_INDEX
:
222 indent_to (file
, indent
+ 3);
223 fprintf (file
, "index %d level %d orig_level %d",
224 TEMPLATE_PARM_IDX (node
), TEMPLATE_PARM_LEVEL (node
),
225 TEMPLATE_PARM_ORIG_LEVEL (node
));
228 print_node (file
, "template", TI_TEMPLATE (node
), indent
+4);
229 print_node (file
, "args", TI_ARGS (node
), indent
+4);
230 if (TI_PENDING_TEMPLATE_FLAG (node
))
232 indent_to (file
, indent
+ 3);
233 fprintf (file
, "pending_template");
236 case ARGUMENT_PACK_SELECT
:
237 print_node (file
, "pack", ARGUMENT_PACK_SELECT_FROM_PACK (node
),
239 indent_to (file
, indent
+ 3);
240 fprintf (file
, "index %d", ARGUMENT_PACK_SELECT_INDEX (node
));
242 case DEFERRED_NOEXCEPT
:
243 print_node (file
, "pattern", DEFERRED_NOEXCEPT_PATTERN (node
), indent
+4);
244 print_node (file
, "args", DEFERRED_NOEXCEPT_ARGS (node
), indent
+4);