File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -7322,6 +7322,29 @@ extern void cp_check_const_attributes (tree);
7322
7322
extern void maybe_propagate_warmth_attributes (tree, tree);
7323
7323
7324
7324
/* in error.cc */
7325
+ /* A class for pretty-printing to -flang-dump-XXX files. Used like
7326
+
7327
+ if (cxx_dump_pretty_printer pp {foo_dump_id})
7328
+ {
7329
+ pp_printf (&pp, ...);
7330
+ }
7331
+
7332
+ If the dump is enabled, the pretty printer will open the dump file and
7333
+ attach to it, and flush and close the file on destruction. */
7334
+
7335
+ class cxx_dump_pretty_printer : public pretty_printer
7336
+ {
7337
+ int phase;
7338
+ FILE *outf;
7339
+ dump_flags_t flags;
7340
+
7341
+ public:
7342
+ cxx_dump_pretty_printer (int phase);
7343
+ operator bool () { return outf != nullptr ; }
7344
+ bool has_flag (dump_flags_t f) { return (flags & f); }
7345
+ ~cxx_dump_pretty_printer ();
7346
+ };
7347
+
7325
7348
extern const char *type_as_string (tree, int );
7326
7349
extern const char *type_as_string_translate (tree, int );
7327
7350
extern const char *decl_as_string (tree, int );
Original file line number Diff line number Diff line change @@ -193,6 +193,33 @@ class cxx_format_postprocessor : public format_postprocessor
193
193
deferred_printed_type m_type_b;
194
194
};
195
195
196
+ /* Constructor and destructor for cxx_dump_pretty_printer, defined here to
197
+ avoid needing to move cxx_format_postprocessor into the header as well. */
198
+
199
+ cxx_dump_pretty_printer::
200
+ cxx_dump_pretty_printer (int phase)
201
+ : phase (phase)
202
+ {
203
+ outf = dump_begin (phase, &flags);
204
+ if (outf)
205
+ {
206
+ pp_format_decoder (this ) = cp_printer;
207
+ /* This gets deleted in ~pretty_printer. */
208
+ pp_format_postprocessor (this ) = new cxx_format_postprocessor ();
209
+ set_output_stream (outf);
210
+ }
211
+ }
212
+
213
+ cxx_dump_pretty_printer::
214
+ ~cxx_dump_pretty_printer ()
215
+ {
216
+ if (outf)
217
+ {
218
+ pp_flush (this );
219
+ dump_end (phase, outf);
220
+ }
221
+ }
222
+
196
223
/* Return the in-scope template that's currently being parsed, or
197
224
NULL_TREE otherwise. */
198
225
You can’t perform that action at this time.
0 commit comments