Skip to content

Commit 896edb1

Browse files
committed
diagnostics: xml: add add_text_from_pp
Various places use xp.add_text (pp_formatted_text (&pp)) Add a helper function for this. No functional change intended. gcc/ChangeLog: * diagnostic-path-output.cc: Use xml::printer::add_text_from_pp. * diagnostic-show-locus.cc: Likewise. * xml-printer.h (xml::printer::add_text_from_pp): New decl. * xml.cc (xml::node_with_children::add_text_from_pp): New. (xml::printer::add_text_from_pp): New. * xml.h (xml::node_with_children::add_text_from_pp): New decl. Signed-off-by: David Malcolm <[email protected]>
1 parent 3dcce64 commit 896edb1

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

gcc/diagnostic-path-output.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ struct event_range
689689
iter_event.print_desc (pp);
690690
if (event_label_writer)
691691
event_label_writer->begin_label ();
692-
xp.add_text (pp_formatted_text (&pp));
692+
xp.add_text_from_pp (pp);
693693
if (event_label_writer)
694694
event_label_writer->end_label ();
695695
}
@@ -1243,7 +1243,7 @@ print_path_summary_as_html (const path_summary &ps,
12431243
else
12441244
pp_printf (&pp, "events %i-%i",
12451245
range->m_start_idx + 1, range->m_end_idx + 1);
1246-
xp.add_text (pp_formatted_text (&pp));
1246+
xp.add_text_from_pp (pp);
12471247
xp.pop_tag ("span");
12481248
}
12491249
if (show_depths)
@@ -1252,7 +1252,7 @@ print_path_summary_as_html (const path_summary &ps,
12521252
xp.push_tag_with_class ("span", "depth", true);
12531253
pretty_printer pp;
12541254
pp_printf (&pp, "(depth %i)", range->m_stack_depth);
1255-
xp.add_text (pp_formatted_text (&pp));
1255+
xp.add_text_from_pp (pp);
12561256
xp.pop_tag ("span");
12571257
}
12581258
xp.pop_tag ("div");

gcc/diagnostic-show-locus.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ struct to_html
614614
{
615615
pp_clear_output_area (&m_scratch_pp);
616616
pp_unicode_character (&m_scratch_pp, ch);
617-
m_xp.add_text (pp_formatted_text (&m_scratch_pp));
617+
m_xp.add_text_from_pp (m_scratch_pp);
618618
}
619619

620620
void add_utf8_byte (char b)

gcc/xml-printer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class printer
4444
void set_attr (const char *name, std::string value);
4545

4646
void add_text (std::string text);
47+
void add_text_from_pp (pretty_printer &pp);
4748

4849
void add_raw (std::string text);
4950

gcc/xml.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ node_with_children::add_text (std::string str)
121121
add_child (std::make_unique <text> (std::move (str)));
122122
}
123123

124+
void
125+
node_with_children::add_text_from_pp (pretty_printer &pp)
126+
{
127+
add_text (pp_formatted_text (&pp));
128+
}
124129

125130
/* struct document : public node_with_children. */
126131

@@ -251,6 +256,13 @@ printer::add_text (std::string text)
251256
parent->add_text (std::move (text));
252257
}
253258

259+
void
260+
printer::add_text_from_pp (pretty_printer &pp)
261+
{
262+
element *parent = m_open_tags.back ();
263+
parent->add_text_from_pp (pp);
264+
}
265+
254266
void
255267
printer::add_raw (std::string text)
256268
{

gcc/xml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct node_with_children : public node
6565
{
6666
void add_child (std::unique_ptr<node> node);
6767
void add_text (std::string str);
68+
void add_text_from_pp (pretty_printer &pp);
6869

6970
std::vector<std::unique_ptr<node>> m_children;
7071
};

0 commit comments

Comments
 (0)