Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
No functional change intended.
gcc/ada/ChangeLog:
* gcc-interface/misc.cc: Make
diagnostics::context::m_source_printing private.
gcc/analyzer/ChangeLog:
* program-point.cc: Make diagnostics::context::m_source_printing
private.
gcc/c-family/ChangeLog:
* c-common.cc: Make diagnostics::context::m_source_printing
private.
* c-format.cc: Likewise.
* c-opts.cc: Likewise.
gcc/ChangeLog:
* diagnostic.h (diagnostic_set_caret_max_width): Drop forward
decl.
(diagnostic_same_line): Make
diagnostics::context::m_source_printing private.
* diagnostics/context.cc (diagnostic_set_caret_max_width): Convert
to...
(diagnostics::context::set_caret_max_width): ...this.
* diagnostics/context.h
(diagnostics::context::get_source_printing_options): New
accessors.
(diagnostics::context::m_source_printing): Make private.
* diagnostics/html-sink.cc: Make
diagnostics::context::m_source_printing private.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/selftest-context.cc: Likewise.
* diagnostics/selftest-context.h
(diagnostics::selftest::test_context::colorize_source): New.
(diagnostics::selftest::test_context::show_labels): New.
(diagnostics::selftest::test_context::show_line_numbers): New.
(diagnostics::selftest::test_context::show_ruler): New.
(diagnostics::selftest::test_context::show_event_links): New.
(diagnostics::selftest::test_context::set_caret_char): New.
* diagnostics/source-printing.cc: Make
diagnostics::context::m_source_printing private.
* diagnostics/text-sink.h: Likewise.
* libgdiagnostics.cc: Likewise.
* opts.cc: Likewise.
* toplev.cc: Likewise.
gcc/fortran/ChangeLog:
* error.cc: Make diagnostics::context::m_source_printing private.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_show_trees.cc: Make
diagnostics::context::m_source_printing private.
* gcc.dg/plugin/diagnostic_plugin_test_inlining.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_string_literals.cc:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.cc:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
No functional change intended.
gcc/ChangeLog:
* Makefile.in: Replace diagnostic.def with diagnostics/kinds.def.
* config/aarch64/aarch64.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* config/i386/i386-options.cc: Likewise.
* config/s390/s390.cc: Likewise.
* diagnostic-core.h: Replace typedef diagnostic_t with
enum class diagnostics::kind in diagnostics/kinds.h and include
it.
* diagnostic-global-context.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostics/buffering.cc: Likewise.
* diagnostics/buffering.h: Likewise.
* diagnostics/context.h: Likewise.
* diagnostics/diagnostic-info.h: Likewise.
* diagnostics/html-sink.cc: Likewise.
* diagnostic.def: Move to...
* diagnostics/kinds.def: ...here and update for diagnostic_t
becoming enum class diagnostics::kind.
* diagnostics/kinds.h: New file, based on material in
diagnostic-core.h.
* diagnostics/lazy-paths.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* diagnostics/option-classifier.cc: Likewise.
* diagnostics/option-classifier.h: Likewise.
* diagnostics/output-spec.h: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/selftest-context.cc: Likewise.
* diagnostics/selftest-context.h: Likewise.
* diagnostics/sink.h: Likewise.
* diagnostics/source-printing.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* diagnostics/text-sink.h: Likewise.
* gcc.cc: Likewise.
* libgdiagnostics.cc: Likewise.
* lto-wrapper.cc: Likewise.
* opts-common.cc: Likewise.
* opts-diagnostic.h: Likewise.
* opts.cc: Likewise.
* rtl-error.cc: Likewise.
* substring-locations.cc: Likewise.
* toplev.cc: Likewise.
gcc/ada/ChangeLog:
* gcc-interface/trans.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
gcc/analyzer/ChangeLog:
* pending-diagnostic.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* program-point.cc: Likewise.
gcc/c-family/ChangeLog:
* c-common.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* c-format.cc: Likewise.
* c-lex.cc: Likewise.
* c-opts.cc: Likewise.
* c-pragma.cc: Likewise.
* c-warn.cc: Likewise.
gcc/c/ChangeLog:
* c-errors.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* c-parser.cc: Likewise.
* c-typeck.cc: Likewise.
gcc/cobol/ChangeLog:
* util.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
gcc/cp/ChangeLog:
* call.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* constexpr.cc: Likewise.
* cp-tree.h: Likewise.
* decl.cc: Likewise.
* error.cc: Likewise.
* init.cc: Likewise.
* method.cc: Likewise.
* module.cc: Likewise.
* parser.cc: Likewise.
* pt.cc: Likewise.
* semantics.cc: Likewise.
* typeck.cc: Likewise.
* typeck2.cc: Likewise.
gcc/d/ChangeLog:
* d-diagnostic.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
gcc/fortran/ChangeLog:
* cpp.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* error.cc: Likewise.
* options.cc: Likewise.
gcc/jit/ChangeLog:
* dummy-frontend.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
gcc/m2/ChangeLog:
* gm2-gcc/m2linemap.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* gm2-gcc/rtegraph.cc: Likewise.
gcc/rust/ChangeLog:
* backend/rust-tree.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* backend/rust-tree.h: Likewise.
* resolve/rust-ast-resolve-expr.cc: Likewise.
* resolve/rust-ice-finalizer.cc: Likewise.
* resolve/rust-ice-finalizer.h: Likewise.
* resolve/rust-late-name-resolver-2.0.cc: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update for
diagnostic_t becoming enum class diagnostics::kind.
* gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.
* lib/gcc-dg.exp: Likewise.
libcpp/ChangeLog:
* internal.h: Update comment for diagnostic_t becoming
enum class diagnostics::kind.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
No functional change intended.
gcc/ada/ChangeLog:
* gcc-interface/misc.cc: Update for diagnostic_context becoming
diagnostics::context.
gcc/analyzer/ChangeLog:
* program-point.cc: : Update for diagnostic_context becoming
diagnostics::context, and for diagnostic_source_print_policy
becoming diagnostics::source_print_policy.
gcc/c-family/ChangeLog:
* c-common.h: Update for diagnostic_context becoming
diagnostics::context.
* c-opts.cc: Likewise.
gcc/c/ChangeLog:
* c-objc-common.cc: Update for diagnostic_context becoming
diagnostics::context.
* c-tree.h: Likewise.
gcc/ChangeLog:
* coretypes.h: Update for diagnostic_context becoming
diagnostics::context.
* diagnostic-global-context.cc: Likewise.
* diagnostic.cc: Likewise. Also for diagnostic_option_classifier
becoming diagnostics::option_classifier.
* diagnostic.h (diagnostic_text_starter_fn): Rename to...
(diagnostics::text_starter_fn): ...this, and move to
diagnostics/context.h.
(get_printer): Rename to...
(diagnostics::get_printer): ...this, and move to
diagnostics/context.h.
(class diagnostic_option_manager): Rename to...
(class diagnostics::option_manager): ...this, and move to
diagnostics/context.h.
(class diagnostic_option_classifier): Rename to...
(class diagnostics::option_classifier): ...this, and move to
diagnostics/context.h.
(struct diagnostic_source_printing_options): Rename to...
(struct diagnostics::source_printing_options): ...this, and move
to diagnostics/context.h.
(class diagnostic_column_policy): Rename to...
(class diagnostics::column_policy): ...this, and move to
diagnostics/context.h.
(class diagnostic_location_print_policy): Rename to...
(class diagnostics::location_print_policy): ...this, and move to
diagnostics/context.h.
(class html_label_writer): Rename to...
(class diagnostics::html_label_writer): ...this, and move to
diagnostics/context.h.
(class diagnostic_source_print_policy): Rename to...
(class diagnostics::source_print_policy): ...this, and move to
diagnostics/context.h.
(struct diagnostic_counters): Rename to...
(struct diagnostics::counters): ...this, and move to
diagnostics/context.h.
(class diagnostic_context): Rename to...
(class diagnostics::context): ...this, and move to
diagnostics/context.h.
(diagnostic_text_starter): Rename to...
(diagnostics::text_starter): ...this, and move to
diagnostics/context.h.
(diagnostic_start_span): Rename to...
(diagnostics::start_span): ...this, and move to
diagnostics/context.h.
(diagnostic_text_finalizer): Rename to...
(diagnostics::text_finalizer): ...this, and move to
diagnostics/context.h.
Include "diagnostics/context.h".
* diagnostics/buffering.h: Update for diagnostic_context becoming
diagnostics::context; similarly for diagnostic_counters.
* diagnostics/client-data-hooks.h: Likewise.
* diagnostics/context.h: New file, taken from material in
diagnostic.h.
* diagnostics/html-sink.cc: : Update for diagnostic_context
becoming diagnostics::context.
* diagnostics/html-sink.h: Likewise.
* diagnostics/lazy-paths.cc: Likewise for
diagnostic_option_manager.
* diagnostics/output-file.h: Likewise for diagnostic_context.
* diagnostics/output-spec.cc: Likewise.
* diagnostics/output-spec.h: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/sarif-sink.h: Likewise.
* diagnostics/sink.h: Likewise.
* diagnostics/source-printing.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* diagnostics/text-sink.h: Likewise.
* gcc-rich-location.h: Likewise.
* gcc.cc: Likewise.
* gdbinit.in: Likewise.
* langhooks-def.h: Likewise.
* langhooks.cc: Likewise.
* langhooks.h: Likewise.
* libgdiagnostics.cc: Likewise.
* optc-gen.awk: Likewise.
* opth-gen.awk: Likewise.
* opts-common.cc: Likewise.
* opts-diagnostic.cc: Likewise.
* opts-diagnostic.h: Likewise.
* opts-global.cc: Likewise.
* opts.cc: Likewise.
* opts.h: Likewise.
* selftest-diagnostic.cc: Likewise.
* selftest-diagnostic.h: Likewise.
* toplev.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
* tree-diagnostic.cc: Likewise.
* tree-diagnostic.h: Likewise.
gcc/cp/ChangeLog:
* cp-tree.h: Update for diagnostic_context becoming
diagnostics::context.
* error.cc: Likewise.
* module.cc: Likewise.
gcc/fortran/ChangeLog:
* error.cc: Update for diagnostic_context becoming
diagnostics::context.
gcc/jit/ChangeLog:
* dummy-frontend.cc: Update for diagnostic_context becoming
diagnostics::context.
* jit-playback.h: Likewise.
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc: Update for diagnostic_text_finalizer
becoming diagnostics::text_finalizer.
* resolve/rust-late-name-resolver-2.0.cc: Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/plugin/show_template_tree_color_plugin.cc: Update for
moves to namespace diagnostics.
* gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Within gcc/
move diagnostic-buffer.h to diagnostics/buffering.h
move diagnostic-format-html.cc to diagnostics/html-sink.cc
move diagnostic-format-html.h to diagnostics/html-sink.h
move diagnostic-format-sarif.cc to diagnostics/sarif-sink.cc
move diagnostic-format-sarif.h to diagnostics/sarif-sink.h
move diagnostic-format.h to diagnostics/sink.h
move diagnostic-format-text.cc to diagnostics/text-sink.cc
move diagnostic-format-text.h to diagnostics/text-sink.h
renaming various types including:
Old name: New name:
diagnostic_output_format diagnostics::sink
diagnostic_buffer diagnostics::buffer
diagnostic_per_format_buffer diagnostics::per_sink_buffer
diagnostic_text_output_format diagnostics::text_sink
sarif_output_format diagnostics::sarif_sink
diagnostic_sarif_format_buffer diagnostics::sarif_sink_buffer
html_output_format diagnostics::html_sink
diagnostic_html_format_buffer diagnostics::html_sink_buffer
No functional change intended.
gcc/ChangeLog:
* Makefile.in (OBJS): Replace diagnostic-format-html.o with
diagnostics/html-sink.o, diagnostic-format-sarif.o with
diagnostics/sarif-sink.o, and diagnostic-format-text.o with
diagnostics/text-sink.o.
* coretypes.h (class diagnostic_text_output_format): Replace
with...
(class diagnostics::text_sink): ...this.
* diagnostic-global-context.cc: Update for move of diagnostics
output formats into namespace "diagnostics", as "sinks".
* diagnostic-macro-unwinding.cc: Likewise.
* diagnostic-macro-unwinding.h: Likewise.
* diagnostic-show-locus.cc: Likewise.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostic-buffer.h: Rename to...
* diagnostics/buffering.h: ...this, updating for above changes.
* diagnostics/client-data-hooks.h: Likewise.
* diagnostics/digraphs.cc: Likewise.
* diagnostic-format-html.cc: Rename to...
* diagnostics/html-sink.cc: ...this, updating for above changes.
* diagnostic-format-html.h: Rename to...
* diagnostics/html-sink.h: ...this, updating for above changes.
* diagnostics/lazy-paths.cc: Likewise.
* diagnostics/metadata.h: Likewise.
* diagnostics/output-spec.cc: Likewise.
* diagnostics/output-spec.h: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/paths.h: Likewise.
* diagnostic-format-sarif.cc: Rename to...
* diagnostics/sarif-sink.cc: ...this, updating for above changes.
* diagnostic-format-sarif.h: Rename to...
* diagnostics/sarif-sink.h: ...this, updating for above changes.
* diagnostic-format.h: Rename to...
* diagnostics/sink.h: ...this, updating for above changes.
* diagnostics/state-graphs-to-dot.cc: Likewise.
* diagnostic-format-text.cc: Rename to...
* diagnostics/text-sink.cc: ...this, updating for above changes.
* diagnostic-format-text.h: Rename to...
* diagnostics/text-sink.h: ...this, updating for above changes.
* gcc.cc: Likewise.
* langhooks-def.h: Likewise.
* langhooks.cc: Likewise.
* langhooks.h: Likewise.
* libgdiagnostics.cc: Likewise.
* opts-diagnostic.cc: Likewise.
* opts.cc: Likewise.
* selftest-diagnostic.cc: Likewise.
* selftest-run-tests.cc: Likewise.
* selftest.h: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
* tree-diagnostic.cc: Likewise.
gcc/analyzer/ChangeLog:
* ana-state-to-diagnostic-state.cc: Update for move of
diagnostics output formats into namespace "diagnostics" as
"sinks".
* bounds-checking.cc: Likewise.
* call-details.cc: Likewise.
* checker-event.cc: Likewise.
* checker-event.h: Likewise.
* diagnostic-manager.cc: Likewise.
* diagnostic-manager.h: Likewise.
* infinite-loop.cc: Likewise.
* infinite-recursion.cc: Likewise.
* pending-diagnostic.h: Likewise.
* region-model.cc: Likewise.
* sm-taint.cc: Likewise.
gcc/c-family/ChangeLog:
* c-opts.cc: Update for move of diagnostics output formats into
namespace "diagnostics" as "sinks".
gcc/cp/ChangeLog:
* cp-tree.h: Update for move of diagnostics output formats into
namespace "diagnostics" as "sinks".
* error.cc: Likewise.
gcc/fortran/ChangeLog:
* error.cc: Update for move of diagnostics output formats into
namespace "diagnostics" as "sinks".
* gfortran.h: Likewise.
gcc/jit/ChangeLog:
* dummy-frontend.cc: Update for move of diagnostics output formats
into namespace "diagnostics" as "sinks".
gcc/rust/ChangeLog:
* resolve/rust-ice-finalizer.cc: Update for move of diagnostics
output formats into namespace "diagnostics" as "sinks".
* resolve/rust-ice-finalizer.h: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_group_plugin.cc: Update for move of
diagnostics output formats into namespace "diagnostics" as
"sinks".
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.
libcc1/ChangeLog:
* context.cc: Update for move of diagnostics output formats into
namespace "diagnostics" as "sinks".
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
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>
|
|
No functional change intended.
gcc/analyzer/ChangeLog:
* bounds-checking.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for
move of diagnostic_diagram to diagnostics::diagram.
gcc/ChangeLog:
* diagnostic-format-html.cc: Update for move of diagnostic_diagram
to diagnostics::diagram.
* diagnostic-format-sarif.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for move
of diagnostic_diagram to diagnostics::diagram.
* diagnostic-format-text.cc: Likewise.
* diagnostic-format-text.h: Update for move of diagnostic_diagram
to diagnostics::diagram.
* diagnostic-format.h: Likewise.
* diagnostic.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for move
of diagnostic_diagram to diagnostics::diagram.
* diagnostic.h: Update for move of diagnostic_diagram to
diagnostics::diagram.
* diagnostic-diagram.h: Move to...
* diagnostics/diagram.h: ...here.
(class diagnostic_diagram): Convert to...
(class diagnostics::diagram): ...this.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_text_art.cc: Update
#include for move of "diagnostic-diagram.h" to
"diagnostics/diagram.h". Update for move of diagnostic_diagram to
diagnostics::diagram.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
renamed: gcc/diagnostic-metadata.h -> gcc/diagnostics/metadata.h
No functional change intended.
gcc/analyzer/ChangeLog:
* diagnostic-manager.cc: Update for move of diagnostic_metadata to
diagnostics::metadata.
* kf.cc: Likewise.
* pending-diagnostic.h: Likewise; also, update #include for move
of "diagnostic-metadata.h" to "diagnostics/metadata.h".
gcc/cobol/ChangeLog:
* util.cc: Remove redundant #includes
gcc/ChangeLog:
* diagnostic-core.h: Update for move of diagnostic_metadata to
diagnostics::metadata.
* diagnostic-format-html.cc: Likewise; also, update #include for
move of "diagnostic-metadata.h" to "diagnostics/metadata.h".
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-text.cc: Likewise.
* diagnostic-global-context.cc: Likewise.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostic-metadata.h: Move to...
* diagnostics/metadata.h: ...here, updating header guard.
(class diagnostic_metadata): Move to...
(class diagnostics::metadata): ...here. Drop redundant
"diagnostics::" qualifiers.
* libgdiagnostics.cc: : Update #include for move of
"diagnostic-metadata.h" to "diagnostics/metadata.h", and update
for move of diagnostic_metadata to diagnostics::metadata.
* selftest-diagnostic.cc: Update for move of diagnostic_metadata
to diagnostics::metadata.
* selftest-diagnostic.h: Likewise.
gcc/rust/ChangeLog:
* rust-diagnostics.cc: Update #include for move of
"diagnostic-metadata.h" to "diagnostics/metadata.h", and update
for move of diagnostic_metadata to diagnostics::metadata.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: : Update #include for
move of "diagnostic-metadata.h" to "diagnostics/metadata.h"
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc: Likewise. Also
update for move of diagnostic_metadata to diagnostics::metadata.
* gcc.dg/plugin/diagnostic_plugin_test_metadata.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise.
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>
|
|
The "gcc" subdirectory of our source tree currently contains a total
of almost 1000 .cc and .h files, enough to hit rate-limiting in some
git web UIs, and obscuring the logical relationships between subsystems.
In r16-2211-ga5d9debedd2f46 I started introducing a
"namespace diagnostics" so it makes sense to move such code
into a new "gcc/diagnostics" subdirectory.
My intent is for the "diagnostics" namespace/directory to contain
shared parts of the diagnostics code that are in libcommon, in
particular which don't have knowledge of trees.
This patch begins moving of the existing code within
"namespace diagnostics" into a new "gcc/diagnostics" subdirectory.
No functional change intended.
renamed: gcc/diagnostic-digraphs.cc -> gcc/diagnostics/digraphs.cc
renamed: gcc/diagnostic-digraphs.h -> gcc/diagnostics/digraphs.h
renamed: gcc/diagnostic-state-to-dot.cc -> gcc/diagnostics/state-graphs-to-dot.cc
renamed: gcc/diagnostic-state-graphs.cc -> gcc/diagnostics/state-graphs.cc
renamed: gcc/diagnostic-state-graphs.h -> gcc/diagnostics/state-graphs.h
contrib/ChangeLog:
* gcc.doxy (INPUT): Add gcc/diagnostics subdir.
gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Rename diagnostic-digraphs.o to
diagnostics/digraphs.o. Rename diagnostic-state-graphs.o to
diagnostics/state-graphs.o. Rename diagnostic-state-to-dot.o to
diagnostics/state-graphs-to-dot.o.
(PLUGIN_HEADERS): Add $(srcdir)/diagnostics/*.h.
(install-plugin:): Likewise.
* configure: Regenerate.
* configure.ac (gccdepdir): Add "diagnostics" to directories.
* diagnostic-format-html.cc: Update #includes for move of
"diagnostic-digraphs.h" to "diagnostics/digraphs.h" and of
move of "diagnostic-state-graphs.h" to
"diagnostics/state-graphs.h".
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-path.cc: Likewise for state-graphs.h
* diagnostic-digraphs.cc: Move...
* diagnostics/digraphs.cc: ...to here. Update #include
for renaming of digraphs.h.
(selftest::diagnostic_digraphs_cc_tests): Rename to...
(selftest::diagnostics_digraphs_cc_tests): ...this.
* diagnostic-digraphs.h: Move...
* diagnostics/digraphs.h: ...to here, updating header guard.
* diagnostic-state-to-dot.cc: Move...
* diagnostics/state-graphs-to-dot.cc: ...to here. Update #include
of state-graphs.h.
* diagnostic-state-graphs.cc: Move...
* diagnostics/state-graphs.cc: ...to here. Update #include
of state-graphs.h.
(selftest::diagnostic_state_graphs_cc_tests): Rename...
(selftest::diagnostics_state_graphs_cc_tests): ...to this.
* diagnostic-state-graphs.h: Move...
* diagnostics/state-graphs.h: ...to here, updating header guard.
* libgdiagnostics.cc: Update #includes for move of
"diagnostic-digraphs.h" to "diagnostics/digraphs.h" and of
move of "diagnostic-state-graphs.h" to
"diagnostics/state-graphs.h".
* selftest-run-tests.cc (selftest::run_tests): Update for
function renamings that reflect file renamings.
* selftest.h (selftest::diagnostic_digraphs_cc_tests): Rename
to...
(selftest::diagnostics_digraphs_cc_tests): ...this.
(selftest::diagnostic_state_graphs_cc_tests): Rename...
(selftest::diagnostics_state_graphs_cc_tests): ...to this.
gcc/analyzer/ChangeLog:
* ana-state-to-diagnostic-state.cc: Update #include for move of
"diagnostic-state-graphs.h" to "diagnostics/state-graphs.h".
* ana-state-to-diagnostic-state.h: Likewise.
* checker-event.cc: Likewise.
* checker-event.h: Update #include for move of
"diagnostic-digraphs.h" to "diagnostics/digraphs.h".
* program-state.cc: : Update #include for move of
"diagnostic-state-graphs.h" to "diagnostics/state-graphs.h".
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc: Update #include
for move of "diagnostic-digraphs.h" to "diagnostics/digraphs.h".
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
This implements error handling for hard register constraints including
potential conflicts with register asm operands.
In contrast to register asm operands, hard register constraints allow
more than just one register per operand. Even more than just one
register per alternative. For example, a valid constraint for an
operand is "{r0}{r1}m,{r2}". However, this also means that we have to
make sure that each register is used at most once in each alternative
over all outputs and likewise over all inputs. For asm statements this
is done by this patch during gimplification. For hard register
constraints used in machine description, error handling is still a todo
and I haven't investigated this so far and consider this rather a low
priority.
gcc/ada/ChangeLog:
* gcc-interface/trans.cc (gnat_to_gnu): Pass null pointer to
parse_{input,output}_constraint().
gcc/analyzer/ChangeLog:
* region-model-asm.cc (region_model::on_asm_stmt): Pass null
pointer to parse_{input,output}_constraint().
gcc/c/ChangeLog:
* c-typeck.cc (build_asm_expr): Pass null pointer to
parse_{input,output}_constraint().
gcc/ChangeLog:
* cfgexpand.cc (n_occurrences): Move this ...
(check_operand_nalternatives): and this ...
(expand_asm_stmt): and the call to gimplify.cc.
* config/s390/s390.cc (s390_md_asm_adjust): Pass null pointer to
parse_{input,output}_constraint().
* gimple-walk.cc (walk_gimple_asm): Pass null pointer to
parse_{input,output}_constraint().
(walk_stmt_load_store_addr_ops): Ditto.
* gimplify-me.cc (gimple_regimplify_operands): Ditto.
* gimplify.cc (num_occurrences): Moved from cfgexpand.cc.
(num_alternatives): Ditto.
(gimplify_asm_expr): Deal with hard register constraints.
* stmt.cc (eliminable_regno_p): New helper.
(hardreg_ok_p): Perform a similar check as done in
make_decl_rtl().
(parse_output_constraint): Add parameter for gimplify_reg_info
and validate hard register constrained operands.
(parse_input_constraint): Ditto.
* stmt.h (class gimplify_reg_info): Forward declaration.
(parse_output_constraint): Add parameter.
(parse_input_constraint): Ditto.
* tree-ssa-operands.cc
(operands_scanner::get_asm_stmt_operands): Pass null pointer
to parse_{input,output}_constraint().
* tree-ssa-structalias.cc (find_func_aliases): Pass null pointer
to parse_{input,output}_constraint().
* varasm.cc (assemble_asm): Pass null pointer to
parse_{input,output}_constraint().
* gimplify_reg_info.h: New file.
gcc/cp/ChangeLog:
* semantics.cc (finish_asm_stmt): Pass null pointer to
parse_{input,output}_constraint().
gcc/d/ChangeLog:
* toir.cc: Pass null pointer to
parse_{input,output}_constraint().
gcc/testsuite/ChangeLog:
* gcc.dg/pr87600-2.c: Split test into two files since errors for
functions test{0,1} are thrown during expand, and for
test{2,3} during gimplification.
* lib/scanasm.exp: On s390, skip lines beginning with #.
* gcc.dg/asm-hard-reg-error-1.c: New test.
* gcc.dg/asm-hard-reg-error-2.c: New test.
* gcc.dg/asm-hard-reg-error-3.c: New test.
* gcc.dg/asm-hard-reg-error-4.c: New test.
* gcc.dg/asm-hard-reg-error-5.c: New test.
* gcc.dg/pr87600-3.c: New test.
* gcc.target/aarch64/asm-hard-reg-2.c: New test.
* gcc.target/s390/asm-hard-reg-7.c: New test.
|
|
|
|
In r16-1631-g2334d30cd8feac I added support for capturing state
information from -fanalyzer in XML form, and adding a way to visualize
these states in HTML output. The data was optionally captured in SARIF
output (with "xml-state=yes"), stashing the XML in string form in
a property bag.
This worked, but there was no way to round-trip the stored data back
from SARIF without adding an XML parser to GCC, which I don't want to
do.
SARIF supports capturing directed graphs, so this patch:
(a) adds a new namespace diagnostics::digraphs, with classes digraph,
node, and edge, representing directed graphs in a form similar to
what SARIF can serialize
(b) adds support to GCC's diagnostic subsystem for reporting graphs,
either "globally" or as part of a diagnostic. An example in a testsuite
plugin emits an error that has a couple of dummy graphs associated with
it, and captures the optimization passes as a digraph "globally".
Graphs are ignored by text sinks, but are captured by sarif sinks,
and the "experimental-html" sink gains SVG-based rendering of any graphs
using dot. This HTML output is rather crude; an example can be seen
here:
https://dmalcolm.fedorapeople.org/gcc/2025-07-10/diagnostic-test-graphs-html.c.html
(c) adds support to libgdiagnostics for the above
(d) adds support to sarif-replay for the above (round-tripping any
graph information)
(e) replaces the XML representation of state with a representation
based on the above directed graphs, using property bags to stash
additional information (e.g. "this is an on-stack buffer")
(f) implements round-tripping of this information in sarif-replay
To summarize:
- previously we could generate HTML diagrams for debugging
-fanalyzer directly from gcc, but not from stored .sarif output.
- with this patch, we can generate such HTML diagrams both directly
*and* from stored .sarif output (provided the SARIF sink was created
with "state-graphs=yes")
Examples of HTML output can be seen here:
https://dmalcolm.fedorapeople.org/gcc/2025-07-10/
where as before j/k can be used to cycle through the events.
which is almost identical to the output from the old XML-based
implementation seen at:
https://dmalcolm.fedorapeople.org/gcc/2025-06-23/
gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add diagnostic-digraphs.o and
diagnostic-state-graphs.o.
gcc/ChangeLog:
* diagnostic-format-html.cc: Include "diagnostic-format-sarif.h",
Replace include of "diagnostic-state.h" with includes of
"diagnostic-digraphs.h" and "diagnostic-state-graphs.h".
(html_generation_options::html_generation_options): Update for
field renaming.
(html_builder::m_body_element): New field.
(html_builder::html_builder): Initialize m_body_element.
(html_builder::maybe_make_state_diagram): Port from XML
implementation to state graph implementation.
(html_builder::make_element_for_diagnostic): Add any
per-diagnostic graphs.
(html_builder::add_graph): New.
(html_builder::emit_global_graph): New.
(html_output_format::report_global_digraph): New.
* diagnostic-format-html.h
(html_generation_options::m_show_state_diagram_xml): Replace
with...
(html_generation_options::m_show_state_diagrams_sarif): ...this.
(html_generation_options::m_show_state_diagram_dot_src): Rename
to...
(html_generation_options::m_show_state_diagrams_dot_src): ...this.
* diagnostic-format-sarif.cc: Include "diagnostic-digraphs.h" and
"diagnostic-state-graphs.h".
(sarif_builder::m_run_graphs): New field.
(sarif_result::on_nested_diagnostic): Update call to
make_location_object to pass arg by pointer.
(sarif_builder::sarif_builder): Initialize m_run_graphs.
(sarif_builder::report_global_digraph): New.
(sarif_builder::make_result_object): Add any graphs to
the result object.
(sarif_builder::make_locations_arr): Update call to
make_location_object to pass arg by pointer.
(sarif_builder::make_location_object): Pass param "loc_mgr" by
pointer rather than by reference so that it can be null, and
handle this case.
(copy_any_property_bag): New.
(make_sarif_graph): New.
(make_sarif_node): New.
(make_sarif_edge): New.
(sarif_property_bag::set_graph): New.
(populate_thread_flow_location_object): Port from XML
implementation to state graph implementation.
(make_run_object): Store any graphs.
(sarif_output_format::report_global_digraph): New.
(sarif_generation_options::sarif_generation_options): Rename
m_xml_state to m_state_graph.
(selftest::test_make_location_object): Update for change to
make_location_object.
* diagnostic-format-sarif.h:
(sarif_generation_options::m_xml_state): Replace with...
(sarif_generation_options::m_state_graph): ...this.
(class sarif_location_manager): Add forward decl.
(diagnostics::digraphs::digraph): New forward decl.
(diagnostics::digraphs::node): New forward decl.
(diagnostics::digraphs::edge): New forward decl.
(sarif_property_bag::set_graph): New decl.
(class sarif_graph): New.
(class sarif_node): New.
(class sarif_edge): New.
(make_sarif_graph): New decl.
(make_sarif_node): New decl.
(make_sarif_edge): New decl.
* diagnostic-format-text.h
(diagnostic_text_output_format::report_global_digraph): New.
* diagnostic-format.h
(diagnostic_output_format::report_global_digraph): New vfunc.
* diagnostic-digraphs.cc: New file.
* diagnostic-digraphs.h: New file.
* diagnostic-metadata.h (diagnostics::digraphs::lazy_digraphs):
New forward decl.
(diagnostic_metadata::diagnostic_metadata): Initialize
m_lazy_digraphs.
(diagnostic_metadata::set_lazy_digraphs): New.
(diagnostic_metadata::get_lazy_digraphs): New.
(diagnostic_metadata::m_lazy_digraphs): New field.
* diagnostic-output-spec.cc (sarif_scheme_handler::make_sink):
Update for XML to state graph changes.
(sarif_scheme_handler::make_sarif_gen_opts): Likewise.
(html_scheme_handler::make_sink): Rename "show-state-diagram-xml"
to "show-state-diagrams-sarif" and use pluralization consistently.
* diagnostic-path.cc: Replace include of "xml.h" with
"diagnostic-state-graphs.h".
(diagnostic_event::maybe_make_xml_state): Replace with...
(diagnostic_event::maybe_make_diagnostic_state_graph): ...this.
* diagnostic-path.h (diagnostics::digraphs::digraph): New forward
decl.
(diagnostic_event::maybe_make_xml_state): Replace with...
(diagnostic_event::maybe_make_diagnostic_state_graph): ...this.
* diagnostic-state-graphs.cc: New file.
* diagnostic-state-graphs.h: New file.
* diagnostic-state-to-dot.cc: Port implementation from XML to
state graphs.
* diagnostic-state.h: Deleted file.
* diagnostic.cc (diagnostic_context::report_global_digraph): New.
* diagnostic.h (diagnostics::digraphs::lazy_digraph): New forward
decl.
(diagnostic_context::report_global_digraph): New decl.
* doc/analyzer.texi (Debugging the Analyzer): Update to reflect
change from XML to state graphs.
* doc/invoke.texi ("sarif" diagnostics sink): Replace "xml-state"
with "state-graphs".
("experimental-html" diagnostics sink): Replace
"show-state-diagrams-xml" with "show-state-diagrams-sarif"
* doc/libgdiagnostics/topics/compatibility.rst
(LIBGDIAGNOSTICS_ABI_3): New.
* doc/libgdiagnostics/topics/graphs.rst: New file.
* doc/libgdiagnostics/topics/index.rst: Add graphs.rst.
* graphviz.h (node_id::operator=): New.
* json.h (json::value::dyn_cast_string): New.
(json::object::get_num_keys): New accessor.
(json::object::get_key): New accessor.
(json::string::dyn_cast_string): New.
* libgdiagnostics++.h (class libgdiagnostics::graph): New.
(class libgdiagnostics::node): New.
(class libgdiagnostics::edge): New.
(class libgdiagnostics::diagnostic::take_graph): New.
(class libgdiagnostics::manager::take_global_graph): New.
(class libgdiagnostics::graph::set_description): New.
(class libgdiagnostics::graph::get_node_by_id): New.
(class libgdiagnostics::graph::get_edge_by_id): New.
(class libgdiagnostics::graph::add_edge): New.
(class libgdiagnostics::node::set_label): New.
(class libgdiagnostics::node::set_location): New.
(class libgdiagnostics::node::set_logical_location): New.
* libgdiagnostics-private.h: New file.
* libgdiagnostics.cc: Define INCLUDE_STRING. Include
"diagnostic-digraphs.h", "diagnostic-state-graphs.h", and
"libgdiagnostics-private.h".
(struct diagnostic_graph): New.
(struct diagnostic_node): New.
(struct diagnostic_edge): New.
(libgdiagnostics_path_event::libgdiagnostics_path_event): Add
state_graph param.
(libgdiagnostics_path_event::maybe_make_diagnostic_state_graph):
New.
(libgdiagnostics_path_event::m_state_graph): New field.
(diagnostic_execution_path::add_event_va): Add state_graph param.
(class prebuilt_digraphs): New.
(diagnostic::diagnostic): Use m_graphs in m_metadata.
(diagnostic::take_graph): New.
(diagnostic::get_graphs): New accessor.
(diagnostic::m_graphs): New field.
(diagnostic_manager::take_global_graph): New.
(diagnostic_execution_path_add_event): Update for new param to
add_event_va.
(diagnostic_execution_path_add_event_va): Likewise.
(diagnostic_graph::add_node_with_id): New public entrypoint.
(diagnostic_graph::add_edge_with_label): New public entrypoint.
(diagnostic_manager_new_graph): New public entrypoint.
(diagnostic_manager_take_global_graph): New public entrypoint.
(diagnostic_take_graph): New public entrypoint.
(diagnostic_graph_release): New public entrypoint.
(diagnostic_graph_set_description): New public entrypoint.
(diagnostic_graph_add_node): New public entrypoint.
(diagnostic_graph_add_edge): New public entrypoint.
(diagnostic_graph_get_node_by_id): New public entrypoint.
(diagnostic_graph_get_edge_by_id): New public entrypoint.
(diagnostic_node_set_location): New public entrypoint.
(diagnostic_node_set_label): New public entrypoint.
(diagnostic_node_set_logical_location): New public entrypoint.
(private_diagnostic_execution_path_add_event_2): New private
entrypoint.
(private_diagnostic_graph_set_property_bag): New private
entrypoint.
(private_diagnostic_node_set_property_bag): New private
entrypoint.
(private_diagnostic_edge_set_property_bag): New private
entrypoint.
* libgdiagnostics.h (diagnostic_graph): New typedef.
(diagnostic_node): New typedef.
(diagnostic_edge): New typedef.
(diagnostic_manager_new_graph): New decl.
(diagnostic_manager_take_global_graph): New decl.
(diagnostic_take_graph): New decl.
(diagnostic_graph_release): New decl.
(diagnostic_graph_set_description): New decl.
(diagnostic_graph_add_node): New decl.
(diagnostic_graph_add_edge): New decl.
(diagnostic_graph_get_node_by_id): New decl.
(diagnostic_graph_get_edge_by_id): New decl.
(diagnostic_node_set_label): New decl.
(diagnostic_node_set_location): New decl.
(diagnostic_node_set_logical_location): New decl.
* libgdiagnostics.map (LIBGDIAGNOSTICS_ABI_3): New.
* libsarifreplay.cc: Include "libgdiagnostics-private.h".
(id_map): New "using".
(sarif_replayer::report_invalid_sarif): Update for change to
report_problem params.
(sarif_replayer::report_unhandled_sarif): Likewise.
(sarif_replayer::report_note): New.
(sarif_replayer::report_problem): Pass param "ref" by
pointer rather than reference and handle it being null.
(sarif_replayer::maybe_get_property_bag): New.
(sarif_replayer::maybe_get_property_bag_value): New.
(sarif_replayer::handle_run_obj): Handle run-level "graphs" as per
§3.14.20.
(sarif_replayer::handle_result_obj): Handle result-level "graphs"
as per §3.27.19.
(handle_thread_flow_location_object): Optionally handle graphs
stored in property "gcc/diagnostic_event/state_graph" as state
graphs.
(sarif_replayer::handle_graph_object): New.
(sarif_replayer::handle_node_object): New.
(sarif_replayer::handle_edge_object): New.
(sarif_replayer::get_graph_node_by_id_property): New.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest::diagnostic_graph_cc_tests and
selftest::diagnostic_state_graph_cc_tests.
* selftest.h (selftest::diagnostic_graph_cc_tests): New decl.
(selftest::diagnostic_state_graph_cc_tests): New decl.
gcc/analyzer/ChangeLog:
* ana-state-to-diagnostic-state.cc: Reimplement, replacing
XML-based implementation with one based on state graphs.
* ana-state-to-diagnostic-state.h: Likewise.
* checker-event.cc: Replace include of "xml.h" with include of
"diagnostic-state-graphs.h".
(checker_event::maybe_make_xml_state): Replace with...
(checker_event::maybe_make_diagnostic_state_graph): ...this.
* checker-event.h: Add include of "diagnostic-digraphs.h".
(checker_event::maybe_make_xml_state): Replace decl with...
(checker_event::maybe_make_diagnostic_state_graph): ...this.
* engine.cc (exploded_node::on_stmt_pre): Replace
"_analyzer_dump_xml" with "__analyzer_dump_sarif".
* program-state.cc: Replace include of "diagnostic-state.h" with
"diagnostic-state-graphs.h".
(program_state::dump_dot): Port from XML to state graphs.
* program-state.h: Drop reduntant forward decl of xml::document.
(program_state::make_xml): Replace decl with...
(program_state::make_diagnostic_state_graph): ...this.
(program_state::dump_xml_to_pp): Drop decl.
(program_state::dump_xml_to_file): Drop decl.
(program_state::dump_xml): Drop decl.
(program_state::dump_dump_sarif): New decl.
* sm-malloc.cc (get_dynalloc_state_for_state): New.
(malloc_state_machine::add_state_to_xml): Replace with...
(malloc_state_machine::add_state_to_state_graph): ...this.
* sm.cc (state_machine::add_state_to_xml): Replace with...
(state_machine::add_state_to_state_graph): ...this.
(state_machine::add_global_state_to_xml): Replace with...
(state_machine::add_global_state_to_state_graph): ...this.
* sm.h (class xml_state): Drop forward decl.
(class analyzer_state_graph): New forward decl.
(state_machine::add_state_to_xml): Replace decl with...
(state_machine::add_state_to_state_graph): ...this.
(state_machine::add_global_state_to_xml): Replace decl with...
(state_machine::add_global_state_to_state_graph): ...this.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/state-diagram-1-sarif.py (test_xml_state):
Rename to...
(test_state_graph): ...this. Port from XML to SARIF graphs.
* gcc.dg/analyzer/state-diagram-1.c: Update sink option
from "sarif:xml-state=yes" to "sarif:state-graphs=yes".
* gcc.dg/analyzer/state-diagram-5-sarif.c: Likewise.
* gcc.dg/analyzer/state-diagram-5-sarif.py: Drop import of ET.
(test_nested_types_in_xml_state): Rename to...
(test_nested_types_in_state_graph): ...this. Port from XML to
SARIF graphs.
* gcc.dg/plugin/diagnostic-test-graphs-html.c: New test.
* gcc.dg/plugin/diagnostic-test-graphs-html.py: New test script.
* gcc.dg/plugin/diagnostic-test-graphs-sarif.c: New test.
* gcc.dg/plugin/diagnostic-test-graphs-sarif.py: New test script.
* gcc.dg/plugin/diagnostic-test-graphs.c: New test.
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc: New test plugin.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above.
* lib/sarif.py (get_xml_state): Delete.
(get_state_graph): New.
(def get_state_node_attr): New.
(get_state_node_kind): New.
(get_state_node_name): New.
(get_state_node_type): New.
(get_state_node_value): New.
* sarif-replay.dg/2.1.0-invalid/3.40.2-duplicate-node-id.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.41.4-unrecognized-node-id.sarif:
New test.
* sarif-replay.dg/2.1.0-valid/graphs-check-html.py: New test
script.
* sarif-replay.dg/2.1.0-valid/graphs-check-sarif-roundtrip.py: New
test script.
* sarif-replay.dg/2.1.0-valid/graphs.sarif: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
Modernization; no functional change intended.
gcc/analyzer/ChangeLog:
* access-diagram.cc: Use nullptr rather than NULL where
appropriate.
* analyzer-language.cc: Likewise.
* analyzer-language.h: Likewise.
* analyzer-logging.h: Likewise.
* analyzer-pass.cc: Likewise.
* analyzer.cc: Likewise.
* bounds-checking.cc: Likewise.
* call-details.cc: Likewise.
* call-string.cc: Likewise.
* call-string.h: Likewise.
* call-summary.cc: Likewise.
* checker-event.cc: Likewise.
* common.h: Likewise.
* constraint-manager.cc: Likewise.
* constraint-manager.h: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* exploded-graph.h: Likewise.
* function-set.cc: Likewise
* infinite-recursion.cc: Likewise
* inlining-iterator.h: Likewise
* kf.cc: Likewise
* known-function-manager.cc: Likewise
* pending-diagnostic.cc: Likewise
* program-point.cc: Likewise
* program-point.h: Likewise
* program-state.cc: Likewise
* program-state.h: Likewise
* record-layout.cc: Likewise
* region-model-asm.cc: Likewise
* region-model-manager.cc: Likewise
* region-model-manager.h: Likewise
* region-model-reachability.cc: Likewise
* region-model.cc: Likewise
* region-model.h: Likewise
* region.cc: Likewise
* region.h: Likewise
* sm-fd.cc: Likewise
* sm-malloc.cc: Likewise
* sm-pattern-test.cc: Likewise
* sm-signal.cc: Likewise
* sm-taint.cc: Likewise
* sm.cc: Likewise
* sm.h: Likewise
* state-purge.cc: Likewise
* state-purge.h: Likewise
* store.cc: Likewise
* store.h: Likewise
* supergraph.cc: Likewise
* supergraph.h: Likewise
* svalue.cc: Likewise
* svalue.h: Likewise
* varargs.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>
|
|
C2Y voted in the
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3466.pdf
paper, which clarifies some of the conditional nonnull cases.
For strncat/__strncat_chk no changes are necessary, we already
use __attribute__((nonnull (1), nonnull_if_nonzero (2, 3))) attributes
on the builtin and glibc can do the same too, meaning that first
argument must be nonnull always and second must be nonnull if
the third one is nonzero.
The problem is with the fread/fwrite changes, where the paper adds:
If size or nmemb is zero,
+ptr may be a null pointer,
fread returns zero and the contents of the array and the state of
the stream remain unchanged.
and ditto for fwrite, so the two argument nonnull_if_nonzero attribute
isn't usable to express that, because whether the pointer can be null
depends on 2 integral arguments rather than one.
The following patch extends the nonnull_if_nonzero attribute, so that
instead of requiring 2 arguments it allows 2 or 3, the first one
is still the pointer argument index which sometimes must not be null
and the other one or two are integral arguments, if there are 2, the
invalid case is only if pointer is null and both the integral arguments
are nonzero.
2025-06-30 Jakub Jelinek <jakub@redhat.com>
PR c/120520
PR c/117023
gcc/
* builtin-attrs.def (DEF_LIST_INT_INT_INT): Define it and
use for 1,2,3.
(ATTR_NONNULL_IF123_LIST): New DEF_ATTR_TREE_LIST.
(ATTR_NONNULL_4_IF123_LIST): Likewise.
* builtins.def (BUILT_IN_FWRITE): Use ATTR_NONNULL_4_IF123_LIST
instead of ATTR_NONNULL_LIST.
(BUILT_IN_FWRITE_UNLOCKED): Likewise.
* gimple.h (infer_nonnull_range_by_attribute): Add another optional
tree * argument defaulted to NULL.
* gimple.cc (infer_nonnull_range_by_attribute): Add OP3 argument,
handle 3 argument nonnull_if_nonzero attribute.
* builtins.cc (validate_arglist): Handle 3 argument nonnull_if_nonzero
attribute.
* tree-ssa-ccp.cc (pass_post_ipa_warn::execute): Likewise.
* ubsan.cc (instrument_nonnull_arg): Adjust
infer_nonnull_range_by_attribute caller, handle 3 argument
nonnull_if_nonzero attribute.
* gimple-range-infer.cc (gimple_infer_range::gimple_infer_range):
Handle 3 argument nonnull_if_nonzero attribute.
* doc/extend.texi (nonnull_if_nonzero): Document 3 argument version
of the attribute.
gcc/c-family/
* c-attribs.cc (c_common_gnu_attributes): Allow 2 or 3 arguments for
nonnull_if_nonzero attribute instead of only 2.
(handle_nonnull_if_nonzero_attribute): Handle 3 argument
nonnull_if_nonzero.
* c-common.cc (struct nonnull_arg_ctx): Rename other member to other1,
add other2 member.
(check_function_nonnull): Clear a if nonnull attribute has an
argument. Adjust for nonnull_arg_ctx changes. Handle 3 argument
nonnull_if_nonzero attribute.
(check_nonnull_arg): Adjust for nonnull_arg_ctx changes, emit different
diagnostics for 3 argument nonnull_if_nonzero attributes.
(check_function_arguments): Adjust ctx var initialization.
gcc/analyzer/
* sm-malloc.cc (malloc_state_machine::on_stmt): Handle 3 argument
nonnull_if_nonzero attribute.
gcc/testsuite/
* gcc.dg/nonnull-9.c: Tweak for 3 argument nonnull_if_nonzero
attribute support, add further tests.
* gcc.dg/nonnull-12.c: New test.
* gcc.dg/nonnull-13.c: New test.
* gcc.dg/nonnull-14.c: New test.
* c-c++-common/ubsan/nonnull-8.c: New test.
* c-c++-common/ubsan/nonnull-9.c: New test.
|
|
|
|
No functional change intended.
gcc/analyzer/ChangeLog:
* region-model.cc
(exception_thrown_from_unrecognized_call::print): Add
"final override" to vfunc.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
This patch adds various support for debugging diagnostic paths and
events, intended initially for myself to help with debugging -fanalyzer.
It adds the optional ability for a diagnostic_event to supply a
description of the predicted state of the program at that point along
the diagnostic_path. To isolate the diagnostic subsystem from the
analyzer, this representation is currently an xml::document with custom
elements. The XML representation is similar to the analyzer's internal
state but can be easier to read - for example, rather than storing the
contents of memory via byte offsets, it uses fields for structs and
element indexes for arrays, recursively.
These states are handled by the HTML and SARIF diagnostic sinks.
The SARIF sink simply embeds the XML as a string in a property bag of the
threadFlowLocation object (SARIF v2.1.0 section 3.38).
For HTML output, the "experimental-html" sink gains a new
"show-state-diagrams=yes" option i.e.:
-fdiagnostics-add-output=experimental-html:show-state-diagrams=yes
which converts the state XML into SVG diagrams visualizing the state of
memory at each event, inspired by the "ddd" debugger. These can be seen
by pressing 'j' and 'k' to single-step forward and backward through
events, making it *much* easier to debug -fanalyzer.
An example of output can be seen here:
https://dmalcolm.fedorapeople.org/gcc/2025-06-23/state-diagram-1.c.html
showing an issue in a singly-linked list; there are various other
examples in the parent directory.
Generating the SVG diagrams requires an invocation of "dot" per event,
so it noticeable slows down diagnostic emission, hence the opt-in
command-line flag. However, I'm already finding bugs in -fanalyzer with
this that I hadn't seen before.
Given that the UI is rather clunky and there is lots of room for
improvement to the visualizations, for now this feature is marked
as being for GCC developers, not end-users.
The patch also adds a dot::ast_node class hierarachy to make it easy to
create GraphViz dot files with the correct escaping, and adds a C++
wrapper around pex adding some syntactic sugar for invoking
subprocesses.
gcc/ChangeLog:
PR other/116792
* Makefile.in (ANALYZER_OBJS): Add
analyzer/ana-state-to-diagnostic-state.o.
(OBJS): Move graphviz.o to...
(OBJS-libcommon): ...here. Add diagnostic-state-to-dot.o and pex.o.
* diagnostic-format-html.cc: Include "diagnostic-state.h" and
"graphviz.h".
(html_generation_options::html_generation_options): Initialize the
new flags.
(HTML_SCRIPT): Add function "get_any_state_diagram". Use it
when changing current focus id to update the visibility of the
pertinent diagram, if any.
(print_pre_source): New.
(html_builder::maybe_make_state_diagram): New.
(html_path_label_writer::html_path_label_writer): Add "path" param.
Initialize m_path and m_curr_event_id.
(html_path_label_writer::begin_label): Store current event id.
(html_path_label_writer::end_label): Attempt to make a state
diagram and add it if successful.
(html_path_label_writer::get_element_id): New.
(html_path_label_writer::m_path): New field.
(html_path_label_writer::m_curr_event_id): New field.
(html_builder::make_element_for_diagnostic): Pass path to label
writer.
* diagnostic-format-html.h
(html_generation_options::m_show_state_diagrams): New field.
(html_generation_options::m_show_state_diagram_xml): New field.
(html_generation_options::m_show_state_diagram_dot_src): New field.
* diagnostic-format-sarif.cc: Include "xml.h".
(populate_thread_flow_location_object): If requested, attempt to
generate xml state and add it to the proeprty bag as
"gcc/diagnostic_event/xml_state" in xml source form.
(sarif_generation_options::sarif_generation_options): Initialize
m_xml_state.
* diagnostic-format-sarif.h
(sarif_generation_options::m_xml_state): New field.
* diagnostic-path.cc: Define INCLUDE_MAP. Include "xml.h".
(diagnostic_event::maybe_make_xml_state): New.
* diagnostic-path.h (class xml::document): New forward decl.
(diagnostic_event::maybe_make_xml_state): New vfunc decl.
* diagnostic-state-to-dot.cc: New file.
* diagnostic-state.h: New file.
* digraph.cc: Define INCLUDE_STRING and INCLUDE_VECTOR.
* doc/analyzer.texi: Document state diagrams in html output.
(__analyzer_dump_dot): New.
(__analyzer_dump_xml): New.
* doc/invoke.texi (sarif): Add "xml-state" key.
(experimental-html): Add keys "show-state-diagrams",
"show-state-diagrams-dot-src" and "show-state-diagrams-xml".
* graphviz.cc: Define INCLUDE_MAP, INCLUDE_STRING, and
INCLUDE_VECTOR. Include "xml.h", "xml-printer.h", "pex.h" and
"selftest.h".
(graphviz_out::graphviz_out): Extract...
(dot::writer::writer): ...this.
(graphviz_out::write_indent): Convert to...
(dot::writer::write_indent): ...this.
(graphviz_out::print): Use get_pp.
(graphviz_out::println): Likewise.
(graphviz_out::begin_tr): Likewise.
(graphviz_out::end_tr): Likewise.
(graphviz_out::begin_td): Likewise.
(graphviz_out::end_td): Likewise.
(graphviz_out::begin_trtd): Likewise.
(graphviz_out::end_tdtr): Likewise.
(dot::ast_node::dump): New.
(dot::id::id): New.
(dot::id::print): New.
(dot::id::is_identifier_p): New.
(dot::kv_pair::print): New.
(dot::attr_list::print): New.
(dot::stmt_list::print): New.
(dot::stmt_list::add_edge): New.
(dot::stmt_list::add_attr): New.
(dot::graph::print): New.
(dot::stmt_with_attr_list::set_label): New.
(dot::node_stmt::print): New.
(dot::attr_stmt::print): New.
(dot::kv_stmt::print): New.
(dot::node_id::print): New.
(dot::port::print): New.
(dot::edge_stmt::print): New.
(dot::subgraph::print): New.
(dot::make_svg_document_buffer_from_graph): New.
(dot::make_svg_from_graph): New.
(selftest:test_ids): New.
(selftest:test_trivial_graph): New.
(selftest:test_layout_example): New.
(selftest:graphviz_cc_tests): New.
* graphviz.h (xml::node): New forward decl.
(class graphviz_out): Split out into...
(class dot::writer): ...this new class
(struct dot::ast_node): New.
(struct dot::id): New.
(struct dot::kv_pair): New.
(struct dot::attr_list): New.
(struct dot::stmt_list): New.
(struct dot::graph): New.
(struct dot::stmt): New.
(struct dot::stmt_with_attr_list): New.
(struct dot::node_stmt): New.
(struct dot::attr_stmt): New.
(struct dot::kv_stmt): New.
(enum class dot::compass_pt): New.
(struct dot::port): New.
(struct dot::node_id): New.
(struct dot::edge_stmt): New.
(struct dot::subgraph): New.
(dot::make_svg_from_graph): New.
* opts-diagnostic.cc (sarif_scheme_handler::make_sink): Add
"xml-state" flag.
(html_scheme_handler::make_sink): Add flags "show-state-diagrams",
"show-state-diagram-dot-src", and "show-state-diagram-xml".
* pex.cc: New file.
* pex.h: New file.
* selftest-run-tests.cc (selftest::run_tests): Call
graphviz_cc_tests.
* selftest.h (selftest::graphviz_cc_tests): New decl.
* xml.cc (xml::node_with_children::add_comment): New.
(xml::node_with_children::find_child_element): New.
(xml::element::get_attr): New.
(xml::comment::write_as_xml): New.
(selftest::test_printer): Add coverage of find_child_element and
get_attr.
(selftest::test_comment): New.
(selftest::xml_cc_tests): Call test_comment.
* xml.h: New forward decls.
(xml::node::dyn_cast_text): Use nullptr.
(xml::node::dyn_cast_element): New vfunc.
(xml::node_with_children::add_comment): New decl.
(xml::node_with_children::find_child_element): New decl.
(xml::element::dyn_cast_element): New vfunc impl.
(xml::element::get_attr): New decl.
(struct xml::comment): New xml::node subclass.
gcc/analyzer/ChangeLog:
PR other/116792
* ana-state-to-diagnostic-state.cc: New file.
* ana-state-to-diagnostic-state.h: New file.
* checker-event.cc: Include "xml.h".
(checker_event::checker_event): Initialize m_path.
(checker_event::prepare_for_emission): Store the path pointer into
m_path.
(checker_event::maybe_make_xml_state): New.
(function_entry_event::function_entry_event): Add "state" param
and use it to initialize m_state.
(superedge_event::get_program_state): New.
(call_event::get_program_state): New.
(warning_event::get_program_state): New.
* checker-event.h (checker_event::get_program_state): New vfunc.
(checker_event::maybe_make_xml_state): New decl.
(checker_event::m_path): New field.
(statement_event::get_program_state): New vfunc impl.
(function_entry_event::function_entry_event): Add "state" param.
(function_entry_event::get_program_state): New vfunc impl.
(function_entry_event::m_state): New field.
(state_change_event::get_program_state): New vfunc impl.
(superedge_event::get_program_state): New vfunc decl.
(warning_event::warning_event): Add "program_state_" param and
copy it.
(warning_event::get_program_state): New vfunc decl.
(warning_event::m_program_state): New field.
* checker-path.h (checker_path::checker_path): Add ext_state param.
(checker_path::get_ext_state): New accessor.
(checker_path::m_ext_state): New field.
* common.h: Define INCLUDE_MAP and INCLUDE_STRING.
* diagnostic-manager.cc (saved_diagnostic::operator==): Don't
deduplicate dump_path_diagnostic instances.
(diagnostic_manager::emit_saved_diagnostic): Pass ext_state to
checker_path ctor.
* engine.cc:
(impl_region_model_context::on_state_leak): Pass old and new state
to state_machine::on_leak.
(exploded_node::on_stmt_pre): Implement __analyzer_dump_xml and
__analyzer_dump_dot.
* exploded-graph.h (impl_region_model_context::get_state): New.
* infinite-recursion.cc
(recursive_function_entry_event::recursive_function_entry_event):
Add "dst_state" param and pass to function_entry_event ctor.
(infinite_recursion_diagnostic::add_function_entry_event): Pass state
to event ctor.
* kf-analyzer.cc: Include "analyzer/program-state.h"
(dump_path_diagnostic::dump_path_diagnostic): Add "state" param.
(dump_path_diagnostic::get_final_state): New.
(dump_path_diagnostic::m_state): New field.
(kf_analyzer_dump_path::impl_call_pre): Pass state to warning.
* pending-diagnostic.cc
(pending_diagnostic::add_function_entry_event): Pass state to
function_entry_event.
(pending_diagnostic::add_final_event): Likewise to warning_event.
* pending-diagnostic.h (pending_diagnostic::get_final_state): New
vfunc decl.
* program-state.cc: Include "diagnostic-state.h", "graphviz.h" and
"analyzer/ana-state-to-diagnostic-state.h".
(program_state::dump_dot): New.
* program-state.h: Include "text-art/tree-widget.h" and
"analyzer/store.h".
(class xml::document): New forward decl.
(make_xml): New.
(dump_xml_to_pp): New.
(dump_xml_to_file): New.
(dump_xml): New.
(dump_dot): New.
* record-layout.cc (record_layout::record_layout): Make param
const_tree.
* record-layout.h (item::item): Likewise.
(item::m_field): Likewise.
(record_layout::record_layout): Likewise.
(record_layout::begin): New.
(record_layout::end): New.
* region-model.cc
(exposure_through_uninit_copy::complain_about_fully_uninit_item):
Use const_tree.
(exposure_through_uninit_copy::complain_about_partially_uninit_item):
Likewise.
* region-model.h (region_model_context::get_state): New vfunc.
(noop_region_model_context::get_state): New.
(region_model_context_decorator::get_state): New.
* sm-fd.cc (fd_leak::fd_leak): Add "final_state" param and capture
it if present.
(fd_leak::get_final_state): New.
(fd_leak::m_final_state): New.
(fd_state_machine::on_open): Pass nullptr for new "final_state"
param.
(fd_state_machine::on_creat): Likewise.
(fd_state_machine::on_socket): Likewise.
(fd_state_machine::on_accept): Likewise.
(fd_state_machine::on_leak): Add state params and pass new state
as final state to fd_leak ctor.
* sm-file.cc: Include "analyzer/program-state.h".
(file_leak::file_leak): Add "final_state" param and capture it if
present.
(file_leak::get_final_state): New.
(file_leak::m_final_state): New.
(fileptr_state_machine::on_leak): Add state params and pass new
state as final state to fd_leak ctor.
* sm-malloc.cc: Include
"analyzer/ana-state-to-diagnostic-state.h".
(malloc_leak::malloc_leak): Add "final_state" param and use it.
(malloc_leak::get_final_state): New vfunc impl.
(malloc_leak::m_final_state): New field.
(malloc_state_machine::on_leak): Add state params; capture final
state.
(malloc_state_machine::add_state_to_xml): New.
* sm.cc (state_machine::on_leak): Add "old_state" and "new_state"
params. Use nullptr.
(state_machine::add_state_to_xml): New.
(state_machine::add_global_state_to_xml): New.
* sm.h (class xml_state): New forward decl.
(state_machine::on_leak): Add state params.
(state_machine::add_state_to_xml): New vfunc decl.
(state_machine::add_global_state_to_xml): New vfunc decl.
* store.h (bit_range::operator<): New.
* varargs.cc (va_list_leak::va_list_leak): Add final_state param
and capture it if non-null.
(va_list_leak::get_final_state): New.
(va_list_leak::m_final_state): New.
(va_list_state_machine::on_leak): Add state params and pass final
state to va_list_leak ctor.
gcc/testsuite/ChangeLog:
PR other/116792
* g++.dg/analyzer/state-diagram.C: New test.
* gcc.dg/analyzer/analyzer-decls.h (__analyzer_dump_dot): New
decl.
(__analyzer_dump_xml): New decl.
* gcc.dg/analyzer/state-diagram-1-sarif.py: New test script.
* gcc.dg/analyzer/state-diagram-1.c: New test.
* gcc.dg/analyzer/state-diagram-2.c: New test.
* gcc.dg/analyzer/state-diagram-3.c: New test.
* gcc.dg/analyzer/state-diagram-4.c: New test.
* gcc.dg/analyzer/state-diagram-5-html.py: New test script.
* gcc.dg/analyzer/state-diagram-5-sarif.py: New test script.
* gcc.dg/analyzer/state-diagram-5.c: New test.
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Define INCLUDE_STRING.
* gcc.dg/plugin/analyzer_gil_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.
* lib/htmltest.py (ns): Add SVG namespace.
* lib/sarif.py (get_result_by_index): New.
(get_xml_state): New.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
No functional change intended.
gcc/analyzer/ChangeLog:
* checker-event.h (checker_event::get_kind): New accessor.
(checker_event::m_kind): Make private.
* checker-path.cc (checker_path::maybe_log): Use accessor for
checker_event::m_kind.
(checker_path::add_event): Likewise.
(checker_path::debug): Likewise.
(checker_path::cfg_edge_pair_at_p): Likewise.
(checker_path::inject_any_inlined_call_events): Likewise.
* diagnostic-manager.cc
(diagnostic_manager::prune_for_sm_diagnostic): Likewise.
(diagnostic_manager::prune_for_sm_diagnostic): Likewise.
(diagnostic_manager::consolidate_conditions): Likewise.
(diagnostic_manager::consolidate_unwind_events): Likewise.
(diagnostic_manager::finish_pruning): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
Previously we used an abstract base class logical_location with
concrete subclasses to separate the diagnostics subsystem from
implementation details of "tree" and of libgdiagnostics.
This approach required allocating implementation objects on the heap
whenever working with logical locations, and made comparing logical
locations awkward.
This patch reworks things so that the type "logical_location" becomes a
boxed pointer (const void *), and client code provides a single object
implementing a new logical_location_manager abstract base class. The
manager class has responsibility for providing meaning to the boxed
pointers. Within the compiler we use a manager in which they are "tree"
pointers, whereas within libgdiagnostics we use a manager in which they
are pointers to instances of libgdiagnostics'
"struct diagnostic_logical_location". Other kinds of manager could be
implemented.
gcc/analyzer/ChangeLog:
* checker-event.cc (checker_event::checker_event): Update
initialization of m_logical_loc.
(checker_event::maybe_add_sarif_properties): Add "builder" param.
Replace call to make_sarif_logical_location_object with call to
sarif_property_bag::set_logical_location.
(superedge_event::maybe_add_sarif_properties): Add "builder"
param.
* checker-event.h (checker_event::get_logical_location):
Reimplement.
(checker_event::maybe_add_sarif_properties): Add "builder" param.
(checker_event::maybe_add_sarif_properties): Add "builder" param.
(checker_event::m_logical_loc): Convert from tree_logical_location
to logical_location.
(superedge_event::maybe_add_sarif_properties): Add sarif_builder
param.
* checker-path.h (checker_path::checker_path): Add logical_loc_mgr
param.
* diagnostic-manager.cc
(diagnostic_manager::emit_saved_diagnostic): Pass logical location
manager to emission_path ctor.
(diagnostic_manager::get_logical_location_manager): New.
* diagnostic-manager.h
(diagnostic_manager::get_logical_location_manager): New decl.
gcc/ChangeLog:
* diagnostic-client-data-hooks.h: Include "logical-location.h".
(diagnostic_client_data_hooks::get_logical_location_manager): New.
(diagnostic_client_data_hooks::get_current_logical_location):
Convert return type from const logical_location * to
logical_location.
* diagnostic-format-json.cc: Include
"diagnostic-client-data-hooks.h".
(make_json_for_path): Update to use logical_location_manager from
the context.
* diagnostic-format-sarif.cc
(sarif_builder::get_logical_location_manager): New.
(sarif_builder::make_location_object): Update type of logical_loc
from "const logical_location *" to "logical_location".
(sarif_builder::set_any_logical_locs_arr): Likewise.
(sarif_builder::m_logical_loc_mgr): New field.
(sarif_result::on_nested_diagnostic): Use logical_location default
ctor rather than nullptr.
(sarif_builder::sarif_builder): Initialize m_logical_loc_mgr from
context's client data hooks.
(sarif_builder::make_locations_arr): Convert type of logical_loc
from from "const logical_location *" to "logical_location".
(sarif_builder::set_any_logical_locs_arr): Likewise. Pass manager
to make_sarif_logical_location_object.
(sarif_builder::make_location_object): Likewise.
(sarif_property_bag::set_logical_location): New.
(make_sarif_logical_location_object): Update for introduction of
logical_location_manager.
(populate_thread_flow_location_object): Pass builder to
ev.maybe_add_sarif_properties.
(selftest::test_make_location_object): Use logical_location
default ctor rather than nullptr.
* diagnostic-format-sarif.h (class logical_location): Replace
forward decl with include of "logical-location.h".
(class sarif_builder): New forward decl.
(sarif_property_bag::set_logical_location): New.
(make_sarif_logical_location_object): Add "mgr" param.
* diagnostic-path.cc
(diagnostic_path::get_first_event_in_a_function): Update for
change of logical_location type.
(per_thread_summary::per_thread_summary): Pass in
"logical_loc_mgr".
(per_thread_summary::m_logical_loc_mgr): New field.
(event_range::m_logical_loc): Update for change of
logical_location type.
(path_summary::get_logical_location_manager): New accessor.
(path_summary::m_logical_loc_mgr): New field.
(path_summary::get_or_create_events_for_thread_id): Pass
m_logical_loc_mgr to per_thread_summary ctor.
(path_summary::path_summary): Initialize m_logical_loc_mgr.
(thread_event_printer::print_swimlane_for_event_range): Add param
"logical_loc_mgr". Update for change in logical_loc type.
(print_path_summary_as_text): Pass manager to
thread_event_printer::print_swimlane_for_event_range.
(diagnostic_text_output_format::print_path): Update for
introduction of logical_location_manager.
* diagnostic-path.h: Include "logical-location.h".
(class sarif_builder): New forward decl.
(diagnostic_event::get_logical_location): Convert return type from
"const logical_location *" to "logical_location".
(diagnostic_event::maybe_add_sarif_properties): Add sarif_builder
param.
(diagnostic_path::get_logical_location_manager): New accessor.
(diagnostic_path::diagnostic_path): New ctor, taking manager.
(diagnostic_path::m_logical_loc_mgr): New field.
* diagnostic.cc
(diagnostic_context::get_logical_location_manager): New.
(logical_location::function_p): Convert to...
(logical_location_manager::function_p): ...this.
* diagnostic.h (class logical_location): Replace forward decl
with...
(class logical_location_manager): ...this.
(diagnostic_context::get_logical_location_manager): New decl.
* lazy-diagnostic-path.cc
(selftest::test_lazy_path::test_lazy_path): Pass m_logical_loc_mgr
to path ctor.
(selftest::test_lazy_path::make_inner_path): Likewise.
(selftest::test_lazy_path::m_logical_loc_mgr): New field.
* lazy-diagnostic-path.h
(lazy_diagnostic_path::lazy_diagnostic_path): New ctor.
* libgdiagnostics.cc (struct diagnostic_logical_location): Convert
from subclass of logical_location to a plain struct, dropping
accessors.
(class impl_logical_location_manager): New.
(impl_diagnostic_client_data_hooks::get_logical_location_manager):
New
(impl_diagnostic_client_data_hooks::m_logical_location_manager):
New field.
(diagnostic_manager::get_logical_location_manager): New.
(libgdiagnostics_path_event::get_logical_location): Reimplement.
(diagnostic_execution_path::diagnostic_execution_path): Add
logical_loc_mgr and pass to base class.
(diagnostic_execution_path::same_function_p): Update for change to
logical_location type.
(diagnostic::add_execution_path): Pass logical_loc_mgr to path
ctor.
(impl_diagnostic_client_data_hooks::get_current_logical_location):
Reimplement.
(diagnostic_text_sink::text_starter): Reimplement printing of
logical location.
(diagnostic_manager::new_execution_path): Pass mgr to path ctor.
(diagnostic_manager_debug_dump_logical_location): Update for
changes to diagnostic_logical_location.
(diagnostic_logical_location_get_kind): Likewise.
(diagnostic_logical_location_get_parent): Likewise.
(diagnostic_logical_location_get_short_name): Likewise.
(diagnostic_logical_location_get_fully_qualified_name): Likewise.
(diagnostic_logical_location_get_decorated_name): Likewise.
* logical-location.h (class logical_location_manager): New.
(class logical_location): Convert to typedef of
logical_location_manager::key.
* selftest-diagnostic-path.cc
(selftest::test_diagnostic_path::test_diagnostic_path): Pass
m_test_logical_loc_mgr to base ctor.
(selftest::test_diagnostic_path::same_function_p): Use pointer
comparison.
(selftest::test_diagnostic_path::add_event): Use
logical_location_from_funcname.
(selftest::test_diagnostic_path::add_thread_event): Likewise.
(selftest::test_diagnostic_path::logical_location_from_funcname):
New.
(selftest::test_diagnostic_event::test_diagnostic_event): Fix
indentation. Pass logical_location rather than const char *.
* selftest-diagnostic-path.h
(selftest::test_diagnostic_event::test_diagnostic_event):
Likewise.
(selftest::test_diagnostic_event::get_logical_location): Update
for change to logical_location type.
(selftest::test_diagnostic_event::get_function_name): Drop.
(selftest::test_diagnostic_event::m_logical_loc): Convert from
test_logical_location to logical_location.
(selftest::test_diagnostic_path::logical_location_from_funcname):
New.
(selftest::test_diagnostic_path::m_test_logical_loc_mgr): New
field.
* selftest-logical-location.cc: Include "selftest.h".
(selftest::test_logical_location::test_logical_location): Drop.
(selftest::test_logical_location_manager::~test_logical_location_manager):
New.
(selftest::test_logical_location::get_short_name): Replace with...
(selftest::test_logical_location_manager::get_short_name):
...this.
(selftest::test_logical_location::get_name_with_scope): Replace
with...
(selftest::test_logical_location_manager::get_name_with_scope):
...this.
(selftest::test_logical_location::get_internal_name): Replace
with...
(selftest::test_logical_location_manager::get_internal_name):
...this.
(selftest::test_logical_location::get_kind): Replace with...
(selftest::test_logical_location_manager::get_kind): ...this.
(selftest::test_logical_location::get_name_for_path_output):
Replace with...
(selftest::test_logical_location_manager::get_name_for_path_output):
...this.
(selftest::test_logical_location_manager::logical_location_from_funcname):
New.
(selftest::test_logical_location_manager::item_from_funcname):
New.
(selftest::selftest_logical_location_cc_tests): New.
* selftest-logical-location.h (class test_logical_location):
Replace with...
(class test_logical_location_manager): ...this.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest_logical_location_cc_tests.
* selftest.h (selftest::selftest_logical_location_cc_tests): New
decl.
* simple-diagnostic-path.cc
(simple_diagnostic_path::simple_diagnostic_path): Add
"logical_loc_mgr" param and pass it to base ctor.
(simple_diagnostic_event::simple_diagnostic_event): Update init of
m_logical_loc.
(selftest::test_intraprocedural_path): Update for changes to
logical locations.
* simple-diagnostic-path.h: Likewise.
* tree-diagnostic-client-data-hooks.cc
(compiler_data_hooks::get_logical_location_manger): New.
(compiler_data_hooks::get_current_logical_location): Update.
(compiler_data_hooks::m_current_fndecl_logical_loc): Replace
with...
(compiler_data_hooks::m_logical_location_manager): ...this.
* tree-logical-location.cc
(compiler_logical_location::get_short_name_for_tree): Replace
with...
(tree_logical_location_manager::get_short_name): ...this.
(compiler_logical_location::get_name_with_scope_for_tree): Replace
with...
(tree_logical_location_manager::get_name_with_scope): ...this.
(compiler_logical_location::get_internal_name_for_tree): Replace
with...
(tree_logical_location_manager::get_internal_name): ...this.
(compiler_logical_location::get_kind_for_tree): Replace with...
(tree_logical_location_manager::get_kind): ...this.
(compiler_logical_location::get_name_for_tree_for_path_output):
Replace with...
(tree_logical_location_manager::get_name_for_path_output):
...this.
(tree_logical_location::get_short_name): Drop.
(tree_logical_location::get_name_with_scope): Drop.
(tree_logical_location::get_internal_name): Drop.
(tree_logical_location::get_kind): Drop.
(tree_logical_location::get_name_for_path_output): Drop.
(current_fndecl_logical_location::get_short_name): Drop.
(current_fndecl_logical_location::get_name_with_scope): Drop.
(current_fndecl_logical_location::get_internal_name): Drop.
(current_fndecl_logical_location::get_kind): Drop.
(current_fndecl_logical_location::get_name_for_path_output): Drop.
* tree-logical-location.h (class compiler_logical_location): Drop.
(class tree_logical_location): Drop.
(class current_fndecl_logical_location): Drop.
(class tree_logical_location_manager): New.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Update for
changes to simple_diagnostic_path.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
gcc/analyzer/ChangeLog:
* sm-malloc.cc (malloc_diagnostic::describe_state_change): Tweak
the "EXPR is NULL" message for the case where EXPR is a null
pointer.
gcc/testsuite/ChangeLog:
* c-c++-common/analyzer/data-model-path-1.c: Check for
"using NULL here" message.
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:
Likewise. Check for "return of NULL" message.
* c-c++-common/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c:
Likewise.
* gcc.dg/analyzer/data-model-5.c: Likewise.
* gcc.dg/analyzer/data-model-5b.c: Likewise.
* gcc.dg/analyzer/data-model-5c.c: Likewise.
* gcc.dg/analyzer/torture/pr93647.c: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
Having both an enum and a variable with the same name triggers an error with
gcc 5.
exploded-graph.h:351:29: error: ‘status’ is not a class, namespace, or enumeration
gcc/analyzer/ChangeLog:
* exploded-graph.h (set_status): Rename parameter.
* constraint-manager.cc (bound::ensure_closed): Likewise.
(range::add_bound): Likewise.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Reviewed-by: David Malcolm <dmalcolm@redhat.com>
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
|
|
|
|
The analyzer was issuing false warnings about uninitialized variables
in C++ in places where NRVO was marking DECL_RESULT with
DECL_BY_REFERENCE.
Fixed thusly.
gcc/analyzer/ChangeLog:
PR analyzer/111536
* engine.cc (maybe_update_for_edge): Update for new call_stmt
param to region_model::push_frame.
* program-state.cc (program_state::push_frame): Likewise.
* region-model.cc (region_model::update_for_gcall): Likewise.
(region_model::push_frame): Add "call_stmt" param.
Handle DECL_RESULT with DECL_BY_REFERENCE set on it by stashing
the region of the lhs of the call_stmt in the caller frame,
and writing a reference to it within the "result" in the callee
frame.
(region_model::pop_frame): Don't write back to the LHS for
DECL_BY_REFERENCE results.
(selftest::test_stack_frames): Update for new call_stmt param to
region_model::push_frame.
(selftest::test_get_representative_path_var): Likewise.
(selftest::test_state_merging): Likewise.
(selftest::test_alloca): Likewise.
* region-model.h (region_model::push_frame): Add "call_stmt"
param.
* region.cc: Include "tree-ssa.h".
(region::can_have_initial_svalue_p): Use ssa_defined_default_def_p
for ssa names, rather than special-casing it for just parameters.
This should now also cover DECL_RESULT with DECL_BY_REFERENCE and
hard registers.
* sm-signal.cc (update_model_for_signal_handler): Update for new
call_stmt param to region_model::push_frame.
* state-purge.cc (state_purge_per_decl::process_worklists):
Likewise.
gcc/testsuite/ChangeLog:
PR analyzer/111536
* c-c++-common/analyzer/hard-reg-1.c: New test.
* g++.dg/analyzer/nrvo-1.C: New test.
* g++.dg/analyzer/nrvo-2.C: New test.
* g++.dg/analyzer/nrvo-pr111536-1.C: New test.
* g++.dg/analyzer/nrvo-pr111536-1b.C: New test.
* g++.dg/analyzer/nrvo-pr111536-2.C: New test.
* g++.dg/analyzer/nrvo-pr111536-2b.C: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
gcc/analyzer/ChangeLog:
PR analyzer/109366
* region-model-manager.cc
(region_model_manager::maybe_fold_sub_svalue): Sub-values of zero
constants are zero.
gcc/testsuite/ChangeLog:
PR analyzer/109366
* g++.dg/analyzer/unique_ptr-1.C: New test.
* g++.dg/analyzer/unique_ptr-2.C: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
This patch adds initial support for exception-handling to -fanalyzer,
handling eh_dispatch for regions of type ERT_TRY and
ERT_ALLOWED_EXCEPTIONS. I haven't managed yet seen eh_dispatch for
regions of type ERT_CLEANUP and ERT_MUST_NOT_THROW in the analyzer; with
this patch it will ICE if it sees those.
Additionally, this patch only checks for exact matches of exception
types, rather than supporting subclasses and references. I'm deferring
fixing this for now whilst figuring out how best to interact with the C++
type system; I'm tracking it as PR analyzer/119697.
The patch adds event classes for throwing and catching exceptions, and
seems to generate readable warnings for the kinds of leak that might
occur due to trying to manage resources manually and forgetting about
exceptions; for example:
exception-leak-1.C: In function ‘int test()’:
exception-leak-1.C:7:9: warning: leak of ‘ptr’ [CWE-401] [-Wanalyzer-malloc-leak]
7 | throw 42;
| ^~
‘int test()’: events 1-3
5 | void *ptr = __builtin_malloc (1024);
| ~~~~~~~~~~~~~~~~~^~~~~~
| |
| (1) allocated here
6 |
7 | throw 42;
| ~~
| |
| (2) throwing exception of type ‘int’ here...
| (3) ⚠️ ‘ptr’ leaks here; was allocated at (1)
Although dynamic exception specifications are only available in C++14
and earlier, the need to support them meant it seemed relatively easy to
add a warning to check them, hence the patch adds a new warning
for code paths that throw an exception that doesn't match a dynamic
exception specification: -Wanalyzer-throw-of-unexpected-type.
gcc/analyzer/ChangeLog:
PR analyzer/97111
* analyzer.cc (is_cxa_throw_p): New.
(is_cxa_rethrow_p): New.
* analyzer.opt (Wanalyzer-throw-of-unexpected-type): New.
* analyzer.opt.urls: Regenerate.
* call-info.cc (custom_edge_info::create_enode): New.
* call-info.h (call_info::print): Drop "final".
(call_info::add_events_to_path): Likewise.
* checker-event.cc (event_kind_to_string): Add cases for
event_kind::catch_, event_kind::throw_, and event_kind::unwind.
(explicit_throw_event::print_desc): New.
(throw_from_call_to_external_fn_event::print_desc): New.
(unwind_event::print_desc): New.
* checker-event.h (enum class event_kind): Add catch_, throw_,
and unwind.
(class catch_cfg_edge_event): New.
(class throw_event): New.
(class explicit_throw_event): New.
(class throw_from_call_to_external_fn_event): New.
(class unwind_event): New.
* common.h (class eh_dispatch_cfg_superedge): New forward decl.
(class eh_dispatch_try_cfg_superedge): New forward decl.
(class eh_dispatch_allowed_cfg_superedge): New forward decl.
(custom_edge_info::create_enode): New vfunc decl.
(is_cxa_throw_p): New decl.
(is_cxa_rethrow_p): New decl.
* diagnostic-manager.cc
(diagnostic_manager::add_events_for_superedge): Special-case edges
for eh_dispach_try.
(diagnostic_manager::prune_path): Call consolidate_unwind_events.
(diagnostic_manager::prune_for_sm_diagnostic): Don't filter the new
event_kinds.
(diagnostic_manager::consolidate_unwind_events): New.
* diagnostic-manager.h
(diagnostic_manager::consolidate_unwind_events): New decl.
* engine.cc (exploded_node::on_stmt_pre): Handle "__cxa_throw",
"__cxa_rethrow", and resx statements.
(class throw_custom_edge): New.
(class unwind_custom_edge): New.
(get_eh_outedge): New.
(exploded_graph::unwind_from_exception): New.
(exploded_node::on_throw): New.
(exploded_node::on_resx): New.
(exploded_graph::get_or_create_node): Add "add_to_worklist" param
and use it.
(exploded_graph::process_node): Use edge_info's create_enode vfunc
to create enodes, rather than calling get_or_create_node directly.
Ignore CFG edges in the sgraph flagged with EH whilst we're
exploring the egraph.
(exploded_graph_annotator::print_enode): Handle case
exploded_node::status::special.
* exploded-graph.h (exploded_node::status): Add value "special".
(exploded_node::on_throw): New decl.
(exploded_node::on_resx): New decl.
(exploded_graph::get_or_create_node): Add optional
"add_to_worklist" param.
(exploded_graph::unwind_from_exception): New decl.
* kf-lang-cp.cc (class kf_cxa_allocate_exception): New.
(class kf_cxa_begin_catch): New.
(class kf_cxa_end_catch): New.
(class throw_of_unexpected_type): New.
(class kf_cxa_call_unexpected): New.
(register_known_functions_lang_cp): Register known functions
"__cxa_allocate_exception", "__cxa_begin_catch",
"__cxa_end_catch", and "__cxa_call_unexpected".
* kf.cc (class kf_eh_pointer): New.
(register_known_functions): Register it for BUILT_IN_EH_POINTER.
* region-model.cc: Include "analyzer/function-set.h".
(exception_node::operator==): New.
(exception_node::dump_to_pp): New.
(exception_node::dump): New.
(exception_node::to_json): New.
(exception_node::make_dump_widget): New.
(exception_node::maybe_get_type): New.
(exception_node::add_to_reachable_regions): New.
(region_model::region_model): Initialize
m_thrown_exceptions_stack and m_caught_exceptions_stack.
(region_model::operator=): Likewise.
(region_model::operator==): Compare them.
(region_model::dump_to_pp): Dump exception stacks.
(region_model::to_json): Add exception stacks.
(region_model::make_dump_widget): Likewise.
(class exception_thrown_from_unrecognized_call): New.
(get_fns_assumed_not_to_throw): New.
(can_throw_p): New.
(region_model::check_for_throw_inside_call): New.
(region_model::on_call_pre): Call check_for_throw_inside_call
on unknown fns or those we don't have a body for.
(region_model::maybe_update_for_edge): Handle eh_dispatch_stmt
statements. Drop old code that called
apply_constraints_for_exception on EDGE_EH edges.
(class rejected_eh_dispatch): New.
(exception_matches_type_p): New.
(matches_any_exception_type_p): New.
(region_model::apply_constraints_for_eh_dispatch): New.
(region_model::apply_constraints_for_eh_dispatch_try): New.
(region_model::apply_constraints_for_eh_dispatch_allowed): New.
(region_model::apply_constraints_for_exception): Delete.
(region_model::can_merge_with_p): Don't merge models with
non-equal exception stacks.
(region_model::get_referenced_base_regions): Add regions from
exception stacks.
* region-model.h (struct exception_node): New.
(region_model::push_thrown_exception): New.
(region_model::get_current_thrown_exception): New.
(region_model::pop_thrown_exception): New.
(region_model::push_caught_exception): New.
(region_model::get_current_caught_exception): New.
(region_model::pop_caught_exception): New.
(region_model::apply_constraints_for_eh_dispatch_try): New decl.
(region_model::apply_constraints_for_eh_dispatch_allowed) New decl.
(region_model::apply_constraints_for_exception): Delete.
(region_model::apply_constraints_for_eh_dispatch): New decl.
(region_model::check_for_throw_inside_call): New decl.
(region_model::m_thrown_exceptions_stack): New field.
(region_model::m_caught_exceptions_stack): New field.
* supergraph.cc: Include "except.h" and "analyzer/region-model.h".
(supergraph::add_cfg_edge): Special-case eh_dispatch edges.
(superedge::get_description): Use default_tree_printer.
(get_catch): New.
(eh_dispatch_cfg_superedge::make): New.
(eh_dispatch_cfg_superedge::eh_dispatch_cfg_superedge): New.
(eh_dispatch_cfg_superedge::get_eh_status): New.
(eh_dispatch_try_cfg_superedge::dump_label_to_pp): New.
(eh_dispatch_try_cfg_superedge::apply_constraints): New.
(eh_dispatch_allowed_cfg_superedge::eh_dispatch_allowed_cfg_superedge):
New.
(eh_dispatch_allowed_cfg_superedge::dump_label_to_pp): New.
(eh_dispatch_allowed_cfg_superedge::apply_constraints): New.
* supergraph.h: Include "except.h".
(superedge::dyn_cast_eh_dispatch_cfg_superedge): New vfunc.
(superedge::dyn_cast_eh_dispatch_try_cfg_superedge): New vfunc.
(superedge::dyn_cast_eh_dispatch_allowed_cfg_superedge): New
vfunc.
(class eh_dispatch_cfg_superedge): New.
(is_a_helper <const eh_dispatch_cfg_superedge *>::test): New.
(class eh_dispatch_try_cfg_superedge): New.
(is_a_helper <const eh_dispatch_try_cfg_superedge *>::test): New.
(class eh_dispatch_allowed_cfg_superedge): New.
(is_a_helper <const eh_dispatch_allowed_cfg_superedge *>::test):
New.
* svalue.cc (svalue::maybe_get_type_from_typeinfo): New.
* svalue.h (svalue::maybe_get_type_from_typeinfo): New decl.
gcc/ChangeLog:
PR analyzer/97111
* doc/invoke.texi: Add -Wanalyzer-throw-of-unexpected-type.
* gimple.h (gimple_call_nothrow_p): Make arg const.
gcc/testsuite/ChangeLog:
PR analyzer/97111
* c-c++-common/analyzer/analyzer-verbosity-2a.c: Add
-fno-exceptions.
* c-c++-common/analyzer/analyzer-verbosity-3a.c: Likewise.
* c-c++-common/analyzer/attr-const-2.c: Add
__attribute__((nothrow)).
* c-c++-common/analyzer/attr-malloc-4.c: Likewise.
* c-c++-common/analyzer/attr-malloc-5.c: Likewise.
* c-c++-common/analyzer/attr-malloc-6.c: Add -fno-exceptions.
* c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c:
Likewise.
* c-c++-common/analyzer/attr-malloc-exception.c: New test.
* c-c++-common/analyzer/call-summaries-pr107158-2.c: Add
-fno-exceptions.
* c-c++-common/analyzer/call-summaries-pr107158.c: Likewise.
* c-c++-common/analyzer/capacity-2.c: Likewise.
* c-c++-common/analyzer/coreutils-sum-pr108666.c: Likewise.
* c-c++-common/analyzer/data-model-22.c: Likewise.
* c-c++-common/analyzer/data-model-5d.c: Likewise.
* c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c:
Likewise.
* c-c++-common/analyzer/deref-before-check-pr108475-haproxy-tcpcheck.c:
Likewise.
* c-c++-common/analyzer/edges-2.c: Likewise.
* c-c++-common/analyzer/fd-2.c: Likewise.
* c-c++-common/analyzer/fd-3.c: Likewise.
* c-c++-common/analyzer/fd-meaning.c: Likewise.
* c-c++-common/analyzer/file-1.c: Likewise.
* c-c++-common/analyzer/file-3.c: Likewise.
* c-c++-common/analyzer/file-meaning-1.c: Likewise.
* c-c++-common/analyzer/infinite-recursion.c: Likewise.
* c-c++-common/analyzer/leak-3.c: Likewise.
* c-c++-common/analyzer/malloc-dedupe-1.c: Likewise.
* c-c++-common/analyzer/malloc-in-loop.c: Likewise.
* c-c++-common/analyzer/malloc-many-paths-3.c: Likewise.
* c-c++-common/analyzer/malloc-paths-5.c: Likewise.
* c-c++-common/analyzer/malloc-paths-7.c: Likewise.
* c-c++-common/analyzer/malloc-paths-8.c: Likewise.
* c-c++-common/analyzer/malloc-vs-local-1a.c: Likewise.
* c-c++-common/analyzer/malloc-vs-local-2.c: Likewise.
* c-c++-common/analyzer/malloc-vs-local-3.c: Likewise.
* c-c++-common/analyzer/paths-7.c: Likewise.
* c-c++-common/analyzer/pr110830.c: Likewise.
* c-c++-common/analyzer/pr93032-mztools-simplified.c: Likewise.
* c-c++-common/analyzer/pr93355-localealias-feasibility-3.c:
Likewise.
* c-c++-common/analyzer/pr93355-localealias-simplified.c:
Likewise.
* c-c++-common/analyzer/pr96650-1-trans.c: Likewise.
* c-c++-common/analyzer/pr97072.c: Add __attribute__((nothrow)).
* c-c++-common/analyzer/pr98575-1.c: Likewise.
* c-c++-common/analyzer/pr99716-1.c: Add -fno-exceptions.
* c-c++-common/analyzer/pr99716-2.c: Likewise.
* c-c++-common/analyzer/pr99716-3.c: Likewise.
* c-c++-common/analyzer/pragma-2.c: Likewise.
* c-c++-common/analyzer/rhbz1878600.c: Likewise.
* c-c++-common/analyzer/strndup-1.c: Likewise.
* c-c++-common/analyzer/write-to-string-literal-4-disabled.c:
Likewise.
* c-c++-common/analyzer/write-to-string-literal-4.c: Likewise.
* c-c++-common/analyzer/write-to-string-literal-5.c: Likewise.
* c-c++-common/analyzer/zlib-5.c: Likewise.
* g++.dg/analyzer/exception-could-throw-1.C: New test.
* g++.dg/analyzer/exception-could-throw-2.C: New test.
* g++.dg/analyzer/exception-dynamic-spec.C: New test.
* g++.dg/analyzer/exception-leak-1.C: New test.
* g++.dg/analyzer/exception-leak-2.C: New test.
* g++.dg/analyzer/exception-leak-3.C: New test.
* g++.dg/analyzer/exception-leak-4.C: New test.
* g++.dg/analyzer/exception-leak-5.C: New test.
* g++.dg/analyzer/exception-leak-6.C: New test.
* g++.dg/analyzer/exception-nothrow.C: New test.
* g++.dg/analyzer/exception-path-1.C: New test.
* g++.dg/analyzer/exception-path-catch-all-1.C: New test.
* g++.dg/analyzer/exception-path-catch-all-2.C: New test.
* g++.dg/analyzer/exception-path-unwind-multiple-2.C: New test.
* g++.dg/analyzer/exception-path-unwind-multiple.C: New test.
* g++.dg/analyzer/exception-path-unwind-single.C: New test.
* g++.dg/analyzer/exception-path-with-cleanups.C: New test.
* g++.dg/analyzer/exception-rethrow-1.C: New test.
* g++.dg/analyzer/exception-rethrow-2.C: New test.
* g++.dg/analyzer/exception-stack-1.C: New test.
* g++.dg/analyzer/exception-stack-2.C: New test.
* g++.dg/analyzer/exception-subclass-1.C: New test.
* g++.dg/analyzer/exception-subclass-2.C: New test.
* g++.dg/analyzer/exception-value-1.C: New test.
* g++.dg/analyzer/exception-value-2.C: New test.
* g++.dg/analyzer/fno-exception.C: New test.
* g++.dg/analyzer/pr94028.C: Drop xfail.
* g++.dg/analyzer/std-unexpected.C: New test.
* g++.dg/coroutines/pr105287.C: Drop dg-excess-errors.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
C++11 does not provide a std::make_unique so in
r13-3627-g00d7c8ff16e683 I added a make-unique.h
declaring a ::make_unique.
As of r15-4719-ga9ec1bc06bd3cc we can use C++14, so make-unique.h is no
longer needed: we can use simply use std::make_unique instead.
This patch removes make-unique.h and updates every place using it
to use std::make_unique.
No functional change intended.
gcc/analyzer/ChangeLog:
* access-diagram.cc: Replace uses of ::make_unique with
std::make_unique.
* analyzer.cc: Likewise.
* bounds-checking.cc: Likewise.
* call-details.cc: Likewise.
* call-info.cc: Likewise.
* call-string.cc: Likewise.
* checker-path.cc: Likewise.
* common.h: Drop include of "make-unique.h".
* constraint-manager.cc: Replace uses of ::make_unique with
std::make_unique.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* infinite-loop.cc: Likewise.
* infinite-recursion.cc: Likewise.
* kf-analyzer.cc: Likewise.
* kf-lang-cp.cc: Likewise.
* kf.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* program-point.cc: Likewise; drop #include.
* program-state.cc: Likewise.
* ranges.cc: Likewise.
* region-model.cc: Likewise.
* region.cc: Likewise; drop #include.
* 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.
* sm.cc: Likewise.
* store.cc: Likewise.
* supergraph.cc: Likewise.
* svalue.cc: Likewise; drop #include.
* varargs.cc: Likewise.
gcc/c-family/ChangeLog:
* c-pretty-print.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
gcc/c/ChangeLog:
* c-decl.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
* c-objc-common.cc: Likewise.
* c-parser.cc: Likewise.
gcc/cp/ChangeLog:
* cxx-pretty-print.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
* error.cc: Likewise.
* name-lookup.cc: Likewise.
* parser.cc: Likewise.
gcc/ChangeLog:
* diagnostic-format-json.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-text.cc: Likewise.
* diagnostic.cc: Likewise.
* dumpfile.cc: Likewise.
* gcc-attribute-urlifier.cc: Likewise.
* gcc-urlifier.cc: Likewise.
* json-parsing.cc: Likewise.
* json.cc: Likewise.
* lazy-diagnostic-path.cc: Likewise.
* libgdiagnostics.cc: Likewise.
* libsarifreplay.cc: Likewise.
* lto-wrapper.cc: Likewise.
* make-unique.h: Delete.
* opts-diagnostic.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
* pretty-print.cc: Likewise.
* text-art/style.cc: Likewise.
* text-art/styled-string.cc: Likewise.
* text-art/table.cc: Likewise.
* text-art/tree-widget.cc: Likewise.
* text-art/widget.cc: Likewise.
* timevar.cc: Likewise.
* toplev.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
gcc/jit/ChangeLog:
* dummy-frontend.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Drop include of
"make-unique.h". Replace uses of ::make_unique with
std::make_unique.
* gcc.dg/plugin/analyzer_gil_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
gcc/analyzer/ChangeLog:
* engine.cc (class plugin_analyzer_init_impl): Convert
"m_checkers" to use std::vector of std::unique_ptr. Convert
"m_known_fn_mgr" to a reference.
(impl_run_checkers): Convert "checkers" to use std::vector of
std::unique_ptr and move it into the extrinsic_state.
* program-state.cc (extrinsic_state::dump_to_pp): Update for
changes to m_checkers.
(extrinsic_state::to_json): Likewise.
(extrinsic_state::get_sm_idx_by_name): Likewise.
(selftest::test_sm_state_map): Update to use std::unique_ptr
for state machines.
(selftest::test_program_state_1): Likewise.
(selftest::test_program_state_2): Likewise.
(selftest::test_program_state_merging): Likewise.
(selftest::test_program_state_merging_2): Likewise.
* program-state.h (class extrinsic_state): Convert "m_checkers" to
use std::vector of std::unique_ptr and to be owned by this object,
rather than a reference. Add ctor for use in selftests.
* sm-fd.cc (make_fd_state_machine): Update to use std::unique_ptr.
* sm-file.cc (make_fileptr_state_machine): Likewise.
* sm-malloc.cc (make_malloc_state_machine): Likewise.
* sm-pattern-test.cc (make_pattern_test_state_machine): Likewise.
* sm-sensitive.cc (make_sensitive_state_machine): Likewise.
* sm-signal.cc (make_signal_state_machine): Likewise.
* sm-taint.cc (make_taint_state_machine): Likewise.
* sm.cc: Define INCLUDE_LIST.
(make_checkers): Return the vector directly, rather than pass it
in by reference. Update to use std::unique_ptr throughout. Use
an intermediate list, and use that to filter with
flag_analyzer_checker, fixing memory leak for this case.
* sm.h: (make_checkers): Return the vector directly, rather than
pass it in by reference, and use std::vector of std::unique_ptr.
(make_malloc_state_machine): Convert return type to use std::unique_ptr.
(make_fileptr_state_machine): Likewise.
(make_taint_state_machine): Likewise.
(make_sensitive_state_machine): Likewise.
(make_signal_state_machine): Likewise.
(make_pattern_test_state_machine): Likewise.
(make_va_list_state_machine): Likewise.
(make_fd_state_machine): Likewise.
* varargs.cc (make_va_list_state_machine): Update to use
std::unique_ptr.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
No functional change intended.
gcc/analyzer/ChangeLog:
* call-summary.cc (call_summary_replay::call_summary_replay):
Convert "summary" from call_summary * to call_summary &.
(call_summary_replay::dump_to_pp): Likewise for m_summary.
* call-summary.h (call_summary_replay::call_summary_replay):
Likewise for "summary".
(call_summary_replay::m_summary): Likewise.
* engine.cc (call_summary_edge_info::call_summary_edge_info):
Likewise.
(call_summary_edge_info::update_state): Likewise.
(call_summary_edge_info::update_model): Likewise.
(call_summary_edge_info::print_desc): Likewise for m_summary.
(call_summary_edge_info::m_summary): Likewise.
(exploded_node::replay_call_summaries): Update for change to
replay_call_summary.
(exploded_node::replay_call_summary): Convert "summary" from
call_summary * to call_summary &.
* exploded-graph.h (exploded_node::replay_call_summary): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
No functional change intended.
gcc/analyzer/ChangeLog:
* analyzer.cc: Convert gcall * to gcall & where we know the
pointer must be non-null.
* call-details.cc: Likewise.
* call-details.h: Likewise.
* call-info.cc: Likewise.
* call-info.h: Likewise.
* call-summary.h: Likewise.
* checker-event.cc: Likewise.
* checker-event.h: Likewise.
* common.h: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* exploded-graph.h: Likewise.
* kf-analyzer.cc: Likewise.
* kf-lang-cp.cc: Likewise.
* kf.cc: Likewise.
* known-function-manager.cc: Likewise.
* program-state.cc: Likewise.
* program-state.h: Likewise.
* region-model.cc: Likewise.
* region-model.h: Likewise.
* sm-fd.cc: Likewise.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* sm.h: Likewise.
* store.cc: Likewise.
* store.h: Likewise.
* supergraph.cc: Likewise.
* supergraph.h: Likewise.
* svalue.h: Likewise.
* varargs.cc: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.cc: Convert gcall * to gcall &
where we know the pointer must be non-null.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Modernization; no functional change intended.
gcc/analyzer/ChangeLog:
* access-diagram.cc: Convert enum access_direction to
"enum class".
* bounds-checking.cc: Likewise.
* checker-event.cc: Convert enum event_kind to "enum class".
* checker-event.h: Likewise.
* checker-path.cc: Likewise.
* common.h: Convert enum access_direction to "enum class".
* constraint-manager.cc: Convert enum bound_kind to "enum class".
* constraint-manager.h: Likewise.
* diagnostic-manager.cc: Convert enum event_kind to "enum class".
* engine.cc: Convert enum status to "enum class".
* exploded-graph.h: Likewise.
* infinite-loop.cc: Likewise.
* kf-lang-cp.cc: Convert enum poison_kind to "enum class".
* kf.cc: Likewise.
* region-model-manager.cc: Likewise.
* region-model.cc: Likewise; also for enum access_direction.
* svalue.cc: Likewise.
* svalue.h: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Convert
enum poison_kind to "enum class".
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Our headers are a major pain to work with: many require certain other
headers to be included in a particular (undocumented) order in order
to be includable.
Simplify includes in the analyzer by renaming analyzer/analyzer.h to
analyzer/common.h and have it include all the common headers needed
throughout the analyzer, thus encapsulating the rules about e.g. being
able to include "gimple.h" in one place in the analyzer subdirectory.
Doing so also makes it easier to e.g. define INCLUDE_SET in one place,
rather than in many source files.
gcc/analyzer/ChangeLog:
* analyzer.h: Rename to...
* common.h: ...this. Add define of INCLUDE_VECTOR, includes of
"config.h", "system.h", "coretypes.h", "make-unique.h", "tree.h",
"function.h", "basic-block.h", "gimple.h", "options.h",
"bitmap.h", "diagnostic-core.h", and "diagnostic-path.h".
* access-diagram.h: Don't include "analyzer/analyzer.h".
* access-diagram.cc: Reorganize includes to #include
"analyzer/common.h" first, then group by subsystem, dropping
redundant headers.
* analysis-plan.cc: Likewise.
* analyzer-language.cc: Likewise.
* analyzer-pass.cc: Likewise.
* analyzer-selftests.cc: Likewise.
* analyzer.cc: Likewise.
* bounds-checking.cc: Likewise.
* call-details.cc: Likewise.
* call-info.cc: Likewise.
* call-string.cc: Likewise.
* call-summary.cc: Likewise.
* checker-event.cc: Likewise.
* checker-path.cc: Likewise.
* complexity.cc: Likewise.
* constraint-manager.cc: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* feasible-graph.cc: Likewise.
* infinite-loop.cc: Likewise.
* infinite-recursion.cc: Likewise.
* kf-analyzer.cc: Likewise.
* kf-lang-cp.cc: Likewise.
* kf.cc: Likewise.
* known-function-manager.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* program-point.cc: Likewise.
* program-state.cc: Likewise.
* ranges.cc: Likewise.
* record-layout.cc: Likewise.
* region-model-asm.cc: Likewise.
* region-model-manager.cc: Likewise.
* region-model-reachability.cc: Likewise.
* region-model.cc: Likewise.
* region.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.
* sm.cc: Likewise.
* state-purge.cc: Likewise.
* store.cc: Likewise.
* supergraph.cc: Likewise.
* svalue.cc: Likewise.
* symbol.cc: Likewise.
* trimmed-graph.cc: Likewise.
* varargs.cc: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Update for renaming
of analyzer/analyzer.h to analyzer/common.h.
* gcc.dg/plugin/analyzer_gil_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
gcc/analyzer/ChangeLog:
* region-model.cc (region_model::on_stmt_pre): Use internal_error
if we see an unexpected gimple stmt code.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Add a new function to help debugging -fanalyzer.
No functional change intended.
gcc/analyzer/ChangeLog:
* call-details.cc (call_details::dump): New overload.
(call_details::make_dump_widget): New.
* call-details.h (call_details::dump): Declare new overload.
(call_details::make_dump_widget): New decl.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
The following testcase ICEs in cmp_csts_same_type because RAW_DATA_CST
isn't handled there. As TREE_TYPE (cst1) in that case is INTEGER_TYPE,
e.g. char/signed char/unsigned char, the type itself doesn't imply
the size, so the length is compared first, followed by comparing the
data.
While at it, I've noticed STRING_CST handling is wrong, because STRING_CST
can represent even string literals with embedded nul characters.
We shouldn't stop at those, hence memcmp.
While for STRING_CST TREE_TYPE should likely already imply the length
and so same type should imply same TREE_STRING_LENGTH, I've repeated
the comparisons in there just in case.
2025-03-14 Jakub Jelinek <jakub@redhat.com>
PR analyzer/119278
* svalue.cc (cmp_csts_same_type): For STRING_CST, compare
TREE_STRING_LENGTH first just in case and use memcmp rather
than strcmp. Handle RAW_DATA_CST.
* c-c++-common/analyzer/pr119278.c: New test.
|
|
|
|
gcc/analyzer/ChangeLog:
PR analyzer/117262
* region-model-manager.cc
(region_model_manager::get_or_create_constant_svalue): Use
NULL_TREE for the types of constant_svalue for RAW_DATA_CST.
(region_model_manager::maybe_fold_sub_svalue): Generalize
STRING_CST logic to also handle RAW_DATA_CST.
(region_model_manager::maybe_get_char_from_cst): New.
(region_model_manager::maybe_get_char_from_raw_data_cst): New.
* region-model-manager.h
(region_model_manager::maybe_get_char_from_cst): New decl.
(region_model_manager::maybe_get_char_from_raw_data_cst): New decl.
* region-model.cc (region_model::get_rvalue_1): Handle
RAW_DATA_CST.
* store.cc (get_subregion_within_ctor_for_ctor_pair): New.
(binding_map::apply_ctor_pair_to_child_region): Call
get_subregion_within_ctor_for_ctor_pair so that we handle
RAW_DATA_CST.
gcc/testsuite/ChangeLog:
PR analyzer/117262
* c-c++-common/analyzer/raw-data-cst-pr117262-1.c: New test.
* c-c++-common/analyzer/raw-data-cst-pr117262-2.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
On top of the
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668554.html
patch which introduces the nonnull_if_nonzero attribute (because
C2Y is allowing NULL arguments on various calls like memcpy, memset,
strncpy etc. as long as the count is 0) the following patch adds just
limited handling of the attribute in the analyzer.
For nonnull attribute(s) we have the get_nonnull_args helper which
returns a bitmap, for nonnull_if_nonzero a function would need to
return a hash_map or something similar, I think it is better to
handle the attributes one by one. This patch just handles the
non-zero INTEGER_CST (integer_nonzerop) count arguments, in other places
the above patch uses ranger to some extent, but I'm not familiar enough
with the analyzer to know if one can use the ranger, or should somehow
explain in data structures the conditional nature of the nonnull property,
the argument is nonnull only if some other argument is nonzero.
Also, analyzer uses get_nonnull_args in another spot when entering a frame,
not sure if anything can be done there (note the conditional nonnull
somehow, pass from callers if the argument is nonzero, ...).
Note, the testsuite changes aren't strictly necessary with just
the above and this patch, but will be with a patch I'm going to post
soon.
2025-02-24 Jakub Jelinek <jakub@redhat.com>
PR c/117023
gcc/analyzer/
* sm-malloc.cc (malloc_state_machine::handle_nonnull): New private
method.
(malloc_state_machine::on_stmt): Use it for nonnull attribute arguments.
Handle also nonnull_if_nonzero attributes.
gcc/testsuite/
* c-c++-common/analyzer/call-summaries-malloc.c
(test_use_without_check): Pass 4 rather than sz to memset.
* c-c++-common/analyzer/strncpy-1.c (test_null_dst,
test_null_src): Pass 42 rather than count to strncpy.
|
|
|
|
Previously the analyzer treated IFN_UBSAN_BOUNDS as a no-op, but
the other IFN_UBSAN_* were unrecognized and conservatively treated
as having arbitrary behavior.
Treat IFN_UBSAN_NULL and IFN_UBSAN_PTR also as no-ops, which should
make -fanalyzer behave better with -fsanitize=undefined.
gcc/analyzer/ChangeLog:
PR analyzer/118300
* kf.cc (class kf_ubsan_bounds): Replace this with...
(class kf_ubsan_noop): ...this.
(register_sanitizer_builtins): Use it to handle IFN_UBSAN_NULL,
IFN_UBSAN_BOUNDS, and IFN_UBSAN_PTR as nop-ops.
(register_known_functions): Drop handling of IFN_UBSAN_BOUNDS
here, as it's now handled by register_sanitizer_builtins above.
gcc/testsuite/ChangeLog:
PR analyzer/118300
* gcc.dg/analyzer/ubsan-pr118300.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|