Age | Commit message (Collapse) | Author | Files | Lines |
|
Move more diagnostic-specific code from gcc/ to gcc/diagnostics/
No functional change intended.
contrib/ChangeLog:
* filter-clang-warnings.py: Update for move of
diagnostic-path-output.cc to diagnostics/paths-output.cc.
gcc/ChangeLog:
* Makefile.in (OBJS): Replace lazy-diagnostic-path.o with
diagnostics/lazy-paths.o.
(OBJS-libcommon): Replace diagnostic-path.o with
diagnostics/paths.o, diagnostic-path-output.o with
diagnostics/paths-output.o, and selftest-diagnostic-path.o with
diagnostics/selftest-paths.o.
(EXTRA_BACKEND_OBJS): Replace lazy-diagnostic-path.o with
diagnostics/lazy-paths.o.
* diagnostic-format-html.cc: Update #include for
"diagnostic-path.h" moving to "diagnostics/paths.h",
diagnostic_thread_id_t to diagnostics::paths::thread_id_t,
diagnostic_event_id_t to diagnostics::paths::event_id_t,
diagnostic_path to diagnostics::paths::path, and
diagnostic_thread to diagnostics::paths::thread, and
diagnostic_event to diagnostics::paths::event.
* diagnostic-format-html.h: Likewise.
* diagnostic-format-sarif.cc: Likewise. Update PROPERTY_PREFIX
for threadFlowLocations from "gcc/diagnostic_event/" to
"gcc/diagnostics/paths/event/".
* diagnostic-format-text.cc: Likewise.
* diagnostic-format-text.h: Likewise.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostic-event-id.h: Move to...
* diagnostics/event-id.h: ...here, updating header guard.
(diagnostics:paths:event_id_t): New typedef.
(diagnostic_thread_id_t): Replace with...
(diagnostics:paths:thread_id_t): New typedef.
* lazy-diagnostic-path.cc: Move to...
* diagnostics/lazy-paths.cc: ...here. Update for above changes,
lazy_diagnostic_path becomes diagnostics::paths::lazy_path.
(lazy_diagnostic_path_cc_tests): Rename to...
(diagnostics_lazy_paths_cc_tests): ...this.
* lazy-diagnostic-path.h: Move to...
* diagnostics/lazy-paths.h: ...here, updating header guard.
Update for above changes.
* diagnostic-path-output.cc: Move to...
* diagnostics/paths-output.cc: ...here. Update for above changes.
(diagnostic_path_output_cc_tests): Rename to...
(diagnostics_paths_output_cc_tests): ...this.
* diagnostic-path.cc: Move to...
* diagnostics/paths.cc: ...here. Update for above changes.
* diagnostic-path.h: Move to...
* diagnostics/paths.h: ...here, updating header guard.
Update #include for moving "diagnostic-event-id.h" to
"diagnostics/event-id.h".
(class diagnostic_event): Convert to...
(class diagnostics::paths::event): ...this.
(class diagnostic_thread): Convert to...
(class diagnostics::paths::thread): ...this.
(class diagnostic_path): Convert to...
(class diagnostics::paths::path): ...this.
* diagnostic-show-locus.cc: Update for above changes.
* doc/analyzer.texi: Likewise.
* selftest-diagnostic-path.cc: Move to...
* diagnostics/selftest-paths.cc: ...here. Update for
above changes, and for "selftest-diagnostic-path.h" moving to
"diagnostics/selftest-paths.h".
* selftest-diagnostic-path.h: Move to...
* diagnostics/selftest-paths.h: ...here, updating header guard.
Update for above changes.
* libgdiagnostics.cc: Update for above changes.
* libsarifreplay.cc: Update property prefix for
threadFlowLocations from "gcc/diagnostic_event/" to
"gcc/diagnostics/paths/event/".
* pretty-print-format-impl.h: Update for above changes.
* pretty-print.cc: Likewise.
* selftest-run-tests.cc (selftest::run_tests): Update for
renaming of lazy_diagnostic_path_cc_tests to
diagnostics_lazy_paths_cc_tests, and of
diagnostic_path_output_cc_tests to
diagnostics_paths_output_cc_tests.
* selftest.h (lazy_diagnostic_path_cc_tests): Replace decl with...
(diagnostics_lazy_paths_cc_tests): ...this.
(diagnostic_path_output_cc_tests): Replace decl with...
(diagnostics_paths_output_cc_tests): ...this.
* simple-diagnostic-path.cc: Clarify that this relates to "tree"
and thus shouldn't be in "diagnostics". Update for above changes.
* simple-diagnostic-path.h: Likewise.
gcc/analyzer/ChangeLog:
* access-diagram.cc: Update for changes to diagnostic paths:
"diagnostic-path.h" moving to "diagnostics/paths.h",
"diagnostic-event-id.h" moving to "diagnostics/event-id.h",
diagnostic_event_id_t to diagnostics::paths::event_id_t,
diagnostic_path to diagnostics::paths::path, and
diagnostic_event to diagnostics::paths::event.
* access-diagram.h: Likewise.
* analyzer.cc: Likewise.
* bounds-checking.cc: Likewise.
* call-info.cc: Likewise.
* checker-event.cc: Likewise.
* checker-event.h: Likewise.
* checker-path.cc: Likewise.
* checker-path.h: Likewise.
* common.h: Likewise.
* diagnostic-manager.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* pending-diagnostic.h: Likewise.
* program-point.cc: Likewise.
* program-state.cc: Likewise.
* region-model.cc: Likewise.
* sm-fd.cc: Likewise.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-pattern-test.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* varargs.cc: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.cc: Update #include for
"diagnostic-path.h" moving to "diagnostics/paths.h",
diagnostic_thread_id_t to diagnostics::paths::thread_id_t,
diagnostic_event_id_t to diagnostics::paths::event_id_t,
diagnostic_path to diagnostics::paths::path, and
diagnostic_thread to diagnostics::paths::thread, and
diagnostic_event to diagnostics::paths::event.
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise.
* lib/sarif.py (get_state_graph): Update property prefix for
threadFlowLocations from "gcc/diagnostic_event/" to
"gcc/diagnostics/paths/event/".
* gcc.dg/sarif-output/include-chain-2.h: Update comment.
libcpp/ChangeLog:
* include/rich-location.h: Replace diagnostic_path with
diagnostics::paths::path.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
This patch moves gcc/logical-locations.h into gcc/diagnostics
and moves the classes into "namespace diagnostics", to better
indicate that this is part of the shared diagnostics code.
The type "logical_location" becomes diagnostics::logical_locations::key,
the class logical_location_manager becomes
class diagnostics::logical_locations::manager, and the enum
enum logical_location_kind becomes
enum diagnostics::logical_locations::kind.
Note that tree-logical-locations.{h,cc} are *not* part
of "namespace diagnostics", as they use tree.
renamed: gcc/logical-location.h -> gcc/diagnostics/logical-locations.h
renamed: gcc/selftest-logical-location.cc -> gcc/diagnostics/selftest-logical-locations.cc
renamed: gcc/selftest-logical-location.h -> gcc/diagnostics/selftest-logical-locations.h
No functional change intended.
gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace
selftest-logical-location.o with
diagnostics/selftest-logical-locations.o.
* diagnostic-client-data-hooks.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, and of logical_location
to diagnostics::logical_locations::key.
* diagnostic-format-html.cc: Add "using namespace diagnostics;",
and drop now-redundant "diagnostics::" prefixes.
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* diagnostic-format-sarif.cc: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h". Add
"using namespace diagnostics;", and drop now-redundant
"diagnostics::" prefixes.
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* diagnostic-format-sarif.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location to
diagnostics::logical_locations::key.
* diagnostic-path-output.cc: Add "using namespace diagnostics;".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, and
of logical_location to diagnostics::logical_locations::key,
* diagnostic-path.cc: Add "using namespace diagnostics;".
Update for conversion of logical_location to
diagnostics::logical_locations::key.
* diagnostic-path.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, and of logical_location
to diagnostics::logical_locations::key,
* diagnostic.cc: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* diagnostic.h: Reorganize forward decls.
(class logical_location_manager): Replace this forward decl
with...
(class diagnostics::logical_locations::manager): ...this.
(diagnostic_context::get_logical_location_manager): Update
return type.
* diagnostics/digraphs.h: : Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location to
diagnostics::logical_locations::key.
* logical-location.h: Move to...
* diagnostics/logical-locations.h: ...here.
(enum class logical_location_kind): Convert to...
(enum class diagnostics::logical_locations::kind): ... this.
(class logical_location_manager::key): Convert to...
(class diagnostics::logical_locations::key): ... this.
(class logical_location_manager): Convert to...
(class diagnostics::logical_locations::manager): ... this.
(logical_location): Drop this typedef in favor of
diagnostics::logical_locations::key.
* selftest-logical-location.cc: Move to...
* diagnostics/selftest-logical-locations.cc: ...here.
Update #include for move of "selftest-logical-location.h" to
"diagnostics/selftest-logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
(selftest_logical_location_cc_tests): Rename to...
(diagnostics_selftest_logical_locations_cc_tests): ...this.
* selftest-logical-location.h: Move to...
* diagnostics/selftest-logical-locations.h: ...here, updating
include guard.
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* diagnostics/state-graphs-to-dot.cc: Add
"using namespace diagnostics;" and drop now-redundant
"diagnostics::" prefixes.
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager.
* diagnostics/state-graphs.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager,
of logical_location to diagnostics::logical_locations::key.
* libgdiagnostics.cc: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, and of logical_location
to diagnostics::logical_locations::key.
* selftest-diagnostic-path.cc: Update for conversion of
logical_location to diagnostics::logical_locations::key.
* selftest-diagnostic-path.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location to
diagnostics::logical_locations::key.
* selftest-run-tests.cc (selftest::run_tests): Update for
renaming of selftest_logical_location_cc_tests to
diagnostics_selftest_logical_locations_cc_tests.
* selftest.h: Likewise.
* simple-diagnostic-path.h: Update for conversion of
logical_location to diagnostics::logical_locations::key.
* tree-diagnostic-client-data-hooks.cc: Update for conversion of
logical_location_manager to
diagnostics::logical_locations::manager, and of logical_location
to diagnostics::logical_locations::key.
* tree-logical-location.cc: Update for conversions.
Update for conversion of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* tree-logical-location.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location
to diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
gcc/analyzer/ChangeLog:
* checker-event.h (checker_event::get_logical_location): Update
for conversion of logical_location to
diagnostics::logical_locations::key.
(checker_event::m_logical_loc): Likewise.
* diagnostic-manager.cc
(diagnostic_manager::get_logical_location_manager): Likewise.
* diagnostic-manager.h
(diagnostic_manager::get_logical_location_manager): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Modernization; no functional change intended.
gcc/ChangeLog:
* diagnostic-color.cc: Use nullptr rather than NULL.
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-text.cc: Likewise.
* diagnostic-macro-unwinding.cc: Likewise.
* diagnostic-path-output.cc: Likewise.
* diagnostic-path.cc: Likewise.
* diagnostic-show-locus.cc: Likewise.
* diagnostic-spec.cc: Likewise.
* diagnostic.cc: Likewise.
* lazy-diagnostic-path.cc: Likewise.
* simple-diagnostic-path.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Modernization; no functional change intended.
gcc/analyzer/ChangeLog:
* checker-event.cc (function_entry_event::get_meaning): Convert
diagnostic_event::meaning enums to enum class.
(cfg_edge_event::get_meaning): Likewise.
(call_event::get_meaning): Likewise.
(return_event::get_meaning): Likewise.
(start_consolidated_cfg_edges_event::get_meaning): Likewise.
(inlined_call_event::get_meaning): Likewise.
(warning_event::get_meaning): Likewise.
* sm-fd.cc (fd_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-file.cc (file_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-sensitive.cc
(exposure_through_output_file::get_meaning_for_state_change):
Likewise.
* sm-taint.cc (taint_diagnostic::get_meaning_for_state_change):
Likewise.
* varargs.cc
(va_list_sm_diagnostic::get_meaning_for_state_change): Likewise.
gcc/ChangeLog:
* diagnostic-format-sarif.cc
(sarif_builder::maybe_make_kinds_array): Convert
diagnostic_event::meaning enums to enum class.
* diagnostic-path-output.cc (path_label::get_text): Likewise.
* diagnostic-path.cc
(diagnostic_event::meaning::maybe_get_verb_str): Likewise.
(diagnostic_event::meaning::maybe_get_noun_str): Likewise.
(diagnostic_event::meaning::maybe_get_property_str): Likewise.
* diagnostic-path.h (diagnostic_event::verb): Likewise.
(diagnostic_event::noun): Likewise.
(diagnostic_event::property): Likewise.
(diagnostic_event::meaning): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.cc
(gil_diagnostic::get_meaning_for_state_change): Convert
diagnostic_event::meaning enums to enum class.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
When compiling diagnostic-path-output.cc with clang, it warns that
path_label::get_effects should be marked as override. That looks like
a good idea and from a brief look I also believe it should be marked
as final (the other override in the class is marked as both), so this
patch does that.
Likewise for html_output_format::after_diagnostic in
diagnostic-format-html.cc which also already has quite a few member
functions marked as final override.
gcc/ChangeLog:
2025-06-24 Martin Jambor <mjambor@suse.cz>
* diagnostic-path-output.cc (path_label::get_effects): Mark as
final override.
* diagnostic-format-html.cc
(html_output_format::after_diagnostic): Likewise.
|
|
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 <dmalcolm@redhat.com>
|
|
I've been seeing issues in the experimental-html sink where the nesting
of tags goes wrong.
The two issues I've seen are:
* the pp_token_list from the diagnostic message that reaches the
html_token_printer doesn't always have matching pairs of begin/end
tokens (PR other/120610)
* a bug in diagnostic-show-locus where there was a stray xp.pop_tag,
in print_trailing_fixits.
This patch:
* changes the xml::printer::pop_tag API so that it now takes the
expected name of the element being popped (rather than expressing this
in comments), and that, by default, the xml::printer asserts that this
matches.
* gives the html_token_printer its own xml::printer instance to restrict
the affected area of the DOM tree; this xml::printer doesn't enforce
nesting (PR other/120610)
* adds RAII sentinel classes that automatically check for pushes/pops
being balanced within a scope, using them in various places
* fixes the bug in print_trailing_fixits for html output
gcc/ChangeLog:
PR other/120610
* diagnostic-format-html.cc (html_builder::html_builder): Update
for new param of xml::printer::pop_tag.
(html_path_label_writer::end_label): Likewise.
(html_builder::make_element_for_diagnostic::html_token_printer):
Give the instance its own xml::printer. Update for new param of
xml::printer::pop_tag.
(html_builder::make_element_for_diagnostic): Give the instance its
own xml::printer.
(html_builder::make_metadata_element): Update for new param of
xml::printer::pop_tag.
(html_builder::flush_to_file): Likewise.
* diagnostic-path-output.cc (begin_html_stack_frame): Likewise.
(begin_html_stack_frame): Likewise.
(end_html_stack_frame): Likewise.
(print_path_summary_as_html): Likewise.
* diagnostic-show-locus.cc
(struct to_text::auto_check_tag_nesting): New.
(struct to_html:: auto_check_tag_nesting): New.
(to_text::pop_html_tag): Change param to const char *.
(to_html::pop_html_tag): Likewise; rename param to
"expected_name".
(default_diagnostic_start_span_fn<to_html>): Update for new param
of xml::printer::pop_tag.
(layout_printer<to_html>::end_label): Likewise.
(layout_printer<Sink>::print_trailing_fixits): Add RAII sentinel
to check tag nesting for the HTML case. Delete stray popping
of "td" in the presence of fix-it hints.
(layout_printer<Sink>::print_line): Add RAII sentinel
to check tag nesting for the HTML case.
(diagnostic_source_print_policy::print_as_html): Likewise.
(layout_printer<Sink>::print): Likewise.
* xml-printer.h (xml::printer::printer): Add optional
"check_popped_tags" param.
(xml::printer::pop_tag): Add "expected_name" param.
(xml::printer::get_num_open_tags): New accessor.
(xml::printer::dump): New decl.
(xml::printer::m_check_popped_tags): New field.
(class xml::auto_check_tag_nesting): New.
(class xml::auto_print_element): Update for new param of pop_tag.
* xml.cc: Move pragma pop so that the pragma also covers
xml::printer's member functions, "dump" in particular.
(xml::printer::printer): Add param "check_popped_tags".
(xml::printer::pop_tag): Add param "expected_name" and use it to assert
that the popped tag is as expected. Assert that we have a tag to
pop.
(xml::printer::dump): New.
(selftest::test_printer): Update for new param of pop_tag.
(selftest::test_attribute_ordering): Likewise.
gcc/testsuite/ChangeLog:
PR other/120610
* gcc.dg/format/diagnostic-ranges-html.py: Remove out-of-date
comment.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
This patch reworks the HTML output from the the option
-fdiagnostics-add-output=experimental-html
so that for source quoting and path printing, rather than simply adding
the textual output inside <pre> elements, it breaks up the output
into HTML tags reflecting the structure of the output, using CSS, SVG
and a little javascript to help the user navigate the diagnostics and
the events within any paths.
This uses ideas from the patch I posted in:
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558603.html
but reworks the above patch so that:
* rather than printing source to a pretty_printer, the HTML is created
by building a DOM tree in memory, using a new xml::printer class. This
should be less error-prone than the pretty_printer approach, since it
ought to solve escaping issues. Instead of a text vs html boolean,
the code is generalized via templates with to_text vs to_html sinks.
This templatization applies both to path-printing and
diagnostic-show-locus.cc.
* the HTML output can have multiple diagnostics and multiple paths rather
than just a single path. The javascript keyboard controls now cycle
through all diagnostics and all events within them
An example of the output can be seen at:
https://dmalcolm.fedorapeople.org/gcc/2025-05-27/malloc-1.c.html
where the keys "j" and "k" cycle through diagnostics and events
within them.
gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc: Define INCLUDE_STRING.
Include "xml.h", "xml-printer.h", and "json.h".
(html_generation_options::html_generation_options): New.
(namespace xml): Move decls to xml.h and convert from using
label_text to std::string.
(xml::text::write_as_xml): Reimplement indentation so it is done
by this node, rather than the parent.
(xml::node_with_children::add_text): Convert from label_text to
std::string. Consolidate runs of text into a single node.
(xml::document::write_as_xml): Reimplement indentation.
(xml::element::write_as_xml): Reimplement indentation so it is
done by this node, rather than the parent. Convert from
label_text to std::string. Update attribute-printing to new
representation to preserve insertion order.
(xml::element::set_attr): Convert from label_text to std::string.
Record insertion order.
(xml::raw::write_as_xml): New.
(xml::printer::printer): New.
(xml::printer::push_tag): New.
(xml::printer::push_tag_with_class): New.
(xml::printer::pop_tag): New.
(xml::printer::set_attr): New.
(xml::printer::add_text): New.
(xml::printer::add_raw): New.
(xml::printer::push_element): New.
(xml::printer::append): New.
(xml::printer::get_insertion_point): New.
(html_builder::add_focus_id): New.
(html_builder::m_html_gen_opts): New field.
(html_builder::m_head_element): New field.
(html_builder::m_next_diag_id): New field.
(html_builder::m_ui_focus_ids): New field.
(make_div): Convert from label_text to std::string.
(make_span): Likewise.
(HTML_STYLE): New.
(HTML_SCRIPT): New.
(html_builder::html_builder): Fix indentation. Add
"html_gen_opts" param. Initialize new fields. Reimplement
using xml::printer. Optionally add style and script tags.
(class html_path_label_writer): New.
(html_builder::make_element_for_diagnostic): Convert from
label_text to std::string. Set "id" on "gcc-diagnostic" and
"gcc-message" <div> elements; add the latter to the focus ids.
Use diagnostic_context::maybe_show_locus_as_html rather than
html_builder::make_element_for_source. Use print_path_as_html
rather than html_builder::make_element_for_path.
(html_builder::make_element_for_source): Drop.
(html_builder::make_element_for_path): Drop.
(html_builder::make_element_for_patch): Convert from label_text to
std::string.
(html_builder::make_metadata_element): Likewise. Use
xml::printer.
(html_builder::make_element_for_metadata): Convert from label_text
to std::string.
(html_builder::emit_diagram): Expand comment.
(html_builder::flush_to_file): Write out initializer for
"focus_ids" into javascript.
(html_output_format::html_output_format): Add param
"html_gen_opts" and use it to initialize m_builder.
(html_file_output_format::html_file_output_format): Likewise, to
initialize base class.
(make_html_sink): Likewise, to pass to ctor.
(selftest::test_html_diagnostic_context::test_html_diagnostic_context):
Set up html_generation_options.
(selftest::html_buffered_output_format::html_buffered_output_format):
Add html_gen_opts param.
(selftest::test_simple_log): Add id attributes to expected text
for "gcc-diagnostic" and "gcc-message" elements. Update
whitespace for indentation fixes.
(selftest::test_metadata): Update whitespace for indentation
fixes.
(selftest::test_printer): New selftest.
(selftest::test_attribute_ordering): New selftest.
(selftest::diagnostic_format_html_cc_tests): Call the new
selftests.
* diagnostic-format-html.h (struct html_generation_options): New.
(make_html_sink): Add "html_gen_opts" param.
(print_path_as_html): New decl.
* diagnostic-path-output.cc: Define INCLUDE_MAP. Add includes of
"diagnostic-format-html.h", "xml.h", and "xml-printer.h".
(path_print_policy::path_print_policy): Add ctor.
(path_print_policy::get_diagram_theme): Fix whitespace.
(struct stack_frame): New.
(begin_html_stack_frame): New function.
(end_html_stack_frame): New function.
(emit_svg_arrow): New function.
(event_range::print): Rename to...
(event_range::print_as_text): ...this. Update call to
diagnostic_start_span.
(event_range::print_as_html): New, based on the above, but ported
from pretty_printer to xml::printer.
(thread_event_printer::print_swimlane_for_event_range): Rename
to...
(thread_event_printer::print_swimlane_for_event_range_as_text):
...this. Update for renaming of event_range::print to
event_range::print_as_text.
(thread_event_printer::print_swimlane_for_event_range_as_html):
New.
(print_path_summary_as_text): Update for "_as_text" renaming.
(print_path_summary_as_html): New.
(print_path_as_html): New.
* diagnostic-show-locus.cc: Add defines of INCLUDE_MAP and
INCLUDE_STRING. Add includes of "xml.h" and "xml-printer.h".
(struct char_display_policy): Replace "m_print_cb" with
"m_print_text_cb" and "m_print_html_cb".
(struct to_text): New.
(struct to_html): New.
(get_printer): New.
(default_diagnostic_start_span_fn<to_text>): New.
(default_diagnostic_start_span_fn<to_html>): New.
(class layout): Update "friend class layout_printer;" for
template.
(enum class margin_kind): New.
(class layout_printer): Convert into a template.
(layout_printer::m_pp): Replace field with...
(layout_printer::m_sink): ...this.
(layout_printer::m_colorizer): Drop field in favor of a pointer
in the "to_text" sink.
(default_print_decoded_ch): Convert into a template.
(escape_as_bytes_print): Likewise.
(escape_as_unicode_print): Likewise.
(make_char_policy): Update to use both text and html callbacks.
(layout_printer::print_gap_in_line_numbering): Replace with...
(layout_printer<to_text>::print_gap_in_line_numbering): ...this
(layout_printer<to_html>::print_gap_in_line_numbering): ...and
this.
(layout_printer::print_source_line): Convert to template, using
m_sink.
(layout_printer::print_leftmost_column): Likewise.
(layout_printer::start_annotation_line): Likewise.
(layout_printer<to_text>::end_line): New.
(layout_printer<to_html>::end_line): New.
(layout_printer::print_annotation_line): Convert to template,
using m_sink.
(class line_label): Add field m_original_range_idx.
(layout_printer<to_text>::begin_label): New.
(layout_printer<to_html>::begin_label): New.
(layout_printer<to_text>::end_label): New.
(layout_printer<to_html>::end_label): New.
(layout_printer::print_any_labels): Convert to template, using
m_sink.
(layout_printer::print_leading_fixits): Likewise.
(layout_printer::print_trailing_fixits): Likewise.
(layout_printer::print_newline): Drop.
(layout_printer::move_to_column): Convert to template, using
m_sink.
(layout_printer::show_ruler): Likewise.
(layout_printer::print_line): Likewise.
(layout_printer::print_any_right_to_left_edge_lines): Likewise.
(layout_printer::layout_printer): Likewise.
(diagnostic_context::maybe_show_locus_as_html): New.
(diagnostic_source_print_policy::diagnostic_source_print_policy):
Update for split of start_span_cb into text vs html variants.
(diagnostic_source_print_policy::print): Update for use of
templates; use to_text.
(diagnostic_source_print_policy::print_as_html): New.
(layout_printer::print): Convert to template, using m_sink.
(selftest::make_element_for_locus): New.
(selftest::make_raw_html_for_locus): New.
(selftest::test_layout_x_offset_display_utf8): Update for use of
templates.
(selftest::test_layout_x_offset_display_tab): Likewise.
(selftest::test_one_liner_caret_and_range): Add test coverage of
HTML output.
(selftest::test_one_liner_labels): Likewise.
* diagnostic.cc (diagnostic_context::initialize): Update for split
of start_span_cb into text vs html variants.
(default_diagnostic_start_span_fn): Move to
diagnostic-show-locus.cc, converting to template.
* diagnostic.h (class xml::printer): New forward decl.
(diagnostic_start_span_fn): Replace typedef with "using",
converting to a template.
(struct to_text): New forward decl.
(struct to_html): New forward decl.
(get_printer): New decl.
(diagnostic_location_print_policy::print_text_span_start): New
decl.
(diagnostic_location_print_policy::print_html_span_start): New
decl.
(class html_label_writer): New.
(diagnostic_source_print_policy::print_as_html): New decl.
(diagnostic_source_print_policy::get_start_span_fn): Replace
with...
(diagnostic_source_print_policy::get_text_start_span_fn): ...this
(diagnostic_source_print_policy::get_html_start_span_fn): ...and
this
(diagnostic_source_print_policy::m_start_span_cb): Replace with...
(diagnostic_source_print_policy::m_text_start_span_cb): ...this
(diagnostic_source_print_policy::m_html_start_span_cb): ...and
this.
(diagnostic_context::maybe_show_locus_as_html): New decl.
(diagnostic_context::m_text_callbacks::m_start_span): Replace
with...
(diagnostic_context::m_text_callbacks::m_text_start_span): ...this
(diagnostic_context::m_text_callbacks::m_html_start_span): ...and
this.
(diagnostic_start_span): Update for template change.
(diagnostic_show_locus_as_html): New inline function.
(default_diagnostic_start_span_fn): Convert to template.
* doc/invoke.texi (experimental-html): Add "css" and "javascript"
keys.
* opts-diagnostic.cc (html_scheme_handler::make_sink): Likewise.
* selftest-diagnostic.cc
(selftest::test_diagnostic_context::start_span_cb): Update for
template changes.
* selftest-diagnostic.h
(selftest::test_diagnostic_context::start_span_cb): Likewise.
* xml-printer.h: New file.
* xml.h: New file, based on material in diagnostic-format-html.cc,
but using std::string rather than label_text.
(xml::element::m_key_insertion_order): New field.
(struct xml::raw): New.
gcc/fortran/ChangeLog
PR other/116792
* error.cc (gfc_diagnostic_start_span): Update for diagnostic.h
changes.
gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/html-output/missing-semicolon.c: Add ":javascript=no" to
html output.
* gcc.dg/html-output/missing-semicolon.py: Move repeated
definitions into lib/htmltest.py.
* gcc.dg/plugin/diagnostic_group_plugin.cc: Update for template
changes.
* gcc.dg/plugin/diagnostic-test-metadata-html.c: Add
":javascript=no" to html output. Add
"-fdiagnostics-show-line-numbers".
* gcc.dg/plugin/diagnostic-test-metadata-html.py: Move repeated
definitions into lib/htmltest.py. Add checks of annotated source.
* gcc.dg/plugin/diagnostic-test-paths-2.c: Add ":javascript=no" to
html output.
* gcc.dg/plugin/diagnostic-test-paths-2.py: Move repeated
definitions into lib/htmltest.py. Add checks of execution path.
* gcc.dg/plugin/diagnostic-test-paths-4.c: Add
-fdiagnostics-add-output=experimental-html:javascript=no. Add
invocation ot diagnostic-test-paths-4.py.
* gcc.dg/plugin/diagnostic-test-paths-4.py: New test script.
* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c: Add
-fdiagnostics-add-output=experimental-html:javascript=no. Add
invocation of diagnostic-test-show-locus.py.
* gcc.dg/plugin/diagnostic-test-show-locus.py: New test script.
* lib/htmltest.py: New test support script.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
No functional change intended.
gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add diagnostic-path-output.o.
* diagnostic-path-output.cc: New file, taken from material in
diagnostic-path.cc.
* diagnostic-path.cc: Drop includes of
"diagnostic-macro-unwinding.h", "intl.h", "gcc-rich-location.h",
"diagnostic-color.h", "diagnostic-event-id.h",
"diagnostic-label-effects.h", "pretty-print-markup.h",
"selftest.h", "selftest-diagnostic.h",
"selftest-diagnostic-path.h", "text-art/theme.h", and
"diagnostic-format-text.h".
(class path_print_policy): Move to diagnostic-path-output.cc.
(class path_label): Likewise.
(can_consolidate_events): Likewise.
(class per_thread_summary): Likewise.
(struct event_range): Likewise.
(struct path_summary): Likewise.
(per_thread_summary::interprocedural_p): Likewise.
(path_summary::path_summary): Likewise.
(write_indent): Likewise.
(base_indent): Likewise.
(per_frame_indent): Likewise.
(class thread_event_printer): Likewise.
(print_path_summary_as_text): Likewise.
(class element_event_desc): Likewise.
(diagnostic_text_output_format::print_path): Likewise.
(selftest::path_events_have_column_data_p): Likewise.
(selftest::test_empty_path): Likewise.
(selftest::test_intraprocedural_path): Likewise.
(selftest::test_interprocedural_path_1): Likewise.
(selftest::test_interprocedural_path_2): Likewise.
(selftest::test_recursion): Likewise.
(class selftest::control_flow_test): Likewise.
(selftest::test_control_flow_1): Likewise.
(selftest::test_control_flow_2): Likewise.
(selftest::test_control_flow_3): Likewise.
(selftest::assert_cfg_edge_path_streq): Likewise.
(ASSERT_CFG_EDGE_PATH_STREQ): Likewise.
(selftest::test_control_flow_4): Likewise.
(selftest::test_control_flow_5): Likewise.
(selftest::test_control_flow_6): Likewise.
(selftest::control_flow_tests): Likewise.
(selftest::diagnostic_path_cc_tests): Likewise, renaming
accordingly.
* selftest-run-tests.cc (selftest::run_tests): Update for
move of path-printing selftests.
* selftest.h (selftest::diagnostic_path_cc_tests): Replace decl
with...
(selftest::diagnostic_path_output_cc_tests): ...this.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|