mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 03:47:02 -05:00
diagnostics: introduce namespace diagnostics::paths
Move more diagnostic-specific code from gcc/ to gcc/diagnostics/ No functional change intended. contrib/ChangeLog: * filter-clang-warnings.py: Update for move of diagnostic-path-output.cc to diagnostics/paths-output.cc. gcc/ChangeLog: * Makefile.in (OBJS): Replace lazy-diagnostic-path.o with diagnostics/lazy-paths.o. (OBJS-libcommon): Replace diagnostic-path.o with diagnostics/paths.o, diagnostic-path-output.o with diagnostics/paths-output.o, and selftest-diagnostic-path.o with diagnostics/selftest-paths.o. (EXTRA_BACKEND_OBJS): Replace lazy-diagnostic-path.o with diagnostics/lazy-paths.o. * diagnostic-format-html.cc: Update #include for "diagnostic-path.h" moving to "diagnostics/paths.h", diagnostic_thread_id_t to diagnostics::paths::thread_id_t, diagnostic_event_id_t to diagnostics::paths::event_id_t, diagnostic_path to diagnostics::paths::path, and diagnostic_thread to diagnostics::paths::thread, and diagnostic_event to diagnostics::paths::event. * diagnostic-format-html.h: Likewise. * diagnostic-format-sarif.cc: Likewise. Update PROPERTY_PREFIX for threadFlowLocations from "gcc/diagnostic_event/" to "gcc/diagnostics/paths/event/". * diagnostic-format-text.cc: Likewise. * diagnostic-format-text.h: Likewise. * diagnostic.cc: Likewise. * diagnostic.h: Likewise. * diagnostic-event-id.h: Move to... * diagnostics/event-id.h: ...here, updating header guard. (diagnostics:paths:event_id_t): New typedef. (diagnostic_thread_id_t): Replace with... (diagnostics:paths:thread_id_t): New typedef. * lazy-diagnostic-path.cc: Move to... * diagnostics/lazy-paths.cc: ...here. Update for above changes, lazy_diagnostic_path becomes diagnostics::paths::lazy_path. (lazy_diagnostic_path_cc_tests): Rename to... (diagnostics_lazy_paths_cc_tests): ...this. * lazy-diagnostic-path.h: Move to... * diagnostics/lazy-paths.h: ...here, updating header guard. Update for above changes. * diagnostic-path-output.cc: Move to... * diagnostics/paths-output.cc: ...here. Update for above changes. (diagnostic_path_output_cc_tests): Rename to... (diagnostics_paths_output_cc_tests): ...this. * diagnostic-path.cc: Move to... * diagnostics/paths.cc: ...here. Update for above changes. * diagnostic-path.h: Move to... * diagnostics/paths.h: ...here, updating header guard. Update #include for moving "diagnostic-event-id.h" to "diagnostics/event-id.h". (class diagnostic_event): Convert to... (class diagnostics::paths::event): ...this. (class diagnostic_thread): Convert to... (class diagnostics::paths::thread): ...this. (class diagnostic_path): Convert to... (class diagnostics::paths::path): ...this. * diagnostic-show-locus.cc: Update for above changes. * doc/analyzer.texi: Likewise. * selftest-diagnostic-path.cc: Move to... * diagnostics/selftest-paths.cc: ...here. Update for above changes, and for "selftest-diagnostic-path.h" moving to "diagnostics/selftest-paths.h". * selftest-diagnostic-path.h: Move to... * diagnostics/selftest-paths.h: ...here, updating header guard. Update for above changes. * libgdiagnostics.cc: Update for above changes. * libsarifreplay.cc: Update property prefix for threadFlowLocations from "gcc/diagnostic_event/" to "gcc/diagnostics/paths/event/". * pretty-print-format-impl.h: Update for above changes. * pretty-print.cc: Likewise. * selftest-run-tests.cc (selftest::run_tests): Update for renaming of lazy_diagnostic_path_cc_tests to diagnostics_lazy_paths_cc_tests, and of diagnostic_path_output_cc_tests to diagnostics_paths_output_cc_tests. * selftest.h (lazy_diagnostic_path_cc_tests): Replace decl with... (diagnostics_lazy_paths_cc_tests): ...this. (diagnostic_path_output_cc_tests): Replace decl with... (diagnostics_paths_output_cc_tests): ...this. * simple-diagnostic-path.cc: Clarify that this relates to "tree" and thus shouldn't be in "diagnostics". Update for above changes. * simple-diagnostic-path.h: Likewise. gcc/analyzer/ChangeLog: * access-diagram.cc: Update for changes to diagnostic paths: "diagnostic-path.h" moving to "diagnostics/paths.h", "diagnostic-event-id.h" moving to "diagnostics/event-id.h", diagnostic_event_id_t to diagnostics::paths::event_id_t, diagnostic_path to diagnostics::paths::path, and diagnostic_event to diagnostics::paths::event. * access-diagram.h: Likewise. * analyzer.cc: Likewise. * bounds-checking.cc: Likewise. * call-info.cc: Likewise. * checker-event.cc: Likewise. * checker-event.h: Likewise. * checker-path.cc: Likewise. * checker-path.h: Likewise. * common.h: Likewise. * diagnostic-manager.cc: Likewise. * pending-diagnostic.cc: Likewise. * pending-diagnostic.h: Likewise. * program-point.cc: Likewise. * program-state.cc: Likewise. * region-model.cc: Likewise. * sm-fd.cc: Likewise. * sm-file.cc: Likewise. * sm-malloc.cc: Likewise. * sm-pattern-test.cc: Likewise. * sm-sensitive.cc: Likewise. * sm-signal.cc: Likewise. * sm-taint.cc: Likewise. * varargs.cc: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/analyzer_gil_plugin.cc: Update #include for "diagnostic-path.h" moving to "diagnostics/paths.h", diagnostic_thread_id_t to diagnostics::paths::thread_id_t, diagnostic_event_id_t to diagnostics::paths::event_id_t, diagnostic_path to diagnostics::paths::path, and diagnostic_thread to diagnostics::paths::thread, and diagnostic_event to diagnostics::paths::event. * gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise. * lib/sarif.py (get_state_graph): Update property prefix for threadFlowLocations from "gcc/diagnostic_event/" to "gcc/diagnostics/paths/event/". * gcc.dg/sarif-output/include-chain-2.h: Update comment. libcpp/ChangeLog: * include/rich-location.h: Replace diagnostic_path with diagnostics::paths::path. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
@@ -46,7 +46,7 @@ def skip_warning(filename, message):
|
||||
'-Wunused-function', '-Wunneeded-internal-declaration',
|
||||
'-Wvla-cxx-extension', '-Wunused-command-line-argument'],
|
||||
|
||||
'diagnostic-path-output.cc': ['m_logical_loc_mgr'],
|
||||
'diagnostics/paths-output.cc': ['m_logical_loc_mgr'],
|
||||
'fold-const-call.cc': ['-Wreturn-type'],
|
||||
'gimple-match': ['-Wunused-', '-Wtautological-compare'],
|
||||
'generic-match': ['-Wunused-', '-Wtautological-compare'],
|
||||
|
||||
@@ -1454,6 +1454,7 @@ OBJS = \
|
||||
df-problems.o \
|
||||
df-scan.o \
|
||||
dfp.o \
|
||||
diagnostics/lazy-paths.o \
|
||||
digraph.o \
|
||||
dojump.o \
|
||||
dominance.o \
|
||||
@@ -1595,7 +1596,6 @@ OBJS = \
|
||||
jump.o \
|
||||
langhooks.o \
|
||||
late-combine.o \
|
||||
lazy-diagnostic-path.o \
|
||||
lcm.o \
|
||||
lists.o \
|
||||
loop-doloop.o \
|
||||
@@ -1858,15 +1858,16 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
|
||||
diagnostic-format-text.o \
|
||||
diagnostic-global-context.o \
|
||||
diagnostic-macro-unwinding.o \
|
||||
diagnostic-path.o \
|
||||
diagnostic-path-output.o \
|
||||
diagnostic-show-locus.o \
|
||||
diagnostics/digraphs.o \
|
||||
diagnostics/edit-context.o \
|
||||
diagnostics/output-spec.o \
|
||||
diagnostics/paths.o \
|
||||
diagnostics/paths-output.o \
|
||||
diagnostics/state-graphs.o \
|
||||
diagnostics/state-graphs-to-dot.o \
|
||||
diagnostics/selftest-logical-locations.o \
|
||||
diagnostics/selftest-paths.o \
|
||||
graphviz.o pex.o \
|
||||
pretty-print.o intl.o \
|
||||
json.o json-parsing.o \
|
||||
@@ -1874,7 +1875,6 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
|
||||
sbitmap.o \
|
||||
vec.o input.o hash-table.o ggc-none.o memory-block.o \
|
||||
selftest.o selftest-diagnostic.o sort.o \
|
||||
selftest-diagnostic-path.o \
|
||||
selftest-json.o \
|
||||
text-art/box-drawing.o \
|
||||
text-art/canvas.o \
|
||||
@@ -1922,7 +1922,7 @@ endif
|
||||
|
||||
# libbackend.a objs that might not be in some cases linked into the compiler,
|
||||
# yet they are supposed to be part of the plugin ABI. See PR116143.
|
||||
EXTRA_BACKEND_OBJS = simple-diagnostic-path.o lazy-diagnostic-path.o
|
||||
EXTRA_BACKEND_OBJS = simple-diagnostic-path.o diagnostics/lazy-paths.o
|
||||
|
||||
BACKEND = $(EXTRA_BACKEND_OBJS) libbackend.a main.o libcommon-target.a \
|
||||
libcommon.a $(CPPLIB) $(LIBDECNUMBER)
|
||||
|
||||
@@ -1300,7 +1300,7 @@ class valid_region_spatial_item : public spatial_item
|
||||
{
|
||||
public:
|
||||
valid_region_spatial_item (const access_operation &op,
|
||||
diagnostic_event_id_t region_creation_event_id,
|
||||
diagnostics::paths::event_id_t region_creation_event_id,
|
||||
const theme &theme)
|
||||
: m_op (op),
|
||||
m_region_creation_event_id (region_creation_event_id),
|
||||
@@ -1523,7 +1523,7 @@ public:
|
||||
|
||||
private:
|
||||
const access_operation &m_op;
|
||||
diagnostic_event_id_t m_region_creation_event_id;
|
||||
diagnostics::paths::event_id_t m_region_creation_event_id;
|
||||
mutable const boundaries *m_boundaries;
|
||||
const svalue *m_existing_sval;
|
||||
std::unique_ptr<spatial_item> m_existing_sval_spatial_item;
|
||||
@@ -2012,7 +2012,7 @@ class access_diagram_impl : public vbox_widget
|
||||
{
|
||||
public:
|
||||
access_diagram_impl (const access_operation &op,
|
||||
diagnostic_event_id_t region_creation_event_id,
|
||||
diagnostics::paths::event_id_t region_creation_event_id,
|
||||
style_manager &sm,
|
||||
const theme &theme,
|
||||
logger *logger)
|
||||
@@ -2564,7 +2564,7 @@ private:
|
||||
}
|
||||
|
||||
const access_operation &m_op;
|
||||
diagnostic_event_id_t m_region_creation_event_id;
|
||||
diagnostics::paths::event_id_t m_region_creation_event_id;
|
||||
style_manager &m_sm;
|
||||
const theme &m_theme;
|
||||
logger *m_logger;
|
||||
@@ -2662,7 +2662,7 @@ direction_widget::paint_to_canvas (canvas &canvas)
|
||||
an access_diagram_impl. */
|
||||
|
||||
access_diagram::access_diagram (const access_operation &op,
|
||||
diagnostic_event_id_t region_creation_event_id,
|
||||
diagnostics::paths::event_id_t region_creation_event_id,
|
||||
style_manager &sm,
|
||||
const theme &theme,
|
||||
logger *logger)
|
||||
|
||||
@@ -152,7 +152,7 @@ class access_diagram : public text_art::wrapper_widget
|
||||
{
|
||||
public:
|
||||
access_diagram (const access_operation &op,
|
||||
diagnostic_event_id_t region_creation_event_id,
|
||||
diagnostics::paths::event_id_t region_creation_event_id,
|
||||
text_art::style_manager &sm,
|
||||
const text_art::theme &theme,
|
||||
logger *logger);
|
||||
|
||||
@@ -21,7 +21,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "tree-pretty-print.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "tree-dfa.h"
|
||||
#include "intl.h"
|
||||
|
||||
@@ -232,7 +232,7 @@ tree_to_json (tree node)
|
||||
for unknown). */
|
||||
|
||||
std::unique_ptr<json::value>
|
||||
diagnostic_event_id_to_json (const diagnostic_event_id_t &event_id)
|
||||
diagnostic_event_id_to_json (const diagnostics::paths::event_id_t &event_id)
|
||||
{
|
||||
if (event_id.known_p ())
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
}
|
||||
void prepare_for_emission (checker_path *path,
|
||||
pending_diagnostic *pd,
|
||||
diagnostic_event_id_t emission_id) override
|
||||
diagnostics::paths::event_id_t emission_id) override
|
||||
{
|
||||
region_creation_event_capacity::prepare_for_emission (path,
|
||||
pd,
|
||||
@@ -203,7 +203,7 @@ protected:
|
||||
const region *m_reg;
|
||||
tree m_diag_arg;
|
||||
const svalue *m_sval_hint;
|
||||
diagnostic_event_id_t m_region_creation_event_id;
|
||||
diagnostics::paths::event_id_t m_region_creation_event_id;
|
||||
};
|
||||
|
||||
/* Abstract base class for all out-of-bounds warnings where the
|
||||
|
||||
@@ -24,7 +24,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "cfg.h"
|
||||
#include "digraph.h"
|
||||
#include "sbitmap.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
|
||||
#include "analyzer/analyzer-logging.h"
|
||||
#include "analyzer/supergraph.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Subclasses of diagnostic_event for analyzer diagnostics.
|
||||
/* Subclasses of diagnostics::paths::event for analyzer diagnostics.
|
||||
Copyright (C) 2019-2025 Free Software Foundation, Inc.
|
||||
Contributed by David Malcolm <dmalcolm@redhat.com>.
|
||||
|
||||
@@ -101,7 +101,7 @@ event_kind_to_string (enum event_kind ek)
|
||||
}
|
||||
}
|
||||
|
||||
/* class checker_event : public diagnostic_event. */
|
||||
/* class checker_event : public diagnostics::paths::event. */
|
||||
|
||||
/* checker_event's ctor. */
|
||||
|
||||
@@ -131,16 +131,16 @@ checker_event::checker_event (enum event_kind kind,
|
||||
}
|
||||
}
|
||||
|
||||
/* No-op implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* No-op implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
checker_event: checker events have no meaning by default. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
checker_event::get_meaning () const
|
||||
{
|
||||
return meaning ();
|
||||
return diagnostics::paths::event::meaning ();
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::maybe_add_sarif_properties
|
||||
/* Implementation of diagnostics::paths::event::maybe_add_sarif_properties
|
||||
for checker_event. */
|
||||
|
||||
void
|
||||
@@ -215,7 +215,7 @@ checker_event::debug () const
|
||||
void
|
||||
checker_event::prepare_for_emission (checker_path *path,
|
||||
pending_diagnostic *pd,
|
||||
diagnostic_event_id_t emission_id)
|
||||
diagnostics::paths::event_id_t emission_id)
|
||||
{
|
||||
m_path = path;
|
||||
m_pending_diagnostic = pd;
|
||||
@@ -252,7 +252,7 @@ checker_event::maybe_make_diagnostic_state_graph (bool debug) const
|
||||
|
||||
/* class debug_event : public checker_event. */
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
debug_event.
|
||||
Use the saved string as the event's description. */
|
||||
|
||||
@@ -264,7 +264,7 @@ debug_event::print_desc (pretty_printer &pp) const
|
||||
|
||||
/* class precanned_custom_event : public custom_event. */
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
precanned_custom_event.
|
||||
Use the saved string as the event's description. */
|
||||
|
||||
@@ -287,7 +287,7 @@ statement_event::statement_event (const gimple *stmt, tree fndecl, int depth,
|
||||
{
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
statement_event.
|
||||
Use the statement's dump form as the event's description. */
|
||||
|
||||
@@ -383,7 +383,7 @@ function_entry_event::function_entry_event (const program_point &dst_point,
|
||||
{
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
function_entry_event.
|
||||
|
||||
Use a string such as "entry to 'foo'" as the event's description. */
|
||||
@@ -394,10 +394,10 @@ function_entry_event::print_desc (pretty_printer &pp) const
|
||||
pp_printf (&pp, "entry to %qE", m_effective_fndecl);
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* Implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
function entry. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
function_entry_event::get_meaning () const
|
||||
{
|
||||
return meaning (verb::enter, noun::function);
|
||||
@@ -429,7 +429,7 @@ state_change_event::state_change_event (const supernode *node,
|
||||
{
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
state_change_event.
|
||||
|
||||
Attempt to generate a nicer human-readable description.
|
||||
@@ -471,7 +471,7 @@ state_change_event::print_desc (pretty_printer &pp) const
|
||||
pp_string (&pp, "NULL origin");
|
||||
|
||||
/* Get any "meaning" of event. */
|
||||
diagnostic_event::meaning meaning = get_meaning ();
|
||||
diagnostics::paths::event::meaning meaning = get_meaning ();
|
||||
pp_string (&pp, ", meaning: ");
|
||||
meaning.dump_to_pp (&pp);
|
||||
pp_string (&pp, ")");
|
||||
@@ -508,11 +508,11 @@ state_change_event::print_desc (pretty_printer &pp) const
|
||||
}
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* Implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
state change events: delegate to the pending_diagnostic to
|
||||
get any meaning. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
state_change_event::get_meaning () const
|
||||
{
|
||||
if (m_pending_diagnostic)
|
||||
@@ -530,7 +530,7 @@ state_change_event::get_meaning () const
|
||||
|
||||
/* class superedge_event : public checker_event. */
|
||||
|
||||
/* Implementation of diagnostic_event::maybe_add_sarif_properties
|
||||
/* Implementation of diagnostics::paths::event::maybe_add_sarif_properties
|
||||
for superedge_event. */
|
||||
|
||||
void
|
||||
@@ -626,10 +626,10 @@ cfg_edge_event::cfg_edge_event (enum event_kind kind,
|
||||
gcc_assert (eedge.m_sedge->m_kind == SUPEREDGE_CFG_EDGE);
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* Implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
CFG edge events. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
cfg_edge_event::get_meaning () const
|
||||
{
|
||||
const cfg_superedge& cfg_sedge = get_cfg_superedge ();
|
||||
@@ -643,7 +643,7 @@ cfg_edge_event::get_meaning () const
|
||||
|
||||
/* class start_cfg_edge_event : public cfg_edge_event. */
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
start_cfg_edge_event.
|
||||
|
||||
If -fanalyzer-verbose-edges, then generate low-level descriptions, such
|
||||
@@ -844,7 +844,7 @@ call_event::call_event (const exploded_edge &eedge,
|
||||
m_dest_snode = eedge.m_dest->get_supernode ();
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
call_event.
|
||||
|
||||
If this call event passes critical state for an sm-based warning,
|
||||
@@ -876,10 +876,10 @@ call_event::print_desc (pretty_printer &pp) const
|
||||
get_caller_fndecl ());
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* Implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
function call events. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
call_event::get_meaning () const
|
||||
{
|
||||
return meaning (verb::call, noun::function);
|
||||
@@ -928,7 +928,7 @@ return_event::return_event (const exploded_edge &eedge,
|
||||
m_dest_snode = eedge.m_dest->get_supernode ();
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
return_event.
|
||||
|
||||
If this return event returns critical state for an sm-based warning,
|
||||
@@ -960,10 +960,10 @@ return_event::print_desc (pretty_printer &pp) const
|
||||
m_src_snode->m_fun->decl);
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* Implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
function return events. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
return_event::get_meaning () const
|
||||
{
|
||||
return meaning (verb::return_, noun::function);
|
||||
@@ -987,10 +987,10 @@ start_consolidated_cfg_edges_event::print_desc (pretty_printer &pp) const
|
||||
m_edge_sense ? "true" : "false");
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* Implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
start_consolidated_cfg_edges_event. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
start_consolidated_cfg_edges_event::get_meaning () const
|
||||
{
|
||||
return meaning (verb::branch,
|
||||
@@ -1008,10 +1008,10 @@ inlined_call_event::print_desc (pretty_printer &pp) const
|
||||
m_apparent_caller_fndecl);
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* Implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
reconstructed inlined function calls. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
inlined_call_event::get_meaning () const
|
||||
{
|
||||
return meaning (verb::call, noun::function);
|
||||
@@ -1019,7 +1019,7 @@ inlined_call_event::get_meaning () const
|
||||
|
||||
/* class setjmp_event : public checker_event. */
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
setjmp_event. */
|
||||
|
||||
void
|
||||
@@ -1038,7 +1038,7 @@ setjmp_event::print_desc (pretty_printer &pp) const
|
||||
void
|
||||
setjmp_event::prepare_for_emission (checker_path *path,
|
||||
pending_diagnostic *pd,
|
||||
diagnostic_event_id_t emission_id)
|
||||
diagnostics::paths::event_id_t emission_id)
|
||||
{
|
||||
checker_event::prepare_for_emission (path, pd, emission_id);
|
||||
path->record_setjmp_event (m_enode, emission_id);
|
||||
@@ -1077,7 +1077,7 @@ rewind_event::rewind_event (const exploded_edge *eedge,
|
||||
|
||||
/* class rewind_from_longjmp_event : public rewind_event. */
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
rewind_from_longjmp_event. */
|
||||
|
||||
void
|
||||
@@ -1101,7 +1101,7 @@ rewind_from_longjmp_event::print_desc (pretty_printer &pp) const
|
||||
|
||||
/* class rewind_to_setjmp_event : public rewind_event. */
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
rewind_to_setjmp_event. */
|
||||
|
||||
void
|
||||
@@ -1150,7 +1150,7 @@ rewind_to_setjmp_event::print_desc (pretty_printer &pp) const
|
||||
void
|
||||
rewind_to_setjmp_event::prepare_for_emission (checker_path *path,
|
||||
pending_diagnostic *pd,
|
||||
diagnostic_event_id_t emission_id)
|
||||
diagnostics::paths::event_id_t emission_id)
|
||||
{
|
||||
checker_event::prepare_for_emission (path, pd, emission_id);
|
||||
path->get_setjmp_event (m_rewind_info->get_enode_origin (),
|
||||
@@ -1203,7 +1203,7 @@ unwind_event::print_desc (pretty_printer &pp) const
|
||||
|
||||
/* class warning_event : public checker_event. */
|
||||
|
||||
/* Implementation of diagnostic_event::print_desc vfunc for
|
||||
/* Implementation of diagnostics::paths::event::print_desc vfunc for
|
||||
warning_event.
|
||||
|
||||
If the pending diagnostic implements describe_final_event, use it,
|
||||
@@ -1248,10 +1248,10 @@ warning_event::print_desc (pretty_printer &pp) const
|
||||
pp_string (&pp, "here");
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_event::get_meaning vfunc for
|
||||
/* Implementation of diagnostics::paths::event::get_meaning vfunc for
|
||||
warning_event. */
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
warning_event::get_meaning () const
|
||||
{
|
||||
return meaning (verb::danger, noun::unknown);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Subclasses of diagnostic_event for analyzer diagnostics.
|
||||
/* Subclasses of diagnostics::paths::event for analyzer diagnostics.
|
||||
Copyright (C) 2019-2025 Free Software Foundation, Inc.
|
||||
Contributed by David Malcolm <dmalcolm@redhat.com>.
|
||||
|
||||
@@ -62,7 +62,7 @@ extern const char *event_kind_to_string (enum event_kind ek);
|
||||
The class hierarchy looks like this (using indentation to show
|
||||
inheritance, and with event_kinds shown for the concrete subclasses):
|
||||
|
||||
diagnostic_event
|
||||
diagnostics::paths::event
|
||||
checker_event
|
||||
debug_event (event_kind::debug)
|
||||
custom_event (event_kind::custom)
|
||||
@@ -91,13 +91,13 @@ extern const char *event_kind_to_string (enum event_kind ek);
|
||||
unwind_event (event_kind::unwind)
|
||||
warning_event (event_kind::warning). */
|
||||
|
||||
/* Abstract subclass of diagnostic_event; the base class for use in
|
||||
checker_path (the analyzer's diagnostic_path subclass). */
|
||||
/* Abstract subclass of diagnostics::paths::event; the base class for use in
|
||||
checker_path (the analyzer's diagnostics::paths::path subclass). */
|
||||
|
||||
class checker_event : public diagnostic_event
|
||||
class checker_event : public diagnostics::paths::event
|
||||
{
|
||||
public:
|
||||
/* Implementation of diagnostic_event. */
|
||||
/* Implementation of diagnostics::paths::event. */
|
||||
|
||||
location_t get_location () const final override { return m_loc; }
|
||||
int get_stack_depth () const final override { return m_effective_depth; }
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
}
|
||||
meaning get_meaning () const override;
|
||||
bool connect_to_next_event_p () const override { return false; }
|
||||
diagnostic_thread_id_t get_thread_id () const final override
|
||||
diagnostics::paths::thread_id_t get_thread_id () const final override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
|
||||
virtual void prepare_for_emission (checker_path *,
|
||||
pending_diagnostic *pd,
|
||||
diagnostic_event_id_t emission_id);
|
||||
diagnostics::paths::event_id_t emission_id);
|
||||
virtual bool is_call_p () const { return false; }
|
||||
virtual bool is_function_entry_p () const { return false; }
|
||||
virtual bool is_return_p () const { return false; }
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
get_program_state () const { return nullptr; }
|
||||
|
||||
/* For use with %@. */
|
||||
const diagnostic_event_id_t *get_id_ptr () const
|
||||
const diagnostics::paths::event_id_t *get_id_ptr () const
|
||||
{
|
||||
return &m_emission_id;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ protected:
|
||||
int m_original_depth;
|
||||
int m_effective_depth;
|
||||
pending_diagnostic *m_pending_diagnostic;
|
||||
diagnostic_event_id_t m_emission_id; // only set once all pruning has occurred
|
||||
diagnostics::paths::event_id_t m_emission_id; // only set once all pruning has occurred
|
||||
diagnostics::logical_locations::key m_logical_loc;
|
||||
};
|
||||
|
||||
@@ -666,7 +666,7 @@ public:
|
||||
|
||||
void prepare_for_emission (checker_path *path,
|
||||
pending_diagnostic *pd,
|
||||
diagnostic_event_id_t emission_id) final override;
|
||||
diagnostics::paths::event_id_t emission_id) final override;
|
||||
|
||||
private:
|
||||
const exploded_node *m_enode;
|
||||
@@ -732,10 +732,10 @@ public:
|
||||
|
||||
void prepare_for_emission (checker_path *path,
|
||||
pending_diagnostic *pd,
|
||||
diagnostic_event_id_t emission_id) final override;
|
||||
diagnostics::paths::event_id_t emission_id) final override;
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_original_setjmp_event_id;
|
||||
diagnostics::paths::event_id_t m_original_setjmp_event_id;
|
||||
};
|
||||
|
||||
/* An abstract subclass for throwing/rethrowing an exception. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Subclass of diagnostic_path for analyzer diagnostics.
|
||||
/* Subclass of diagnostics::paths::path for analyzer diagnostics.
|
||||
Copyright (C) 2019-2025 Free Software Foundation, Inc.
|
||||
Contributed by David Malcolm <dmalcolm@redhat.com>.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Subclass of diagnostic_path for analyzer diagnostics.
|
||||
/* Subclass of diagnostics::paths::path for analyzer diagnostics.
|
||||
Copyright (C) 2019-2025 Free Software Foundation, Inc.
|
||||
Contributed by David Malcolm <dmalcolm@redhat.com>.
|
||||
|
||||
@@ -26,28 +26,29 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
namespace ana {
|
||||
|
||||
/* Subclass of diagnostic_path for analyzer diagnostics. */
|
||||
/* Subclass of diagnostic path for analyzer diagnostics. */
|
||||
|
||||
class checker_path : public diagnostic_path
|
||||
class checker_path : public diagnostics::paths::path
|
||||
{
|
||||
public:
|
||||
checker_path (const logical_location_manager &logical_loc_mgr,
|
||||
checker_path (const diagnostics::logical_locations::manager &logical_loc_mgr,
|
||||
const extrinsic_state &ext_state,
|
||||
logger *logger)
|
||||
: diagnostic_path (logical_loc_mgr),
|
||||
: diagnostics::paths::path (logical_loc_mgr),
|
||||
m_ext_state (ext_state),
|
||||
m_thread ("main"),
|
||||
m_logger (logger)
|
||||
{}
|
||||
|
||||
/* Implementation of diagnostic_path vfuncs. */
|
||||
/* Implementation of diagnostics::paths::path vfuncs. */
|
||||
|
||||
unsigned num_events () const final override
|
||||
{
|
||||
return m_events.length ();
|
||||
}
|
||||
|
||||
const diagnostic_event & get_event (int idx) const final override
|
||||
const diagnostics::paths::event &
|
||||
get_event (int idx) const final override
|
||||
{
|
||||
return *m_events[idx];
|
||||
}
|
||||
@@ -55,8 +56,8 @@ public:
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
const diagnostic_thread &
|
||||
get_thread (diagnostic_thread_id_t) const final override
|
||||
const diagnostics::paths::thread &
|
||||
get_thread (diagnostics::paths::thread_id_t) const final override
|
||||
{
|
||||
return m_thread;
|
||||
}
|
||||
@@ -115,21 +116,22 @@ public:
|
||||
checker_event *e;
|
||||
int i;
|
||||
FOR_EACH_VEC_ELT (m_events, i, e)
|
||||
e->prepare_for_emission (this, pd, diagnostic_event_id_t (i));
|
||||
e->prepare_for_emission (this, pd, diagnostics::paths::event_id_t (i));
|
||||
}
|
||||
|
||||
void fixup_locations (pending_diagnostic *pd);
|
||||
|
||||
void record_setjmp_event (const exploded_node *enode,
|
||||
diagnostic_event_id_t setjmp_emission_id)
|
||||
diagnostics::paths::event_id_t setjmp_emission_id)
|
||||
{
|
||||
m_setjmp_event_ids.put (enode, setjmp_emission_id);
|
||||
}
|
||||
|
||||
bool get_setjmp_event (const exploded_node *enode,
|
||||
diagnostic_event_id_t *out_emission_id)
|
||||
diagnostics::paths::event_id_t *out_emission_id)
|
||||
{
|
||||
if (diagnostic_event_id_t *emission_id = m_setjmp_event_ids.get (enode))
|
||||
if (diagnostics::paths::event_id_t *emission_id
|
||||
= m_setjmp_event_ids.get (enode))
|
||||
{
|
||||
*out_emission_id = *emission_id;
|
||||
return true;
|
||||
@@ -154,7 +156,7 @@ private:
|
||||
/* During prepare_for_emission (and after), the setjmp_event for each
|
||||
exploded_node *, so that rewind events can refer to them in their
|
||||
descriptions. */
|
||||
hash_map <const exploded_node *, diagnostic_event_id_t> m_setjmp_event_ids;
|
||||
hash_map <const exploded_node *, diagnostics::paths::event_id_t> m_setjmp_event_ids;
|
||||
|
||||
logger *m_logger;
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "options.h"
|
||||
#include "bitmap.h"
|
||||
#include "diagnostic-core.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "rich-location.h"
|
||||
#include "function.h"
|
||||
#include "json.h"
|
||||
@@ -443,7 +443,7 @@ extern std::unique_ptr<json::value>
|
||||
tree_to_json (tree node);
|
||||
|
||||
extern std::unique_ptr<json::value>
|
||||
diagnostic_event_id_to_json (const diagnostic_event_id_t &);
|
||||
diagnostic_event_id_to_json (const diagnostics::paths::event_id_t &);
|
||||
|
||||
extern std::unique_ptr<json::value>
|
||||
bit_offset_to_json (const bit_offset_t &offset);
|
||||
|
||||
@@ -1583,7 +1583,7 @@ diagnostic_manager::emit_saved_diagnostic (const exploded_graph &eg,
|
||||
/* Precompute all enodes from which the diagnostic is reachable. */
|
||||
path_builder pb (eg, *epath, sd.get_feasibility_problem (), sd);
|
||||
|
||||
/* This is the diagnostic_path subclass that will be built for
|
||||
/* This is the diagnostics::paths::path subclass that will be built for
|
||||
the diagnostic. */
|
||||
checker_path emission_path (get_logical_location_manager (),
|
||||
eg.get_ext_state (),
|
||||
|
||||
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "cpplib.h"
|
||||
#include "digraph.h"
|
||||
#include "ordered-hash-map.h"
|
||||
|
||||
@@ -22,7 +22,6 @@ along with GCC; see the file COPYING3. If not see
|
||||
#define GCC_ANALYZER_PENDING_DIAGNOSTIC_H
|
||||
|
||||
#include "diagnostics/metadata.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "analyzer/sm.h"
|
||||
|
||||
namespace ana {
|
||||
@@ -44,7 +43,7 @@ struct interesting_t
|
||||
};
|
||||
|
||||
/* Various bundles of information used for generating more precise
|
||||
messages for events within a diagnostic_path, for passing to the
|
||||
messages for events within a diagnostic path, for passing to the
|
||||
various "describe_*" vfuncs of pending_diagnostic. See those
|
||||
for more information. */
|
||||
|
||||
@@ -58,7 +57,7 @@ struct state_change
|
||||
tree origin,
|
||||
state_machine::state_t old_state,
|
||||
state_machine::state_t new_state,
|
||||
diagnostic_event_id_t event_id,
|
||||
diagnostics::paths::event_id_t event_id,
|
||||
const state_change_event &event)
|
||||
: m_expr (expr), m_origin (origin),
|
||||
m_old_state (old_state), m_new_state (new_state),
|
||||
@@ -71,7 +70,7 @@ struct state_change
|
||||
tree m_origin;
|
||||
state_machine::state_t m_old_state;
|
||||
state_machine::state_t m_new_state;
|
||||
diagnostic_event_id_t m_event_id;
|
||||
diagnostics::paths::event_id_t m_event_id;
|
||||
const state_change_event &m_event;
|
||||
};
|
||||
|
||||
@@ -131,7 +130,7 @@ struct final_event
|
||||
pending_diagnostic::emit vfunc.
|
||||
|
||||
The rich_location will have already been populated with a
|
||||
diagnostic_path. */
|
||||
diagnostics::paths::path. */
|
||||
|
||||
class diagnostic_emission_context
|
||||
{
|
||||
@@ -182,7 +181,7 @@ private:
|
||||
|
||||
As well as emitting a diagnostic, the class has various "precision of
|
||||
wording" virtual functions, for generating descriptions for events
|
||||
within a diagnostic_path. These are optional, but implementing these
|
||||
within a diagnostic path. These are optional, but implementing these
|
||||
allows for more precise wordings than the more generic
|
||||
implementation. */
|
||||
|
||||
@@ -238,7 +237,7 @@ class pending_diagnostic
|
||||
virtual location_t fixup_location (location_t loc, bool primary) const;
|
||||
|
||||
/* Precision-of-wording vfunc for describing a critical state change
|
||||
within the diagnostic_path.
|
||||
within the diagnostic path.
|
||||
|
||||
For example, a double-free diagnostic might use the descriptions:
|
||||
- "first 'free' happens here"
|
||||
@@ -260,13 +259,13 @@ class pending_diagnostic
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Vfunc for implementing diagnostic_event::get_meaning for
|
||||
/* Vfunc for implementing event::get_meaning for
|
||||
state_change_event. */
|
||||
virtual diagnostic_event::meaning
|
||||
virtual diagnostics::paths::event::meaning
|
||||
get_meaning_for_state_change (const evdesc::state_change &) const
|
||||
{
|
||||
/* Default no-op implementation. */
|
||||
return diagnostic_event::meaning ();
|
||||
return diagnostics::paths::event::meaning ();
|
||||
}
|
||||
|
||||
/* Precision-of-wording vfunc for describing an interprocedural call
|
||||
@@ -285,7 +284,7 @@ class pending_diagnostic
|
||||
}
|
||||
|
||||
/* Precision-of-wording vfunc for describing an interprocedural return
|
||||
within the diagnostic_path that carries critial state for the
|
||||
within the diagnostic path that carries critial state for the
|
||||
diagnostic, from callee back to caller.
|
||||
|
||||
For example, a deref-of-unchecked-malloc diagnostic might use:
|
||||
@@ -301,7 +300,7 @@ class pending_diagnostic
|
||||
}
|
||||
|
||||
/* Precision-of-wording vfunc for describing the final event within a
|
||||
diagnostic_path.
|
||||
diagnostic path.
|
||||
|
||||
For example a double-free diagnostic might use:
|
||||
- "second 'free' here; first 'free' was at (3)"
|
||||
|
||||
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "gcc-rich-location.h"
|
||||
#include "gimple-pretty-print.h"
|
||||
#include "sbitmap.h"
|
||||
|
||||
@@ -27,7 +27,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "gimple-iterator.h"
|
||||
#include "cgraph.h"
|
||||
#include "digraph.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "diagnostics/state-graphs.h"
|
||||
#include "graphviz.h"
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "cgraph.h"
|
||||
#include "cfg.h"
|
||||
#include "sbitmap.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "stor-layout.h"
|
||||
#include "stringpool.h"
|
||||
#include "attribs.h"
|
||||
|
||||
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "stringpool.h"
|
||||
#include "attribs.h"
|
||||
|
||||
@@ -392,21 +392,22 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
get_meaning_for_state_change (
|
||||
const evdesc::state_change &change) const final override
|
||||
{
|
||||
using event = diagnostics::paths::event;
|
||||
if (change.m_old_state == m_sm.get_start_state ()
|
||||
&& (m_sm.is_unchecked_fd_p (change.m_new_state)
|
||||
|| change.m_new_state == m_sm.m_new_datagram_socket
|
||||
|| change.m_new_state == m_sm.m_new_stream_socket
|
||||
|| change.m_new_state == m_sm.m_new_unknown_socket))
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::acquire,
|
||||
diagnostic_event::noun::resource);
|
||||
return event::meaning (event::verb::acquire,
|
||||
event::noun::resource);
|
||||
if (change.m_new_state == m_sm.m_closed)
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::release,
|
||||
diagnostic_event::noun::resource);
|
||||
return diagnostic_event::meaning ();
|
||||
return event::meaning (event::verb::release,
|
||||
event::noun::resource);
|
||||
return event::meaning ();
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -561,7 +562,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_open_event;
|
||||
diagnostics::paths::event_id_t m_open_event;
|
||||
std::unique_ptr<program_state> m_final_state;
|
||||
};
|
||||
|
||||
@@ -705,7 +706,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_first_close_event;
|
||||
diagnostics::paths::event_id_t m_first_close_event;
|
||||
};
|
||||
|
||||
class fd_use_after_close : public fd_param_diagnostic
|
||||
@@ -784,7 +785,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_first_close_event;
|
||||
diagnostics::paths::event_id_t m_first_close_event;
|
||||
};
|
||||
|
||||
class fd_use_without_check : public fd_param_diagnostic
|
||||
@@ -854,7 +855,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_first_open_event;
|
||||
diagnostics::paths::event_id_t m_first_open_event;
|
||||
};
|
||||
|
||||
/* Concrete pending_diagnostic subclass for -Wanalyzer-fd-phase-mismatch. */
|
||||
|
||||
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "selftest.h"
|
||||
|
||||
#include "analyzer/analyzer-logging.h"
|
||||
@@ -155,18 +155,20 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
get_meaning_for_state_change (const evdesc::state_change &change)
|
||||
const final override
|
||||
{
|
||||
using event = diagnostics::paths::event;
|
||||
|
||||
if (change.m_old_state == m_sm.get_start_state ()
|
||||
&& change.m_new_state == m_sm.m_unchecked)
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::acquire,
|
||||
diagnostic_event::noun::resource);
|
||||
return event::meaning (event::verb::acquire,
|
||||
event::noun::resource);
|
||||
if (change.m_new_state == m_sm.m_closed)
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::release,
|
||||
diagnostic_event::noun::resource);
|
||||
return diagnostic_event::meaning ();
|
||||
return event::meaning (event::verb::release,
|
||||
event::noun::resource);
|
||||
return event::meaning ();
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -225,7 +227,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_first_fclose_event;
|
||||
diagnostics::paths::event_id_t m_first_fclose_event;
|
||||
};
|
||||
|
||||
class file_leak : public file_diagnostic
|
||||
@@ -303,7 +305,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_fopen_event;
|
||||
diagnostics::paths::event_id_t m_fopen_event;
|
||||
std::unique_ptr<program_state> m_final_state;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "stringpool.h"
|
||||
#include "attribs.h"
|
||||
#include "xml-printer.h"
|
||||
@@ -814,18 +814,18 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
get_meaning_for_state_change (const evdesc::state_change &change)
|
||||
const final override
|
||||
{
|
||||
if (change.m_old_state == m_sm.get_start_state ()
|
||||
&& unchecked_p (change.m_new_state))
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::acquire,
|
||||
diagnostic_event::noun::memory);
|
||||
return diagnostics::paths::event::meaning (diagnostics::paths::event::verb::acquire,
|
||||
diagnostics::paths::event::noun::memory);
|
||||
if (freed_p (change.m_new_state))
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::release,
|
||||
diagnostic_event::noun::memory);
|
||||
return diagnostic_event::meaning ();
|
||||
return diagnostics::paths::event::meaning (diagnostics::paths::event::verb::release,
|
||||
diagnostics::paths::event::noun::memory);
|
||||
return diagnostics::paths::event::meaning ();
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -918,7 +918,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_alloc_event;
|
||||
diagnostics::paths::event_id_t m_alloc_event;
|
||||
const deallocator_set *m_expected_deallocators;
|
||||
const deallocator *m_actual_dealloc;
|
||||
};
|
||||
@@ -988,7 +988,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_first_free_event;
|
||||
diagnostics::paths::event_id_t m_first_free_event;
|
||||
const char *m_funcname;
|
||||
};
|
||||
|
||||
@@ -1031,7 +1031,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
diagnostic_event_id_t m_origin_of_unchecked_event;
|
||||
diagnostics::paths::event_id_t m_origin_of_unchecked_event;
|
||||
};
|
||||
|
||||
/* Concrete subclass for describing dereference of a possible NULL
|
||||
@@ -1419,7 +1419,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_free_event;
|
||||
diagnostics::paths::event_id_t m_free_event;
|
||||
const deallocator *m_deallocator;
|
||||
};
|
||||
|
||||
@@ -1500,7 +1500,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_alloc_event;
|
||||
diagnostics::paths::event_id_t m_alloc_event;
|
||||
std::unique_ptr<program_state> m_final_state;
|
||||
};
|
||||
|
||||
@@ -1768,7 +1768,7 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
diagnostic_event_id_t m_first_deref_event;
|
||||
diagnostics::paths::event_id_t m_first_deref_event;
|
||||
const exploded_node *m_deref_enode;
|
||||
tree m_deref_expr;
|
||||
const exploded_node *m_check_enode;
|
||||
|
||||
@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "tree-pretty-print.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
|
||||
#include "analyzer/analyzer-logging.h"
|
||||
#include "analyzer/sm.h"
|
||||
|
||||
@@ -21,7 +21,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
|
||||
#include "analyzer/analyzer-logging.h"
|
||||
#include "analyzer/sm.h"
|
||||
@@ -106,14 +106,15 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
get_meaning_for_state_change (const evdesc::state_change &change)
|
||||
const final override
|
||||
{
|
||||
using event = diagnostics::paths::event;
|
||||
|
||||
if (change.m_new_state == m_sm.m_sensitive)
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::acquire,
|
||||
diagnostic_event::noun::sensitive);
|
||||
return diagnostic_event::meaning ();
|
||||
return event::meaning (event::verb::acquire, event::noun::sensitive);
|
||||
return event::meaning ();
|
||||
}
|
||||
bool
|
||||
describe_call_with_state (pretty_printer &pp,
|
||||
@@ -162,7 +163,7 @@ public:
|
||||
private:
|
||||
const sensitive_state_machine &m_sm;
|
||||
tree m_arg;
|
||||
diagnostic_event_id_t m_first_sensitive_event;
|
||||
diagnostics::paths::event_id_t m_first_sensitive_event;
|
||||
};
|
||||
|
||||
/* sensitive_state_machine's ctor. */
|
||||
|
||||
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "analyzer/common.h"
|
||||
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "sbitmap.h"
|
||||
#include "ordered-hash-map.h"
|
||||
#include "selftest.h"
|
||||
|
||||
@@ -209,14 +209,15 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
get_meaning_for_state_change (const evdesc::state_change &change)
|
||||
const final override
|
||||
{
|
||||
using event = diagnostics::paths::event;
|
||||
if (change.m_new_state == m_sm.m_tainted)
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::acquire,
|
||||
diagnostic_event::noun::taint);
|
||||
return diagnostic_event::meaning ();
|
||||
return event::meaning (event::verb::acquire,
|
||||
event::noun::taint);
|
||||
return event::meaning ();
|
||||
}
|
||||
|
||||
void maybe_add_sarif_properties (sarif_object &result_obj)
|
||||
|
||||
@@ -334,17 +334,17 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
get_meaning_for_state_change (const evdesc::state_change &change)
|
||||
const final override
|
||||
{
|
||||
if (change.m_new_state == m_sm.m_started)
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::acquire,
|
||||
diagnostic_event::noun::resource);
|
||||
return diagnostics::paths::event::meaning (diagnostics::paths::event::verb::acquire,
|
||||
diagnostics::paths::event::noun::resource);
|
||||
if (change.m_new_state == m_sm.m_ended)
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::release,
|
||||
diagnostic_event::noun::resource);
|
||||
return diagnostic_event::meaning ();
|
||||
return diagnostics::paths::event::meaning (diagnostics::paths::event::verb::release,
|
||||
diagnostics::paths::event::noun::resource);
|
||||
return diagnostics::paths::event::meaning ();
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -452,7 +452,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_va_end_event;
|
||||
diagnostics::paths::event_id_t m_va_end_event;
|
||||
const char *m_usage_fnname;
|
||||
};
|
||||
|
||||
@@ -539,7 +539,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
diagnostic_event_id_t m_start_event;
|
||||
diagnostics::paths::event_id_t m_start_event;
|
||||
const char *m_start_event_fnname;
|
||||
std::unique_ptr<program_state> m_final_state;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "diagnostic-format-sarif.h"
|
||||
#include "diagnostics/output-file.h"
|
||||
#include "diagnostic-buffer.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "diagnostics/client-data-hooks.h"
|
||||
#include "selftest.h"
|
||||
#include "selftest-diagnostic.h"
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
}
|
||||
|
||||
std::unique_ptr<xml::node>
|
||||
maybe_make_state_diagram (const diagnostic_event &event);
|
||||
maybe_make_state_diagram (const paths::event &event);
|
||||
|
||||
private:
|
||||
void
|
||||
@@ -607,7 +607,7 @@ print_pre_source (xml::printer &xp, const char *text)
|
||||
}
|
||||
|
||||
std::unique_ptr<xml::node>
|
||||
html_builder::maybe_make_state_diagram (const diagnostic_event &event)
|
||||
html_builder::maybe_make_state_diagram (const paths::event &event)
|
||||
{
|
||||
if (!m_html_gen_opts.m_show_state_diagrams)
|
||||
return nullptr;
|
||||
@@ -665,7 +665,7 @@ class html_path_label_writer : public html_label_writer
|
||||
public:
|
||||
html_path_label_writer (xml::printer &xp,
|
||||
html_builder &builder,
|
||||
const diagnostic_path &path,
|
||||
const paths::path &path,
|
||||
const std::string &event_id_prefix)
|
||||
: m_xp (xp),
|
||||
m_html_builder (builder),
|
||||
@@ -686,7 +686,7 @@ public:
|
||||
|
||||
void end_label () final override
|
||||
{
|
||||
const diagnostic_event &event
|
||||
const paths::event &event
|
||||
= m_path.get_event (m_curr_event_id.zero_based ());
|
||||
if (auto state_doc = m_html_builder.maybe_make_state_diagram (event))
|
||||
{
|
||||
@@ -714,10 +714,10 @@ private:
|
||||
|
||||
xml::printer &m_xp;
|
||||
html_builder &m_html_builder;
|
||||
const diagnostic_path &m_path;
|
||||
const paths::path &m_path;
|
||||
const std::string &m_event_id_prefix;
|
||||
int m_next_event_idx;
|
||||
diagnostic_event_id_t m_curr_event_id;
|
||||
paths::event_id_t m_curr_event_id;
|
||||
};
|
||||
|
||||
/* See https://pf3.patternfly.org/v3/pattern-library/widgets/#alerts */
|
||||
@@ -1551,7 +1551,7 @@ test_token_printer ()
|
||||
|
||||
{
|
||||
token_printer_test t;
|
||||
diagnostic_event_id_t event_id (0);
|
||||
paths::event_id_t event_id (0);
|
||||
pp_printf (&t.m_pp, "foo %@ bar", &event_id);
|
||||
ASSERT_XML_PRINT_EQ
|
||||
(t.m_top_element,
|
||||
|
||||
@@ -56,7 +56,7 @@ make_html_sink (diagnostic_context &context,
|
||||
|
||||
extern void
|
||||
print_path_as_html (xml::printer &xp,
|
||||
const diagnostic_path &path,
|
||||
const diagnostics::paths::path &path,
|
||||
diagnostic_context &dc,
|
||||
html_label_writer *event_label_writer,
|
||||
const diagnostic_source_print_policy &dspp);
|
||||
|
||||
@@ -30,7 +30,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "diagnostics/metadata.h"
|
||||
#include "diagnostics/digraphs.h"
|
||||
#include "diagnostics/state-graphs.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "diagnostic-format.h"
|
||||
#include "diagnostic-buffer.h"
|
||||
#include "json.h"
|
||||
@@ -534,22 +534,22 @@ public:
|
||||
unsigned get_index_within_parent () const { return m_idx_within_parent; }
|
||||
|
||||
sarif_thread_flow &
|
||||
get_or_append_thread_flow (const diagnostic_thread &thread,
|
||||
diagnostic_thread_id_t thread_id);
|
||||
get_or_append_thread_flow (const paths::thread &thread,
|
||||
paths::thread_id_t thread_id);
|
||||
|
||||
sarif_thread_flow &
|
||||
get_thread_flow (diagnostic_thread_id_t thread_id);
|
||||
get_thread_flow (paths::thread_id_t thread_id);
|
||||
|
||||
void add_location (sarif_thread_flow_location &);
|
||||
|
||||
sarif_thread_flow_location &
|
||||
get_thread_flow_loc_obj (diagnostic_event_id_t event_id) const;
|
||||
get_thread_flow_loc_obj (paths::event_id_t event_id) const;
|
||||
|
||||
private:
|
||||
sarif_result &m_parent;
|
||||
const unsigned m_idx_within_parent;
|
||||
|
||||
hash_map<int_hash<diagnostic_thread_id_t, -1, -2>,
|
||||
hash_map<int_hash<paths::thread_id_t, -1, -2>,
|
||||
sarif_thread_flow *> m_thread_id_map; // borrowed ptr
|
||||
json::array *m_thread_flows_arr; // borrowed
|
||||
|
||||
@@ -565,7 +565,7 @@ class sarif_thread_flow : public sarif_object
|
||||
{
|
||||
public:
|
||||
sarif_thread_flow (sarif_code_flow &parent,
|
||||
const diagnostic_thread &thread,
|
||||
const paths::thread &thread,
|
||||
unsigned idx_within_parent);
|
||||
|
||||
sarif_code_flow &get_parent () const { return m_parent; }
|
||||
@@ -865,19 +865,19 @@ private:
|
||||
logical_locations::key logical_loc);
|
||||
std::unique_ptr<sarif_location>
|
||||
make_location_object (sarif_location_manager &loc_mgr,
|
||||
const diagnostic_event &event,
|
||||
const paths::event &event,
|
||||
enum diagnostic_artifact_role role);
|
||||
std::unique_ptr<sarif_code_flow>
|
||||
make_code_flow_object (sarif_result &result,
|
||||
unsigned idx_within_parent,
|
||||
const diagnostic_path &path);
|
||||
const paths::path &path);
|
||||
void
|
||||
populate_thread_flow_location_object (sarif_result &result,
|
||||
sarif_thread_flow_location &thread_flow_loc_obj,
|
||||
const diagnostic_event &event,
|
||||
const paths::event &event,
|
||||
int event_execution_idx);
|
||||
std::unique_ptr<json::array>
|
||||
maybe_make_kinds_array (diagnostic_event::meaning m) const;
|
||||
maybe_make_kinds_array (paths::event::meaning m) const;
|
||||
std::unique_ptr<sarif_physical_location>
|
||||
maybe_make_physical_location_object (location_t loc,
|
||||
enum diagnostic_artifact_role role,
|
||||
@@ -1574,8 +1574,8 @@ sarif_code_flow::sarif_code_flow (sarif_result &parent,
|
||||
}
|
||||
|
||||
sarif_thread_flow &
|
||||
sarif_code_flow::get_or_append_thread_flow (const diagnostic_thread &thread,
|
||||
diagnostic_thread_id_t thread_id)
|
||||
sarif_code_flow::get_or_append_thread_flow (const paths::thread &thread,
|
||||
paths::thread_id_t thread_id)
|
||||
{
|
||||
sarif_thread_flow **slot = m_thread_id_map.get (thread_id);
|
||||
if (slot)
|
||||
@@ -1591,7 +1591,7 @@ sarif_code_flow::get_or_append_thread_flow (const diagnostic_thread &thread,
|
||||
}
|
||||
|
||||
sarif_thread_flow &
|
||||
sarif_code_flow::get_thread_flow (diagnostic_thread_id_t thread_id)
|
||||
sarif_code_flow::get_thread_flow (paths::thread_id_t thread_id)
|
||||
{
|
||||
sarif_thread_flow **slot = m_thread_id_map.get (thread_id);
|
||||
gcc_assert (slot); // it must already have one
|
||||
@@ -1605,7 +1605,7 @@ sarif_code_flow::add_location (sarif_thread_flow_location &tfl_obj)
|
||||
}
|
||||
|
||||
sarif_thread_flow_location &
|
||||
sarif_code_flow::get_thread_flow_loc_obj (diagnostic_event_id_t event_id) const
|
||||
sarif_code_flow::get_thread_flow_loc_obj (paths::event_id_t event_id) const
|
||||
{
|
||||
gcc_assert (event_id.known_p ());
|
||||
gcc_assert ((size_t)event_id.zero_based () < m_all_tfl_objs.size ());
|
||||
@@ -1617,7 +1617,7 @@ sarif_code_flow::get_thread_flow_loc_obj (diagnostic_event_id_t event_id) const
|
||||
/* class sarif_thread_flow : public sarif_object. */
|
||||
|
||||
sarif_thread_flow::sarif_thread_flow (sarif_code_flow &parent,
|
||||
const diagnostic_thread &thread,
|
||||
const paths::thread &thread,
|
||||
unsigned idx_within_parent)
|
||||
: m_parent (parent),
|
||||
m_idx_within_parent (idx_within_parent)
|
||||
@@ -2060,7 +2060,7 @@ sarif_builder::make_result_object (const diagnostic_info &diagnostic,
|
||||
diagnostic_artifact_role::result_file));
|
||||
|
||||
/* "codeFlows" property (SARIF v2.1.0 section 3.27.18). */
|
||||
if (const diagnostic_path *path = diagnostic.richloc->get_path ())
|
||||
if (const paths::path *path = diagnostic.richloc->get_path ())
|
||||
{
|
||||
auto code_flows_arr = std::make_unique<json::array> ();
|
||||
const unsigned code_flow_index = 0;
|
||||
@@ -2430,11 +2430,11 @@ sarif_builder::make_location_object (sarif_location_manager &loc_mgr,
|
||||
}
|
||||
|
||||
/* Make a "location" object (SARIF v2.1.0 section 3.28) for EVENT
|
||||
within a diagnostic_path. */
|
||||
within a paths::path. */
|
||||
|
||||
std::unique_ptr<sarif_location>
|
||||
sarif_builder::make_location_object (sarif_location_manager &loc_mgr,
|
||||
const diagnostic_event &event,
|
||||
const paths::event &event,
|
||||
enum diagnostic_artifact_role role)
|
||||
{
|
||||
auto location_obj = std::make_unique<sarif_location> ();
|
||||
@@ -3050,7 +3050,7 @@ make_minimal_sarif_logical_location (logical_locations::key logical_loc)
|
||||
|
||||
label_text
|
||||
make_sarif_url_for_event (const sarif_code_flow *code_flow,
|
||||
diagnostic_event_id_t event_id)
|
||||
paths::event_id_t event_id)
|
||||
{
|
||||
gcc_assert (event_id.known_p ());
|
||||
|
||||
@@ -3084,7 +3084,7 @@ make_sarif_url_for_event (const sarif_code_flow *code_flow,
|
||||
std::unique_ptr<sarif_code_flow>
|
||||
sarif_builder::make_code_flow_object (sarif_result &result,
|
||||
unsigned idx_within_parent,
|
||||
const diagnostic_path &path)
|
||||
const paths::path &path)
|
||||
{
|
||||
auto code_flow_obj
|
||||
= std::make_unique <sarif_code_flow> (result, idx_within_parent);
|
||||
@@ -3096,8 +3096,8 @@ sarif_builder::make_code_flow_object (sarif_result &result,
|
||||
SARIF file. */
|
||||
for (unsigned i = 0; i < path.num_events (); i++)
|
||||
{
|
||||
const diagnostic_event &event = path.get_event (i);
|
||||
const diagnostic_thread_id_t thread_id = event.get_thread_id ();
|
||||
const paths::event &event = path.get_event (i);
|
||||
const paths::thread_id_t thread_id = event.get_thread_id ();
|
||||
|
||||
sarif_thread_flow &thread_flow_obj
|
||||
= code_flow_obj->get_or_append_thread_flow (path.get_thread (thread_id),
|
||||
@@ -3109,7 +3109,7 @@ sarif_builder::make_code_flow_object (sarif_result &result,
|
||||
m_current_code_flow = code_flow_obj.get ();
|
||||
for (unsigned i = 0; i < path.num_events (); i++)
|
||||
{
|
||||
const diagnostic_event &event = path.get_event (i);
|
||||
const paths::event &event = path.get_event (i);
|
||||
sarif_thread_flow_location &thread_flow_loc_obj
|
||||
= code_flow_obj->get_thread_flow_loc_obj (i);
|
||||
populate_thread_flow_location_object (result,
|
||||
@@ -3129,10 +3129,10 @@ void
|
||||
sarif_builder::
|
||||
populate_thread_flow_location_object (sarif_result &result,
|
||||
sarif_thread_flow_location &tfl_obj,
|
||||
const diagnostic_event &ev,
|
||||
const paths::event &ev,
|
||||
int event_execution_idx)
|
||||
{
|
||||
/* Give diagnostic_event subclasses a chance to add custom properties
|
||||
/* Give paths::event subclasses a chance to add custom properties
|
||||
via a property bag. */
|
||||
ev.maybe_add_sarif_properties (*this, tfl_obj);
|
||||
|
||||
@@ -3141,7 +3141,7 @@ populate_thread_flow_location_object (sarif_result &result,
|
||||
{
|
||||
sarif_property_bag &props = tfl_obj.get_or_create_properties ();
|
||||
|
||||
#define PROPERTY_PREFIX "gcc/diagnostic_event/"
|
||||
#define PROPERTY_PREFIX "gcc/diagnostics/paths/event/"
|
||||
props.set_graph (PROPERTY_PREFIX "state_graph",
|
||||
*this,
|
||||
/* Use RESULT for any related locations in the graph's
|
||||
@@ -3160,7 +3160,7 @@ populate_thread_flow_location_object (sarif_result &result,
|
||||
make_location_object (result, ev, diagnostic_artifact_role::traced_file));
|
||||
|
||||
/* "kinds" property (SARIF v2.1.0 section 3.38.8). */
|
||||
diagnostic_event::meaning m = ev.get_meaning ();
|
||||
paths::event::meaning m = ev.get_meaning ();
|
||||
if (auto kinds_arr = maybe_make_kinds_array (m))
|
||||
tfl_obj.set<json::array> ("kinds", std::move (kinds_arr));
|
||||
|
||||
@@ -3183,22 +3183,25 @@ populate_thread_flow_location_object (sarif_result &result,
|
||||
Otherwise, return nullptr. */
|
||||
|
||||
std::unique_ptr<json::array>
|
||||
sarif_builder::maybe_make_kinds_array (diagnostic_event::meaning m) const
|
||||
sarif_builder::
|
||||
maybe_make_kinds_array (paths::event::meaning m) const
|
||||
{
|
||||
if (m.m_verb == diagnostic_event::verb::unknown
|
||||
&& m.m_noun == diagnostic_event::noun::unknown
|
||||
&& m.m_property == diagnostic_event::property::unknown)
|
||||
using namespace paths;
|
||||
|
||||
if (m.m_verb == event::verb::unknown
|
||||
&& m.m_noun == event::noun::unknown
|
||||
&& m.m_property == event::property::unknown)
|
||||
return nullptr;
|
||||
|
||||
auto kinds_arr = std::make_unique<json::array> ();
|
||||
if (const char *verb_str
|
||||
= diagnostic_event::meaning::maybe_get_verb_str (m.m_verb))
|
||||
= event::meaning::maybe_get_verb_str (m.m_verb))
|
||||
kinds_arr->append_string (verb_str);
|
||||
if (const char *noun_str
|
||||
= diagnostic_event::meaning::maybe_get_noun_str (m.m_noun))
|
||||
= event::meaning::maybe_get_noun_str (m.m_noun))
|
||||
kinds_arr->append_string (noun_str);
|
||||
if (const char *property_str
|
||||
= diagnostic_event::meaning::maybe_get_property_str (m.m_property))
|
||||
= event::meaning::maybe_get_property_str (m.m_property))
|
||||
kinds_arr->append_string (property_str);
|
||||
return kinds_arr;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "diagnostic-color.h"
|
||||
#include "diagnostic-url.h"
|
||||
#include "diagnostics/metadata.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "diagnostics/client-data-hooks.h"
|
||||
#include "diagnostics/diagram.h"
|
||||
#include "diagnostic-format-text.h"
|
||||
@@ -42,6 +42,8 @@ along with GCC; see the file COPYING3. If not see
|
||||
# pragma GCC diagnostic ignored "-Wformat-diag"
|
||||
#endif
|
||||
|
||||
using namespace diagnostics;
|
||||
|
||||
/* Concrete buffering implementation subclass for JSON output. */
|
||||
|
||||
class diagnostic_text_format_buffer : public diagnostic_per_format_buffer
|
||||
@@ -277,7 +279,7 @@ void
|
||||
diagnostic_text_output_format::
|
||||
after_diagnostic (const diagnostic_info &diagnostic)
|
||||
{
|
||||
if (const diagnostic_path *path = diagnostic.richloc->get_path ())
|
||||
if (const paths::path *path = diagnostic.richloc->get_path ())
|
||||
print_path (*path);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
|
||||
char *build_indent_prefix (bool with_bullet) const;
|
||||
|
||||
void print_path (const diagnostic_path &path);
|
||||
void print_path (const diagnostics::paths::path &path);
|
||||
|
||||
bool show_column_p () const { return get_context ().m_show_column; }
|
||||
|
||||
|
||||
@@ -2701,7 +2701,7 @@ layout_printer<to_text>::begin_label (int range_idx,
|
||||
bool is_label_text)
|
||||
{
|
||||
/* Colorize the text, unless it's for labels for events in a
|
||||
diagnostic_path. */
|
||||
diagnostic path. */
|
||||
if (is_label_text && m_is_diagnostic_path)
|
||||
return;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "diagnostic-color.h"
|
||||
#include "diagnostic-url.h"
|
||||
#include "diagnostics/metadata.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "diagnostics/client-data-hooks.h"
|
||||
#include "diagnostics/diagram.h"
|
||||
#include "diagnostic-format.h"
|
||||
|
||||
@@ -96,17 +96,17 @@ enum diagnostics_output_format
|
||||
DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE
|
||||
};
|
||||
|
||||
/* An enum for controlling how diagnostic_paths should be printed. */
|
||||
/* An enum for controlling how diagnostic paths should be printed. */
|
||||
enum diagnostic_path_format
|
||||
{
|
||||
/* Don't print diagnostic_paths. */
|
||||
/* Don't print diagnostic paths. */
|
||||
DPF_NONE,
|
||||
|
||||
/* Print diagnostic_paths by emitting a separate "note" for every event
|
||||
/* Print diagnostic paths by emitting a separate "note" for every event
|
||||
in the path. */
|
||||
DPF_SEPARATE_EVENTS,
|
||||
|
||||
/* Print diagnostic_paths by consolidating events together where they
|
||||
/* Print diagnostic paths by consolidating events together where they
|
||||
are close enough, and printing such runs of events with multiple
|
||||
calls to diagnostic_show_locus, showing the individual events in
|
||||
each run via labels in the source. */
|
||||
@@ -931,7 +931,7 @@ private:
|
||||
/* True if we should print any rules associated with diagnostics. */
|
||||
bool m_show_rules;
|
||||
|
||||
/* How should diagnostic_path objects be printed. */
|
||||
/* How should diagnostics::paths::path objects be printed. */
|
||||
enum diagnostic_path_format m_path_format;
|
||||
|
||||
/* True if we should print stack depths when printing diagnostic paths. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* A class for referring to events within a diagnostic_path.
|
||||
/* A class for referring to events within a diagnostics::paths::path.
|
||||
Copyright (C) 2019-2025 Free Software Foundation, Inc.
|
||||
Contributed by David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
@@ -18,10 +18,10 @@ You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef GCC_DIAGNOSTIC_EVENT_ID_H
|
||||
#define GCC_DIAGNOSTIC_EVENT_ID_H
|
||||
#ifndef GCC_DIAGNOSTICS_EVENT_ID_H
|
||||
#define GCC_DIAGNOSTICS_EVENT_ID_H
|
||||
|
||||
/* A class for referring to events within a diagnostic_path.
|
||||
/* A class for referring to events within a diagnostics::paths::path.
|
||||
|
||||
They are stored as 0-based offsets into the events, but
|
||||
printed (e.g. via %@) as 1-based numbers.
|
||||
@@ -30,8 +30,10 @@ along with GCC; see the file COPYING3. If not see
|
||||
which would be shown to the user as "(1)", "(2)" and "(3)".
|
||||
|
||||
This has its own header so that pretty-print.cc can use this
|
||||
to implement "%@" without bringing in all of diagnostic_path
|
||||
(which e.g. refers to "tree"). */
|
||||
to implement "%@" without bringing in all of diagnostics::paths.
|
||||
|
||||
This has to be in the global namespace for compatibility with
|
||||
c-format.cc in GCC 10 onwards. */
|
||||
|
||||
class diagnostic_event_id_t
|
||||
{
|
||||
@@ -58,15 +60,24 @@ class diagnostic_event_id_t
|
||||
int m_index; // zero-based
|
||||
};
|
||||
|
||||
namespace diagnostics {
|
||||
namespace paths {
|
||||
|
||||
typedef diagnostic_event_id_t event_id_t;
|
||||
|
||||
/* A type for compactly referring to a particular thread within a
|
||||
diagnostics::paths::path. Typically there is just one thread per path,
|
||||
with id 0. */
|
||||
typedef int thread_id_t;
|
||||
|
||||
} // namespace paths
|
||||
} // namespace diagnostics
|
||||
|
||||
|
||||
/* A pointer to a diagnostic_event_id_t, for use with the "%@" format
|
||||
code, which will print a 1-based representation for it, with suitable
|
||||
colorization, e.g. "(1)".
|
||||
The %@ format code requires that known_p be true for the event ID. */
|
||||
typedef diagnostic_event_id_t *diagnostic_event_id_ptr;
|
||||
|
||||
/* A type for compactly referring to a particular thread within a
|
||||
diagnostic_path. Typically there is just one thread per path,
|
||||
with id 0. */
|
||||
typedef int diagnostic_thread_id_t;
|
||||
|
||||
#endif /* ! GCC_DIAGNOSTIC_EVENT_ID_H */
|
||||
#endif /* ! GCC_DIAGNOSTICS_EVENT_ID_H */
|
||||
@@ -27,48 +27,50 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "version.h"
|
||||
#include "intl.h"
|
||||
#include "diagnostic.h"
|
||||
#include "lazy-diagnostic-path.h"
|
||||
#include "diagnostics/lazy-paths.h"
|
||||
#include "selftest.h"
|
||||
#include "selftest-diagnostic.h"
|
||||
#include "simple-diagnostic-path.h"
|
||||
#include "gcc-rich-location.h"
|
||||
#include "diagnostic-format-text.h"
|
||||
|
||||
/* class lazy_diagnostic_path : public diagnostic_path. */
|
||||
using namespace diagnostics::paths;
|
||||
|
||||
/* Implementation of diagnostic_path vfuncs in terms of a lazily-generated
|
||||
/* class lazy_path : public path. */
|
||||
|
||||
/* Implementation of path vfuncs in terms of a lazily-generated
|
||||
path. */
|
||||
|
||||
unsigned
|
||||
lazy_diagnostic_path::num_events () const
|
||||
lazy_path::num_events () const
|
||||
{
|
||||
lazily_generate_path ();
|
||||
return m_inner_path->num_events ();
|
||||
}
|
||||
|
||||
const diagnostic_event &
|
||||
lazy_diagnostic_path::get_event (int idx) const
|
||||
const event &
|
||||
lazy_path::get_event (int idx) const
|
||||
{
|
||||
lazily_generate_path ();
|
||||
return m_inner_path->get_event (idx);
|
||||
}
|
||||
|
||||
unsigned
|
||||
lazy_diagnostic_path::num_threads () const
|
||||
lazy_path::num_threads () const
|
||||
{
|
||||
lazily_generate_path ();
|
||||
return m_inner_path->num_threads ();
|
||||
}
|
||||
|
||||
const diagnostic_thread &
|
||||
lazy_diagnostic_path::get_thread (diagnostic_thread_id_t idx) const
|
||||
const thread &
|
||||
lazy_path::get_thread (thread_id_t idx) const
|
||||
{
|
||||
lazily_generate_path ();
|
||||
return m_inner_path->get_thread (idx);
|
||||
}
|
||||
|
||||
bool
|
||||
lazy_diagnostic_path::same_function_p (int event_idx_a,
|
||||
lazy_path::same_function_p (int event_idx_a,
|
||||
int event_idx_b) const
|
||||
{
|
||||
lazily_generate_path ();
|
||||
@@ -76,7 +78,7 @@ lazy_diagnostic_path::same_function_p (int event_idx_a,
|
||||
}
|
||||
|
||||
void
|
||||
lazy_diagnostic_path::lazily_generate_path () const
|
||||
lazy_path::lazily_generate_path () const
|
||||
{
|
||||
if (!m_inner_path)
|
||||
m_inner_path = make_inner_path ();
|
||||
@@ -87,15 +89,15 @@ lazy_diagnostic_path::lazily_generate_path () const
|
||||
|
||||
namespace selftest {
|
||||
|
||||
class test_lazy_path : public lazy_diagnostic_path
|
||||
class test_lazy_path : public lazy_path
|
||||
{
|
||||
public:
|
||||
test_lazy_path (pretty_printer &pp)
|
||||
: lazy_diagnostic_path (m_logical_loc_mgr),
|
||||
: lazy_path (m_logical_loc_mgr),
|
||||
m_pp (pp)
|
||||
{
|
||||
}
|
||||
std::unique_ptr<diagnostic_path> make_inner_path () const final override
|
||||
std::unique_ptr<path> make_inner_path () const final override
|
||||
{
|
||||
tree fntype_void_void
|
||||
= build_function_type_array (void_type_node, 0, nullptr);
|
||||
@@ -214,7 +216,7 @@ test_emission (pretty_printer *event_pp)
|
||||
/* Run all of the selftests within this file. */
|
||||
|
||||
void
|
||||
lazy_diagnostic_path_cc_tests ()
|
||||
diagnostics_lazy_paths_cc_tests ()
|
||||
{
|
||||
/* In a few places we use the global dc's printer to determine
|
||||
colorization so ensure this off during the tests. */
|
||||
@@ -18,13 +18,16 @@ You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef GCC_LAZY_DIAGNOSTIC_PATH_H
|
||||
#define GCC_LAZY_DIAGNOSTIC_PATH_H
|
||||
#ifndef GCC_DIAGNOSTICS_LAZY_PATHS_H
|
||||
#define GCC_DIAGNOSTICS_LAZY_PATHS_H
|
||||
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
|
||||
/* An implementation of diagnostic_path which has a trivial ctor
|
||||
and lazily creates another diagnostic_path the first time the path
|
||||
namespace diagnostics {
|
||||
namespace paths {
|
||||
|
||||
/* An implementation of diagnostics::paths::path which has a trivial ctor
|
||||
and lazily creates another path the first time the path
|
||||
is queried, deferring to this inner path for all queries.
|
||||
|
||||
Use this to avoid expensive path creation logic when creating
|
||||
@@ -32,16 +35,16 @@ along with GCC; see the file COPYING3. If not see
|
||||
is actually used by a diagnostic, and thus avoided for warnings that
|
||||
are disabled. */
|
||||
|
||||
class lazy_diagnostic_path : public diagnostic_path
|
||||
class lazy_path : public path
|
||||
{
|
||||
public:
|
||||
virtual ~lazy_diagnostic_path () {}
|
||||
virtual ~lazy_path () {}
|
||||
|
||||
unsigned num_events () const final override;
|
||||
const diagnostic_event & get_event (int idx) const final override;
|
||||
const event & get_event (int idx) const final override;
|
||||
unsigned num_threads () const final override;
|
||||
const diagnostic_thread &
|
||||
get_thread (diagnostic_thread_id_t) const final override;
|
||||
const thread &
|
||||
get_thread (thread_id_t) const final override;
|
||||
bool
|
||||
same_function_p (int event_idx_a,
|
||||
int event_idx_b) const final override;
|
||||
@@ -49,16 +52,19 @@ class lazy_diagnostic_path : public diagnostic_path
|
||||
bool generated_p () const { return m_inner_path != nullptr; }
|
||||
|
||||
protected:
|
||||
lazy_diagnostic_path (const logical_location_manager &logical_loc_mgr)
|
||||
: diagnostic_path (logical_loc_mgr)
|
||||
lazy_path (const logical_locations::manager &logical_loc_mgr)
|
||||
: path (logical_loc_mgr)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
void lazily_generate_path () const;
|
||||
virtual std::unique_ptr<diagnostic_path> make_inner_path () const = 0;
|
||||
virtual std::unique_ptr<path> make_inner_path () const = 0;
|
||||
|
||||
mutable std::unique_ptr<diagnostic_path> m_inner_path;
|
||||
mutable std::unique_ptr<path> m_inner_path;
|
||||
};
|
||||
|
||||
#endif /* ! GCC_LAZY_DIAGNOSTIC_PATH_H */
|
||||
} // namespace paths
|
||||
} // namespace diagnostics
|
||||
|
||||
#endif /* ! GCC_DIAGNOSTICS_LAZY_PATHS_H */
|
||||
@@ -28,15 +28,15 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "diagnostic.h"
|
||||
#include "diagnostic-macro-unwinding.h"
|
||||
#include "intl.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "gcc-rich-location.h"
|
||||
#include "diagnostic-color.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "diagnostic-label-effects.h"
|
||||
#include "pretty-print-markup.h"
|
||||
#include "selftest.h"
|
||||
#include "selftest-diagnostic.h"
|
||||
#include "selftest-diagnostic-path.h"
|
||||
#include "diagnostics/selftest-paths.h"
|
||||
#include "text-art/theme.h"
|
||||
#include "diagnostic-format-text.h"
|
||||
#include "diagnostic-format-html.h"
|
||||
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
namespace {
|
||||
|
||||
using namespace diagnostics;
|
||||
using namespace diagnostics::paths;
|
||||
|
||||
/* A bundle of state for printing a path. */
|
||||
|
||||
@@ -85,18 +86,18 @@ private:
|
||||
};
|
||||
|
||||
/* Subclass of range_label for showing a particular event
|
||||
when showing a consecutive run of events within a diagnostic_path as
|
||||
when showing a consecutive run of events within a diagnostic path as
|
||||
labelled ranges within one gcc_rich_location. */
|
||||
|
||||
class path_label : public range_label
|
||||
{
|
||||
public:
|
||||
path_label (const diagnostic_path &path,
|
||||
path_label (const path &path_,
|
||||
const pretty_printer &ref_pp,
|
||||
unsigned start_idx,
|
||||
bool colorize,
|
||||
bool allow_emojis)
|
||||
: m_path (path),
|
||||
: m_path (path_),
|
||||
m_ref_pp (ref_pp),
|
||||
m_start_idx (start_idx), m_effects (*this),
|
||||
m_colorize (colorize), m_allow_emojis (allow_emojis)
|
||||
@@ -105,18 +106,17 @@ class path_label : public range_label
|
||||
label_text get_text (unsigned range_idx) const final override
|
||||
{
|
||||
unsigned event_idx = m_start_idx + range_idx;
|
||||
const diagnostic_event &event = m_path.get_event (event_idx);
|
||||
const event &ev = m_path.get_event (event_idx);
|
||||
|
||||
const diagnostic_event::meaning meaning (event.get_meaning ());
|
||||
const event::meaning meaning (ev.get_meaning ());
|
||||
|
||||
auto pp = m_ref_pp.clone ();
|
||||
pp_show_color (pp.get ()) = m_colorize;
|
||||
diagnostic_event_id_t event_id (event_idx);
|
||||
|
||||
event_id_t event_id (event_idx);
|
||||
pp_printf (pp.get (), "%@", &event_id);
|
||||
pp_space (pp.get ());
|
||||
|
||||
if (meaning.m_verb == diagnostic_event::verb::danger
|
||||
if (meaning.m_verb == event::verb::danger
|
||||
&& m_allow_emojis)
|
||||
{
|
||||
pp_unicode_character (pp.get (), 0x26A0); /* U+26A0 WARNING SIGN. */
|
||||
@@ -130,7 +130,7 @@ class path_label : public range_label
|
||||
pp_string (pp.get (), " ");
|
||||
}
|
||||
|
||||
event.print_desc (*pp.get ());
|
||||
ev.print_desc (*pp.get ());
|
||||
|
||||
label_text result
|
||||
= label_text::take (xstrdup (pp_formatted_text (pp.get ())));
|
||||
@@ -152,28 +152,28 @@ class path_label : public range_label
|
||||
}
|
||||
bool has_in_edge (unsigned range_idx) const final override
|
||||
{
|
||||
if (const diagnostic_event *prev_event
|
||||
if (const event *prev_event
|
||||
= m_path_label.get_prev_event (range_idx))
|
||||
return prev_event->connect_to_next_event_p ();
|
||||
return false;
|
||||
}
|
||||
bool has_out_edge (unsigned range_idx) const final override
|
||||
{
|
||||
const diagnostic_event &event = m_path_label.get_event (range_idx);
|
||||
return event.connect_to_next_event_p ();
|
||||
const event &ev = m_path_label.get_event (range_idx);
|
||||
return ev.connect_to_next_event_p ();
|
||||
}
|
||||
|
||||
private:
|
||||
const path_label &m_path_label;
|
||||
};
|
||||
|
||||
const diagnostic_event &get_event (unsigned range_idx) const
|
||||
const event &get_event (unsigned range_idx) const
|
||||
{
|
||||
unsigned event_idx = m_start_idx + range_idx;
|
||||
return m_path.get_event (event_idx);
|
||||
}
|
||||
|
||||
const diagnostic_event *get_prev_event (unsigned range_idx) const
|
||||
const event *get_prev_event (unsigned range_idx) const
|
||||
{
|
||||
if (m_start_idx + range_idx == 0)
|
||||
return nullptr;
|
||||
@@ -181,7 +181,7 @@ class path_label : public range_label
|
||||
return &m_path.get_event (event_idx);
|
||||
}
|
||||
|
||||
const diagnostic_path &m_path;
|
||||
const path &m_path;
|
||||
const pretty_printer &m_ref_pp;
|
||||
unsigned m_start_idx;
|
||||
path_label_effects m_effects;
|
||||
@@ -190,20 +190,20 @@ class path_label : public range_label
|
||||
};
|
||||
|
||||
/* Return true if E1 and E2 can be consolidated into the same run of events
|
||||
when printing a diagnostic_path. */
|
||||
when printing a diagnostic path. */
|
||||
|
||||
static bool
|
||||
can_consolidate_events (const diagnostic_path &path,
|
||||
const diagnostic_event &e1,
|
||||
can_consolidate_events (const path &p,
|
||||
const event &e1,
|
||||
unsigned ev1_idx,
|
||||
const diagnostic_event &e2,
|
||||
const event &e2,
|
||||
unsigned ev2_idx,
|
||||
bool check_locations)
|
||||
{
|
||||
if (e1.get_thread_id () != e2.get_thread_id ())
|
||||
return false;
|
||||
|
||||
if (!path.same_function_p (ev1_idx, ev2_idx))
|
||||
if (!p.same_function_p (ev1_idx, ev2_idx))
|
||||
return false;
|
||||
|
||||
if (e1.get_stack_depth () != e2.get_stack_depth ())
|
||||
@@ -233,16 +233,16 @@ struct event_range;
|
||||
struct path_summary;
|
||||
class thread_event_printer;
|
||||
|
||||
/* A bundle of information about all of the events in a diagnostic_path
|
||||
/* A bundle of information about all of the events in a diagnostic path
|
||||
relating to a specific path, for use by path_summary. */
|
||||
|
||||
class per_thread_summary
|
||||
{
|
||||
public:
|
||||
per_thread_summary (const diagnostic_path &path,
|
||||
per_thread_summary (const path &path_,
|
||||
const logical_locations::manager &logical_loc_mgr,
|
||||
label_text name, unsigned swimlane_idx)
|
||||
: m_path (path),
|
||||
: m_path (path_),
|
||||
m_logical_loc_mgr (logical_loc_mgr),
|
||||
m_name (std::move (name)),
|
||||
m_swimlane_idx (swimlane_idx),
|
||||
@@ -269,7 +269,7 @@ private:
|
||||
friend class thread_event_printer;
|
||||
friend struct event_range;
|
||||
|
||||
const diagnostic_path &m_path;
|
||||
const path &m_path;
|
||||
const logical_locations::manager &m_logical_loc_mgr;
|
||||
|
||||
const label_text m_name;
|
||||
@@ -281,7 +281,7 @@ private:
|
||||
// The event ranges specific to this thread:
|
||||
auto_vec<event_range *> m_event_ranges;
|
||||
|
||||
const diagnostic_event *m_last_event;
|
||||
const event *m_last_event;
|
||||
|
||||
int m_min_depth;
|
||||
int m_max_depth;
|
||||
@@ -400,7 +400,7 @@ emit_svg_arrow (xml::printer &xp, int old_depth, int new_depth)
|
||||
xp.add_raw (pp_formatted_text (pp));
|
||||
}
|
||||
|
||||
/* A range of consecutive events within a diagnostic_path, all within the
|
||||
/* A range of consecutive events within a diagnostic path, all within the
|
||||
same thread, and with the same fndecl and stack_depth, and which are suitable
|
||||
to print with a single call to diagnostic_show_locus. */
|
||||
struct event_range
|
||||
@@ -425,7 +425,7 @@ struct event_range
|
||||
the events already on this source line, *and* a new event at COLUMN. */
|
||||
bool
|
||||
can_add_label_for_event_p (bool has_in_edge,
|
||||
const diagnostic_event *prev_event,
|
||||
const event *prev_event,
|
||||
bool has_out_edge,
|
||||
int column) const
|
||||
{
|
||||
@@ -490,20 +490,20 @@ struct event_range
|
||||
int m_max_label_source_column;
|
||||
};
|
||||
|
||||
event_range (const diagnostic_path &path,
|
||||
event_range (const path &path_,
|
||||
const pretty_printer &ref_pp,
|
||||
unsigned start_idx,
|
||||
const diagnostic_event &initial_event,
|
||||
const event &initial_event,
|
||||
per_thread_summary &t,
|
||||
bool show_event_links,
|
||||
bool colorize_labels,
|
||||
bool allow_emojis)
|
||||
: m_path (path),
|
||||
: m_path (path_),
|
||||
m_initial_event (initial_event),
|
||||
m_logical_loc (initial_event.get_logical_location ()),
|
||||
m_stack_depth (initial_event.get_stack_depth ()),
|
||||
m_start_idx (start_idx), m_end_idx (start_idx),
|
||||
m_path_label (path, ref_pp,
|
||||
m_path_label (path_, ref_pp,
|
||||
start_idx, colorize_labels, allow_emojis),
|
||||
m_richloc (initial_event.get_location (), &m_path_label, nullptr),
|
||||
m_thread_id (initial_event.get_thread_id ()),
|
||||
@@ -518,7 +518,7 @@ struct event_range
|
||||
per_source_line_info &source_line_info
|
||||
= get_per_source_line_info (exploc.line);
|
||||
|
||||
const diagnostic_event *prev_thread_event = t.m_last_event;
|
||||
const event *prev_thread_event = t.m_last_event;
|
||||
const bool has_in_edge
|
||||
= (prev_thread_event
|
||||
? prev_thread_event->connect_to_next_event_p ()
|
||||
@@ -542,7 +542,7 @@ struct event_range
|
||||
}
|
||||
|
||||
bool maybe_add_event (const path_print_policy &policy,
|
||||
const diagnostic_event &new_ev,
|
||||
const event &new_ev,
|
||||
unsigned new_ev_idx,
|
||||
bool check_rich_locations)
|
||||
{
|
||||
@@ -559,7 +559,7 @@ struct event_range
|
||||
(line_table, new_ev.get_location (), LOCATION_ASPECT_CARET);
|
||||
per_source_line_info &source_line_info
|
||||
= get_per_source_line_info (exploc.line);
|
||||
const diagnostic_event *prev_event = nullptr;
|
||||
const event *prev_event = nullptr;
|
||||
if (new_ev_idx > 0)
|
||||
prev_event = &m_path.get_event (new_ev_idx - 1);
|
||||
const bool has_in_edge = (prev_event
|
||||
@@ -626,7 +626,7 @@ struct event_range
|
||||
{
|
||||
for (unsigned i = m_start_idx; i <= m_end_idx; i++)
|
||||
{
|
||||
const diagnostic_event &iter_event = m_path.get_event (i);
|
||||
const event &iter_event = m_path.get_event (i);
|
||||
diagnostic_event_id_t event_id (i);
|
||||
pp_printf (&pp, " %@: ", &event_id);
|
||||
iter_event.print_desc (pp);
|
||||
@@ -684,7 +684,7 @@ struct event_range
|
||||
{
|
||||
for (unsigned i = m_start_idx; i <= m_end_idx; i++)
|
||||
{
|
||||
const diagnostic_event &iter_event = m_path.get_event (i);
|
||||
const event &iter_event = m_path.get_event (i);
|
||||
diagnostic_event_id_t event_id (i);
|
||||
pretty_printer pp;
|
||||
pp_printf (&pp, " %@: ", &event_id);
|
||||
@@ -707,22 +707,22 @@ struct event_range
|
||||
// TODO: show macro expansions
|
||||
}
|
||||
|
||||
const diagnostic_path &m_path;
|
||||
const diagnostic_event &m_initial_event;
|
||||
const path &m_path;
|
||||
const event &m_initial_event;
|
||||
logical_locations::key m_logical_loc;
|
||||
int m_stack_depth;
|
||||
unsigned m_start_idx;
|
||||
unsigned m_end_idx;
|
||||
path_label m_path_label;
|
||||
gcc_rich_location m_richloc;
|
||||
diagnostic_thread_id_t m_thread_id;
|
||||
thread_id_t m_thread_id;
|
||||
per_thread_summary &m_per_thread_summary;
|
||||
hash_map<int_hash<int, -1, -2>,
|
||||
per_source_line_info> m_source_line_info_map;
|
||||
bool m_show_event_links;
|
||||
};
|
||||
|
||||
/* A struct for grouping together the events in a diagnostic_path into
|
||||
/* A struct for grouping together the events in a path into
|
||||
ranges of events, partitioned by thread and by stack frame (i.e. by fndecl
|
||||
and stack depth). */
|
||||
|
||||
@@ -730,7 +730,7 @@ struct path_summary
|
||||
{
|
||||
path_summary (const path_print_policy &policy,
|
||||
const pretty_printer &ref_pp,
|
||||
const diagnostic_path &path,
|
||||
const path &path_,
|
||||
bool check_rich_locations,
|
||||
bool colorize = false,
|
||||
bool show_event_links = true);
|
||||
@@ -742,7 +742,7 @@ struct path_summary
|
||||
unsigned get_num_ranges () const { return m_ranges.length (); }
|
||||
bool multithreaded_p () const { return m_per_thread_summary.length () > 1; }
|
||||
|
||||
const per_thread_summary &get_events_for_thread_id (diagnostic_thread_id_t tid)
|
||||
const per_thread_summary &get_events_for_thread_id (thread_id_t tid)
|
||||
{
|
||||
per_thread_summary **slot = m_thread_id_to_events.get (tid);
|
||||
gcc_assert (slot);
|
||||
@@ -753,20 +753,20 @@ struct path_summary
|
||||
const logical_locations::manager &m_logical_loc_mgr;
|
||||
auto_delete_vec <event_range> m_ranges;
|
||||
auto_delete_vec <per_thread_summary> m_per_thread_summary;
|
||||
hash_map<int_hash<diagnostic_thread_id_t, -1, -2>,
|
||||
hash_map<int_hash<thread_id_t, -1, -2>,
|
||||
per_thread_summary *> m_thread_id_to_events;
|
||||
|
||||
private:
|
||||
per_thread_summary &
|
||||
get_or_create_events_for_thread_id (const diagnostic_path &path,
|
||||
diagnostic_thread_id_t tid)
|
||||
get_or_create_events_for_thread_id (const path &path_,
|
||||
thread_id_t tid)
|
||||
{
|
||||
if (per_thread_summary **slot = m_thread_id_to_events.get (tid))
|
||||
return **slot;
|
||||
|
||||
const diagnostic_thread &thread = path.get_thread (tid);
|
||||
const thread &thread = path_.get_thread (tid);
|
||||
per_thread_summary *pts
|
||||
= new per_thread_summary (path,
|
||||
= new per_thread_summary (path_,
|
||||
m_logical_loc_mgr,
|
||||
thread.get_name (false),
|
||||
m_per_thread_summary.length ());
|
||||
@@ -800,40 +800,40 @@ per_thread_summary::interprocedural_p () const
|
||||
|
||||
path_summary::path_summary (const path_print_policy &policy,
|
||||
const pretty_printer &ref_pp,
|
||||
const diagnostic_path &path,
|
||||
const path &path_,
|
||||
bool check_rich_locations,
|
||||
bool colorize,
|
||||
bool show_event_links)
|
||||
: m_logical_loc_mgr (path.get_logical_location_manager ())
|
||||
: m_logical_loc_mgr (path_.get_logical_location_manager ())
|
||||
{
|
||||
const unsigned num_events = path.num_events ();
|
||||
const unsigned num_events = path_.num_events ();
|
||||
|
||||
event_range *cur_event_range = nullptr;
|
||||
for (unsigned idx = 0; idx < num_events; idx++)
|
||||
{
|
||||
const diagnostic_event &event = path.get_event (idx);
|
||||
const diagnostic_thread_id_t thread_id = event.get_thread_id ();
|
||||
const event &ev = path_.get_event (idx);
|
||||
const thread_id_t thread_id = ev.get_thread_id ();
|
||||
per_thread_summary &pts
|
||||
= get_or_create_events_for_thread_id (path, thread_id);
|
||||
= get_or_create_events_for_thread_id (path_, thread_id);
|
||||
|
||||
pts.update_depth_limits (event.get_stack_depth ());
|
||||
pts.update_depth_limits (ev.get_stack_depth ());
|
||||
|
||||
if (cur_event_range)
|
||||
if (cur_event_range->maybe_add_event (policy,
|
||||
event,
|
||||
ev,
|
||||
idx, check_rich_locations))
|
||||
continue;
|
||||
|
||||
auto theme = policy.get_diagram_theme ();
|
||||
const bool allow_emojis = theme ? theme->emojis_p () : false;
|
||||
cur_event_range = new event_range (path, ref_pp,
|
||||
idx, event, pts,
|
||||
cur_event_range = new event_range (path_, ref_pp,
|
||||
idx, ev, pts,
|
||||
show_event_links,
|
||||
colorize,
|
||||
allow_emojis);
|
||||
m_ranges.safe_push (cur_event_range);
|
||||
pts.m_event_ranges.safe_push (cur_event_range);
|
||||
pts.m_last_event = &event;
|
||||
pts.m_last_event = &ev;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1286,8 +1286,8 @@ print_path_summary_as_html (const path_summary &ps,
|
||||
class element_event_desc : public pp_element
|
||||
{
|
||||
public:
|
||||
element_event_desc (const diagnostic_event &event)
|
||||
: m_event (event)
|
||||
element_event_desc (const event &event_)
|
||||
: m_event (event_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1299,15 +1299,15 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const diagnostic_event &m_event;
|
||||
const event &m_event;
|
||||
};
|
||||
|
||||
/* Print PATH according to the context's path_format. */
|
||||
|
||||
void
|
||||
diagnostic_text_output_format::print_path (const diagnostic_path &path)
|
||||
diagnostic_text_output_format::print_path (const path &path_)
|
||||
{
|
||||
const unsigned num_events = path.num_events ();
|
||||
const unsigned num_events = path_.num_events ();
|
||||
|
||||
switch (get_context ().get_path_format ())
|
||||
{
|
||||
@@ -1318,36 +1318,36 @@ diagnostic_text_output_format::print_path (const diagnostic_path &path)
|
||||
case DPF_SEPARATE_EVENTS:
|
||||
{
|
||||
/* A note per event. */
|
||||
auto &logical_loc_mgr = path.get_logical_location_manager ();
|
||||
auto &logical_loc_mgr = path_.get_logical_location_manager ();
|
||||
for (unsigned i = 0; i < num_events; i++)
|
||||
{
|
||||
const diagnostic_event &event = path.get_event (i);
|
||||
element_event_desc e_event_desc (event);
|
||||
const event &ev = path_.get_event (i);
|
||||
element_event_desc e_event_desc (ev);
|
||||
diagnostic_event_id_t event_id (i);
|
||||
if (get_context ().show_path_depths_p ())
|
||||
{
|
||||
int stack_depth = event.get_stack_depth ();
|
||||
int stack_depth = ev.get_stack_depth ();
|
||||
/* -fdiagnostics-path-format=separate-events doesn't print
|
||||
fndecl information, so with -fdiagnostics-show-path-depths
|
||||
print the fndecls too, if any. */
|
||||
if (logical_locations::key logical_loc
|
||||
= event.get_logical_location ())
|
||||
= ev.get_logical_location ())
|
||||
{
|
||||
label_text name
|
||||
(logical_loc_mgr.get_name_for_path_output (logical_loc));
|
||||
inform (event.get_location (),
|
||||
inform (ev.get_location (),
|
||||
"%@ %e (fndecl %qs, depth %i)",
|
||||
&event_id, &e_event_desc,
|
||||
name.get (), stack_depth);
|
||||
}
|
||||
else
|
||||
inform (event.get_location (),
|
||||
inform (ev.get_location (),
|
||||
"%@ %e (depth %i)",
|
||||
&event_id, &e_event_desc,
|
||||
stack_depth);
|
||||
}
|
||||
else
|
||||
inform (event.get_location (),
|
||||
inform (ev.get_location (),
|
||||
"%@ %e", &event_id, &e_event_desc);
|
||||
}
|
||||
}
|
||||
@@ -1363,7 +1363,7 @@ diagnostic_text_output_format::print_path (const diagnostic_path &path)
|
||||
const bool show_event_links = m_source_printing.show_event_links_p;
|
||||
path_summary summary (policy,
|
||||
*pp,
|
||||
path,
|
||||
path_,
|
||||
check_rich_locations,
|
||||
colorize,
|
||||
show_event_links);
|
||||
@@ -1378,12 +1378,12 @@ diagnostic_text_output_format::print_path (const diagnostic_path &path)
|
||||
}
|
||||
}
|
||||
|
||||
/* Print PATH as HTML to XP, using DC and DSPP for settings.
|
||||
/* Print PATH_ as HTML to XP, using DC and DSPP for settings.
|
||||
If non-null, use EVENT_LABEL_WRITER when writing events. */
|
||||
|
||||
void
|
||||
print_path_as_html (xml::printer &xp,
|
||||
const diagnostic_path &path,
|
||||
const path &path_,
|
||||
diagnostic_context &dc,
|
||||
html_label_writer *event_label_writer,
|
||||
const diagnostic_source_print_policy &dspp)
|
||||
@@ -1396,7 +1396,7 @@ print_path_as_html (xml::printer &xp,
|
||||
const bool show_event_links = source_printing_opts.show_event_links_p;
|
||||
path_summary summary (policy,
|
||||
*dc.get_reference_printer (),
|
||||
path,
|
||||
path_,
|
||||
check_rich_locations,
|
||||
colorize,
|
||||
show_event_links);
|
||||
@@ -1408,16 +1408,16 @@ print_path_as_html (xml::printer &xp,
|
||||
|
||||
namespace selftest {
|
||||
|
||||
/* Return true iff all events in PATH have locations for which column data
|
||||
/* Return true iff all events in PATH_ have locations for which column data
|
||||
is available, so that selftests that require precise string output can
|
||||
bail out for awkward line_table cases. */
|
||||
|
||||
static bool
|
||||
path_events_have_column_data_p (const diagnostic_path &path)
|
||||
path_events_have_column_data_p (const path &path_)
|
||||
{
|
||||
for (unsigned idx = 0; idx < path.num_events (); idx++)
|
||||
for (unsigned idx = 0; idx < path_.num_events (); idx++)
|
||||
{
|
||||
location_t event_loc = path.get_event (idx).get_location ();
|
||||
location_t event_loc = path_.get_event (idx).get_location ();
|
||||
if (line_table->get_pure_location (event_loc)
|
||||
> LINE_MAP_MAX_LOCATION_WITH_COLS)
|
||||
return false;
|
||||
@@ -1709,7 +1709,7 @@ test_interprocedural_path_2 (pretty_printer *event_pp)
|
||||
}
|
||||
|
||||
/* Verify that print_path_summary is sane in the face of a recursive
|
||||
diagnostic_path. */
|
||||
diagnostic path. */
|
||||
|
||||
static void
|
||||
test_recursion (pretty_printer *event_pp)
|
||||
@@ -2692,7 +2692,7 @@ control_flow_tests (const line_table_case &case_)
|
||||
/* Run all of the selftests within this file. */
|
||||
|
||||
void
|
||||
diagnostic_path_output_cc_tests ()
|
||||
diagnostics_paths_output_cc_tests ()
|
||||
{
|
||||
pretty_printer pp;
|
||||
pp_show_color (&pp) = false;
|
||||
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "system.h"
|
||||
#include "coretypes.h"
|
||||
#include "diagnostic.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "diagnostics/state-graphs.h"
|
||||
|
||||
/* Disable warnings about missing quoting in GCC diagnostics for the print
|
||||
@@ -37,13 +37,14 @@ along with GCC; see the file COPYING3. If not see
|
||||
#endif
|
||||
|
||||
using namespace diagnostics;
|
||||
using namespace diagnostics::paths;
|
||||
|
||||
/* class diagnostic_event. */
|
||||
/* class diagnostics::paths::event. */
|
||||
|
||||
/* struct diagnostic_event::meaning. */
|
||||
/* struct event::meaning. */
|
||||
|
||||
void
|
||||
diagnostic_event::meaning::dump_to_pp (pretty_printer *pp) const
|
||||
event::meaning::dump_to_pp (pretty_printer *pp) const
|
||||
{
|
||||
bool need_comma = false;
|
||||
pp_character (pp, '{');
|
||||
@@ -73,7 +74,7 @@ diagnostic_event::meaning::dump_to_pp (pretty_printer *pp) const
|
||||
threadFlowLocation "kinds" property (SARIF v2.1.0 section 3.38.8). */
|
||||
|
||||
const char *
|
||||
diagnostic_event::meaning::maybe_get_verb_str (enum verb v)
|
||||
event::meaning::maybe_get_verb_str (enum verb v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
@@ -104,7 +105,7 @@ diagnostic_event::meaning::maybe_get_verb_str (enum verb v)
|
||||
threadFlowLocation "kinds" property (SARIF v2.1.0 section 3.38.8). */
|
||||
|
||||
const char *
|
||||
diagnostic_event::meaning::maybe_get_noun_str (enum noun n)
|
||||
event::meaning::maybe_get_noun_str (enum noun n)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
@@ -131,7 +132,7 @@ diagnostic_event::meaning::maybe_get_noun_str (enum noun n)
|
||||
threadFlowLocation "kinds" property (SARIF v2.1.0 section 3.38.8). */
|
||||
|
||||
const char *
|
||||
diagnostic_event::meaning::maybe_get_property_str (enum property p)
|
||||
event::meaning::maybe_get_property_str (enum property p)
|
||||
{
|
||||
switch (p)
|
||||
{
|
||||
@@ -150,7 +151,7 @@ diagnostic_event::meaning::maybe_get_property_str (enum property p)
|
||||
(for debugging/logging purposes). */
|
||||
|
||||
label_text
|
||||
diagnostic_event::get_desc (pretty_printer &ref_pp) const
|
||||
event::get_desc (pretty_printer &ref_pp) const
|
||||
{
|
||||
auto pp = ref_pp.clone ();
|
||||
pp_show_color (pp.get ()) = false;
|
||||
@@ -158,30 +159,30 @@ diagnostic_event::get_desc (pretty_printer &ref_pp) const
|
||||
return label_text::take (xstrdup (pp_formatted_text (pp.get ())));
|
||||
}
|
||||
|
||||
// Base implementation of diagnostic_event::maybe_make_diagnostic_state_graph
|
||||
// Base implementation of event::maybe_make_diagnostic_state_graph
|
||||
|
||||
std::unique_ptr<diagnostics::digraphs::digraph>
|
||||
diagnostic_event::maybe_make_diagnostic_state_graph (bool) const
|
||||
std::unique_ptr<digraphs::digraph>
|
||||
event::maybe_make_diagnostic_state_graph (bool) const
|
||||
{
|
||||
// Don't attempt to make a state graph:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* class diagnostic_path. */
|
||||
/* class diagnostics::paths::path. */
|
||||
|
||||
/* Subroutine of diagnostic_path::interprocedural_p.
|
||||
/* Subroutine of path::interprocedural_p.
|
||||
Look for the first event in this path that is within a function
|
||||
i.e. has a non-null logical location for which function_p is true.
|
||||
If found, write its index to *OUT_IDX and return true.
|
||||
Otherwise return false. */
|
||||
|
||||
bool
|
||||
diagnostic_path::get_first_event_in_a_function (unsigned *out_idx) const
|
||||
path::get_first_event_in_a_function (unsigned *out_idx) const
|
||||
{
|
||||
const unsigned num = num_events ();
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
{
|
||||
const diagnostic_event &event = get_event (i);
|
||||
const event &event = get_event (i);
|
||||
if (logical_locations::key logical_loc = event.get_logical_location ())
|
||||
if (m_logical_loc_mgr.function_p (logical_loc))
|
||||
{
|
||||
@@ -196,14 +197,14 @@ diagnostic_path::get_first_event_in_a_function (unsigned *out_idx) const
|
||||
function, or false if it is purely intraprocedural. */
|
||||
|
||||
bool
|
||||
diagnostic_path::interprocedural_p () const
|
||||
path::interprocedural_p () const
|
||||
{
|
||||
/* Ignore leading events that are outside of any function. */
|
||||
unsigned first_fn_event_idx;
|
||||
if (!get_first_event_in_a_function (&first_fn_event_idx))
|
||||
return false;
|
||||
|
||||
const diagnostic_event &first_fn_event = get_event (first_fn_event_idx);
|
||||
const event &first_fn_event = get_event (first_fn_event_idx);
|
||||
int first_fn_stack_depth = first_fn_event.get_stack_depth ();
|
||||
|
||||
const unsigned num = num_events ();
|
||||
@@ -220,10 +221,10 @@ diagnostic_path::interprocedural_p () const
|
||||
/* Print PATH by emitting a dummy "note" associated with it. */
|
||||
|
||||
DEBUG_FUNCTION
|
||||
void debug (diagnostic_path *path)
|
||||
void debug (path *p)
|
||||
{
|
||||
rich_location richloc (line_table, UNKNOWN_LOCATION);
|
||||
richloc.set_path (path);
|
||||
richloc.set_path (p);
|
||||
inform (&richloc, "debug path");
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef GCC_DIAGNOSTIC_PATH_H
|
||||
#define GCC_DIAGNOSTIC_PATH_H
|
||||
#ifndef GCC_DIAGNOSTICS_PATHS_H
|
||||
#define GCC_DIAGNOSTICS_PATHS_H
|
||||
|
||||
#include "diagnostic.h" /* for ATTRIBUTE_GCC_DIAG. */
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "diagnostics/logical-locations.h"
|
||||
|
||||
namespace xml { class document; }
|
||||
@@ -31,12 +31,18 @@ class sarif_builder;
|
||||
class sarif_object;
|
||||
|
||||
namespace diagnostics {
|
||||
namespace digraphs {
|
||||
namespace digraphs {
|
||||
class digraph;
|
||||
} // namespace digraphs
|
||||
} // namespace digraphs
|
||||
namespace logical_locations {
|
||||
class manager;
|
||||
} // logical_locations
|
||||
} //namespace diagnostics
|
||||
|
||||
/* A diagnostic_path is an optional additional piece of metadata associated
|
||||
namespace diagnostics {
|
||||
namespace paths {
|
||||
|
||||
/* A diagnostics::paths::path is an optional additional piece of metadata associated
|
||||
with a diagnostic (via its rich_location).
|
||||
|
||||
It describes a sequence of events predicted by the compiler that
|
||||
@@ -74,9 +80,9 @@ namespace digraphs {
|
||||
/* Abstract base classes, describing events within a path, and the paths
|
||||
themselves. */
|
||||
|
||||
/* One event within a diagnostic_path. */
|
||||
/* One event within a path. */
|
||||
|
||||
class diagnostic_event
|
||||
class event
|
||||
{
|
||||
public:
|
||||
/* Enums for giving a sense of what this event means.
|
||||
@@ -148,7 +154,7 @@ class diagnostic_event
|
||||
enum property m_property;
|
||||
};
|
||||
|
||||
virtual ~diagnostic_event () {}
|
||||
virtual ~event () {}
|
||||
|
||||
virtual location_t get_location () const = 0;
|
||||
|
||||
@@ -160,7 +166,7 @@ class diagnostic_event
|
||||
virtual void print_desc (pretty_printer &pp) const = 0;
|
||||
|
||||
/* Get a logical location for this event, or null if there is none. */
|
||||
virtual diagnostics::logical_locations::key get_logical_location () const = 0;
|
||||
virtual logical_locations::key get_logical_location () const = 0;
|
||||
|
||||
virtual meaning get_meaning () const = 0;
|
||||
|
||||
@@ -168,7 +174,7 @@ class diagnostic_event
|
||||
next event (e.g. to highlight control flow). */
|
||||
virtual bool connect_to_next_event_p () const = 0;
|
||||
|
||||
virtual diagnostic_thread_id_t get_thread_id () const = 0;
|
||||
virtual thread_id_t get_thread_id () const = 0;
|
||||
|
||||
/* Hook for SARIF output to allow for adding diagnostic-specific
|
||||
properties to the threadFlowLocation object's property bag. */
|
||||
@@ -180,37 +186,35 @@ class diagnostic_event
|
||||
|
||||
/* Hook for capturing state at this event, potentially for visualizing
|
||||
in HTML output, or for adding to SARIF. */
|
||||
virtual std::unique_ptr<diagnostics::digraphs::digraph>
|
||||
virtual std::unique_ptr<digraphs::digraph>
|
||||
maybe_make_diagnostic_state_graph (bool debug) const;
|
||||
|
||||
label_text get_desc (pretty_printer &ref_pp) const;
|
||||
};
|
||||
|
||||
/* Abstract base class representing a thread of execution within
|
||||
a diagnostic_path.
|
||||
Each diagnostic_event is associated with one thread.
|
||||
Typically there is just one thread per diagnostic_path. */
|
||||
a diagnostics::paths::path.
|
||||
Each event is associated with one thread.
|
||||
Typically there is just one thread per diagnostics::paths::path. */
|
||||
|
||||
class diagnostic_thread
|
||||
class thread
|
||||
{
|
||||
public:
|
||||
virtual ~diagnostic_thread () {}
|
||||
virtual ~thread () {}
|
||||
virtual label_text get_name (bool can_colorize) const = 0;
|
||||
};
|
||||
|
||||
/* Abstract base class for getting at a sequence of events. */
|
||||
|
||||
class diagnostic_path
|
||||
class path
|
||||
{
|
||||
public:
|
||||
using logical_location_manager = diagnostics::logical_locations::manager;
|
||||
|
||||
virtual ~diagnostic_path () {}
|
||||
virtual ~path () {}
|
||||
virtual unsigned num_events () const = 0;
|
||||
virtual const diagnostic_event & get_event (int idx) const = 0;
|
||||
virtual const event & get_event (int idx) const = 0;
|
||||
virtual unsigned num_threads () const = 0;
|
||||
virtual const diagnostic_thread &
|
||||
get_thread (diagnostic_thread_id_t) const = 0;
|
||||
virtual const thread &
|
||||
get_thread (thread_id_t) const = 0;
|
||||
|
||||
/* Return true iff the two events are both within the same function,
|
||||
or both outside of any function. */
|
||||
@@ -221,13 +225,13 @@ class diagnostic_path
|
||||
bool interprocedural_p () const;
|
||||
bool multithreaded_p () const;
|
||||
|
||||
const logical_location_manager &get_logical_location_manager () const
|
||||
const logical_locations::manager &get_logical_location_manager () const
|
||||
{
|
||||
return m_logical_loc_mgr;
|
||||
}
|
||||
|
||||
protected:
|
||||
diagnostic_path (const logical_location_manager &logical_loc_mgr)
|
||||
path (const logical_locations::manager &logical_loc_mgr)
|
||||
: m_logical_loc_mgr (logical_loc_mgr)
|
||||
{
|
||||
}
|
||||
@@ -235,12 +239,15 @@ protected:
|
||||
private:
|
||||
bool get_first_event_in_a_function (unsigned *out_idx) const;
|
||||
|
||||
const logical_location_manager &m_logical_loc_mgr;
|
||||
const logical_locations::manager &m_logical_loc_mgr;
|
||||
};
|
||||
|
||||
} // namespace paths
|
||||
} // namespace diagnostics
|
||||
|
||||
/* Concrete subclasses of the above can be found in
|
||||
simple-diagnostic-path.h. */
|
||||
|
||||
extern void debug (diagnostic_path *path);
|
||||
extern void debug (diagnostics::paths::path *path);
|
||||
|
||||
#endif /* ! GCC_DIAGNOSTIC_PATH_H */
|
||||
#endif /* ! GCC_DIAGNOSTICS_PATHS_H */
|
||||
@@ -27,22 +27,24 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "demangle.h"
|
||||
#include "backtrace.h"
|
||||
#include "diagnostic.h"
|
||||
#include "selftest-diagnostic-path.h"
|
||||
#include "diagnostics/selftest-paths.h"
|
||||
|
||||
#if CHECKING_P
|
||||
|
||||
namespace selftest {
|
||||
|
||||
/* class test_diagnostic_path : public diagnostic_path. */
|
||||
using namespace diagnostics::paths;
|
||||
|
||||
/* class test_diagnostic_path : public diagnostics::paths::path. */
|
||||
|
||||
test_diagnostic_path::test_diagnostic_path (pretty_printer *event_pp)
|
||||
: diagnostic_path (m_test_logical_loc_mgr),
|
||||
: path (m_test_logical_loc_mgr),
|
||||
m_event_pp (event_pp)
|
||||
{
|
||||
add_thread ("main");
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_path::num_events vfunc for
|
||||
/* Implementation of path::num_events vfunc for
|
||||
test_diagnostic_path: simply get the number of events in the vec. */
|
||||
|
||||
unsigned
|
||||
@@ -54,7 +56,7 @@ test_diagnostic_path::num_events () const
|
||||
/* Implementation of diagnostic_path::get_event vfunc for
|
||||
test_diagnostic_path: simply return the event in the vec. */
|
||||
|
||||
const diagnostic_event &
|
||||
const event &
|
||||
test_diagnostic_path::get_event (int idx) const
|
||||
{
|
||||
return *m_events[idx];
|
||||
@@ -66,8 +68,8 @@ test_diagnostic_path::num_threads () const
|
||||
return m_threads.length ();
|
||||
}
|
||||
|
||||
const diagnostic_thread &
|
||||
test_diagnostic_path::get_thread (diagnostic_thread_id_t idx) const
|
||||
const thread &
|
||||
test_diagnostic_path::get_thread (thread_id_t idx) const
|
||||
{
|
||||
return *m_threads[idx];
|
||||
}
|
||||
@@ -80,7 +82,7 @@ test_diagnostic_path::same_function_p (int event_idx_a,
|
||||
== m_events[event_idx_b]->get_logical_location ());
|
||||
}
|
||||
|
||||
diagnostic_thread_id_t
|
||||
thread_id_t
|
||||
test_diagnostic_path::add_thread (const char *name)
|
||||
{
|
||||
m_threads.safe_push (new test_diagnostic_thread (name));
|
||||
@@ -95,7 +97,7 @@ test_diagnostic_path::add_thread (const char *name)
|
||||
|
||||
Return the id of the new event. */
|
||||
|
||||
diagnostic_event_id_t
|
||||
event_id_t
|
||||
test_diagnostic_path::add_event (location_t loc,
|
||||
const char *funcname,
|
||||
int depth,
|
||||
@@ -126,11 +128,11 @@ test_diagnostic_path::add_event (location_t loc,
|
||||
|
||||
pp_clear_output_area (pp);
|
||||
|
||||
return diagnostic_event_id_t (m_events.length () - 1);
|
||||
return event_id_t (m_events.length () - 1);
|
||||
}
|
||||
|
||||
diagnostic_event_id_t
|
||||
test_diagnostic_path::add_thread_event (diagnostic_thread_id_t thread_id,
|
||||
event_id_t
|
||||
test_diagnostic_path::add_thread_event (thread_id_t thread_id,
|
||||
location_t loc,
|
||||
const char *funcname,
|
||||
int depth,
|
||||
@@ -163,7 +165,7 @@ test_diagnostic_path::add_thread_event (diagnostic_thread_id_t thread_id,
|
||||
|
||||
pp_clear_output_area (pp);
|
||||
|
||||
return diagnostic_event_id_t (m_events.length () - 1);
|
||||
return event_id_t (m_events.length () - 1);
|
||||
}
|
||||
|
||||
/* Mark the most recent event on this path (which must exist) as being
|
||||
@@ -179,7 +181,7 @@ test_diagnostic_path::connect_to_next_event ()
|
||||
void
|
||||
test_diagnostic_path::add_entry (const char *callee_name,
|
||||
int stack_depth,
|
||||
diagnostic_thread_id_t thread_id)
|
||||
thread_id_t thread_id)
|
||||
{
|
||||
add_thread_event (thread_id, UNKNOWN_LOCATION, callee_name, stack_depth,
|
||||
"entering %qs", callee_name);
|
||||
@@ -188,7 +190,7 @@ test_diagnostic_path::add_entry (const char *callee_name,
|
||||
void
|
||||
test_diagnostic_path::add_return (const char *caller_name,
|
||||
int stack_depth,
|
||||
diagnostic_thread_id_t thread_id)
|
||||
thread_id_t thread_id)
|
||||
{
|
||||
add_thread_event (thread_id, UNKNOWN_LOCATION, caller_name, stack_depth,
|
||||
"returning to %qs", caller_name);
|
||||
@@ -198,7 +200,7 @@ void
|
||||
test_diagnostic_path::add_call (const char *caller_name,
|
||||
int caller_stack_depth,
|
||||
const char *callee_name,
|
||||
diagnostic_thread_id_t thread_id)
|
||||
thread_id_t thread_id)
|
||||
{
|
||||
add_thread_event (thread_id, UNKNOWN_LOCATION,
|
||||
caller_name, caller_stack_depth,
|
||||
@@ -221,7 +223,7 @@ test_diagnostic_event (location_t loc,
|
||||
logical_location logical_loc,
|
||||
int depth,
|
||||
const char *desc,
|
||||
diagnostic_thread_id_t thread_id)
|
||||
thread_id_t thread_id)
|
||||
: m_loc (loc),
|
||||
m_logical_loc (logical_loc),
|
||||
m_depth (depth), m_desc (xstrdup (desc)),
|
||||
@@ -18,10 +18,10 @@ You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef GCC_SELFTEST_DIAGNOSTIC_PATH_H
|
||||
#define GCC_SELFTEST_DIAGNOSTIC_PATH_H
|
||||
#ifndef GCC_DIAGNOSTICS_SELFTEST_PATHS_H
|
||||
#define GCC_DIAGNOSTICS_SELFTEST_PATHS_H
|
||||
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "diagnostics/selftest-logical-locations.h"
|
||||
|
||||
/* The selftest code should entirely disappear in a production
|
||||
@@ -38,16 +38,17 @@ namespace selftest {
|
||||
|
||||
/* An implementation of diagnostic_event. */
|
||||
|
||||
class test_diagnostic_event : public diagnostic_event
|
||||
class test_diagnostic_event : public diagnostics::paths::event
|
||||
{
|
||||
public:
|
||||
using logical_location = diagnostics::logical_locations::key;
|
||||
using thread_id_t = diagnostics::paths::thread_id_t;
|
||||
|
||||
test_diagnostic_event (location_t loc,
|
||||
logical_location logical_loc,
|
||||
int depth,
|
||||
const char *desc,
|
||||
diagnostic_thread_id_t thread_id = 0);
|
||||
thread_id_t thread_id = 0);
|
||||
~test_diagnostic_event ();
|
||||
|
||||
location_t get_location () const final override { return m_loc; }
|
||||
@@ -68,7 +69,7 @@ class test_diagnostic_event : public diagnostic_event
|
||||
{
|
||||
return m_connected_to_next_event;
|
||||
}
|
||||
diagnostic_thread_id_t get_thread_id () const final override
|
||||
thread_id_t get_thread_id () const final override
|
||||
{
|
||||
return m_thread_id;
|
||||
}
|
||||
@@ -84,12 +85,12 @@ class test_diagnostic_event : public diagnostic_event
|
||||
int m_depth;
|
||||
char *m_desc; // has been formatted; doesn't get i18n-ed
|
||||
bool m_connected_to_next_event;
|
||||
diagnostic_thread_id_t m_thread_id;
|
||||
thread_id_t m_thread_id;
|
||||
};
|
||||
|
||||
/* A simple implementation of diagnostic_thread. */
|
||||
/* A simple implementation of diagnostics::paths::thread. */
|
||||
|
||||
class test_diagnostic_thread : public diagnostic_thread
|
||||
class test_diagnostic_thread : public diagnostics::paths::thread
|
||||
{
|
||||
public:
|
||||
test_diagnostic_thread (const char *name) : m_name (name) {}
|
||||
@@ -102,33 +103,38 @@ private:
|
||||
const char *m_name; // has been i18n-ed and formatted
|
||||
};
|
||||
|
||||
/* A concrete subclass of diagnostic_path for implementing selftests
|
||||
/* A concrete subclass of diagnostics::paths::path for implementing selftests
|
||||
- a vector of test_diagnostic_event instances
|
||||
- adds member functions for adding test event
|
||||
- does no translation of its events
|
||||
- has no dependency on "tree". */
|
||||
|
||||
class test_diagnostic_path : public diagnostic_path
|
||||
class test_diagnostic_path : public diagnostics::paths::path
|
||||
{
|
||||
public:
|
||||
using thread = diagnostics::paths::thread;
|
||||
using thread_id_t = diagnostics::paths::thread_id_t;
|
||||
using event = diagnostics::paths::event;
|
||||
using event_id_t = diagnostics::paths::event_id_t;
|
||||
|
||||
test_diagnostic_path (pretty_printer *event_pp);
|
||||
|
||||
unsigned num_events () const final override;
|
||||
const diagnostic_event & get_event (int idx) const final override;
|
||||
const event & get_event (int idx) const final override;
|
||||
unsigned num_threads () const final override;
|
||||
const diagnostic_thread &
|
||||
get_thread (diagnostic_thread_id_t) const final override;
|
||||
const thread &
|
||||
get_thread (thread_id_t) const final override;
|
||||
bool
|
||||
same_function_p (int event_idx_a,
|
||||
int event_idx_b) const final override;
|
||||
|
||||
diagnostic_thread_id_t add_thread (const char *name);
|
||||
thread_id_t add_thread (const char *name);
|
||||
|
||||
diagnostic_event_id_t add_event (location_t loc, const char *funcname, int depth,
|
||||
event_id_t add_event (location_t loc, const char *funcname, int depth,
|
||||
const char *fmt, ...)
|
||||
ATTRIBUTE_GCC_DIAG(5,6);
|
||||
diagnostic_event_id_t
|
||||
add_thread_event (diagnostic_thread_id_t thread_id,
|
||||
event_id_t
|
||||
add_thread_event (thread_id_t thread_id,
|
||||
location_t loc, const char *funcname, int depth,
|
||||
const char *fmt, ...)
|
||||
ATTRIBUTE_GCC_DIAG(6,7);
|
||||
@@ -136,13 +142,13 @@ class test_diagnostic_path : public diagnostic_path
|
||||
void connect_to_next_event ();
|
||||
|
||||
void add_entry (const char *callee_name, int stack_depth,
|
||||
diagnostic_thread_id_t thread_id = 0);
|
||||
thread_id_t thread_id = 0);
|
||||
void add_return (const char *caller_name, int stack_depth,
|
||||
diagnostic_thread_id_t thread_id = 0);
|
||||
thread_id_t thread_id = 0);
|
||||
void add_call (const char *caller_name,
|
||||
int caller_stack_depth,
|
||||
const char *callee_name,
|
||||
diagnostic_thread_id_t thread_id = 0);
|
||||
thread_id_t thread_id = 0);
|
||||
|
||||
private:
|
||||
diagnostics::logical_locations::key
|
||||
@@ -160,4 +166,4 @@ class test_diagnostic_path : public diagnostic_path
|
||||
|
||||
#endif /* #if CHECKING_P */
|
||||
|
||||
#endif /* ! GCC_SELFTEST_DIAGNOSTIC_PATH_H */
|
||||
#endif /* ! GCC_DIAGNOSTICS_SELFTEST_PATHS_H */
|
||||
@@ -432,7 +432,7 @@ binop_svalue (mult_expr, initial_svalue(‘size_t’, decl_region(frame_region(
|
||||
@subsection Analyzer Paths
|
||||
|
||||
We need to explain to the user what the problem is, and to persuade them
|
||||
that there really is a problem. Hence having a @code{diagnostic_path}
|
||||
that there really is a problem. Hence having a @code{diagnostics::paths::path}
|
||||
isn't just an incidental detail of the analyzer; it's required.
|
||||
|
||||
Paths ought to be:
|
||||
@@ -491,7 +491,7 @@ and notes if it is infeasible.
|
||||
|
||||
The above gives us a shortest feasible @code{exploded_path} through the
|
||||
@code{exploded_graph} (a list of @code{exploded_edge *}). We use this
|
||||
@code{exploded_path} to build a @code{diagnostic_path} (a list of
|
||||
@code{exploded_path} to build a @code{diagnostics::paths::path} (a list of
|
||||
@strong{events} for the diagnostic subsystem) - specifically a
|
||||
@code{checker_path}.
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "diagnostic-color.h"
|
||||
#include "diagnostic-url.h"
|
||||
#include "diagnostics/metadata.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "diagnostics/client-data-hooks.h"
|
||||
#include "diagnostic-format-sarif.h"
|
||||
#include "diagnostic-format-text.h"
|
||||
@@ -210,7 +210,7 @@ struct diagnostic_logical_location
|
||||
};
|
||||
|
||||
static diagnostic_event_id
|
||||
as_diagnostic_event_id (diagnostic_event_id_t id)
|
||||
as_diagnostic_event_id (diagnostics::paths::event_id_t id)
|
||||
{
|
||||
return id.zero_based ();
|
||||
}
|
||||
@@ -993,7 +993,7 @@ struct diagnostic_edge : public diagnostics::digraphs::edge
|
||||
}
|
||||
};
|
||||
|
||||
class libgdiagnostics_path_event : public diagnostic_event
|
||||
class libgdiagnostics_path_event : public diagnostics::paths::event
|
||||
{
|
||||
public:
|
||||
libgdiagnostics_path_event (const diagnostic_physical_location *physical_loc,
|
||||
@@ -1010,7 +1010,7 @@ public:
|
||||
gcc_assert (m_msg_buf);
|
||||
}
|
||||
|
||||
/* diagnostic_event vfunc implementations. */
|
||||
/* diagnostics::paths::event vfunc implementations. */
|
||||
|
||||
location_t get_location () const final override
|
||||
{
|
||||
@@ -1047,7 +1047,7 @@ public:
|
||||
return false; // TODO
|
||||
}
|
||||
|
||||
diagnostic_thread_id_t get_thread_id () const final override
|
||||
diagnostics::paths::thread_id_t get_thread_id () const final override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ private:
|
||||
std::unique_ptr<diagnostic_message_buffer> m_msg_buf;
|
||||
};
|
||||
|
||||
class libgdiagnostics_path_thread : public diagnostic_thread
|
||||
class libgdiagnostics_path_thread : public diagnostics::paths::thread
|
||||
{
|
||||
public:
|
||||
libgdiagnostics_path_thread (const char *name) : m_name (name) {}
|
||||
@@ -1105,15 +1105,15 @@ private:
|
||||
|
||||
/* This has to be a "struct" as it is exposed in the C API. */
|
||||
|
||||
struct diagnostic_execution_path : public diagnostic_path
|
||||
struct diagnostic_execution_path : public diagnostics::paths::path
|
||||
{
|
||||
diagnostic_execution_path (const logical_location_manager &logical_loc_mgr)
|
||||
: diagnostic_path (logical_loc_mgr),
|
||||
diagnostic_execution_path (const diagnostics::logical_locations::manager &logical_loc_mgr)
|
||||
: diagnostics::paths::path (logical_loc_mgr),
|
||||
m_thread ("")
|
||||
{
|
||||
}
|
||||
|
||||
diagnostic_event_id_t
|
||||
diagnostics::paths::event_id_t
|
||||
add_event_va (const diagnostic_physical_location *physical_loc,
|
||||
const diagnostic_logical_location *logical_loc,
|
||||
unsigned stack_depth,
|
||||
@@ -1148,19 +1148,19 @@ struct diagnostic_execution_path : public diagnostic_path
|
||||
return m_events.size () - 1;
|
||||
}
|
||||
|
||||
/* diagnostic_path vfunc implementations. */
|
||||
/* diagnostics::paths::path vfunc implementations. */
|
||||
|
||||
unsigned num_events () const final override
|
||||
{
|
||||
return m_events.size ();
|
||||
}
|
||||
const diagnostic_event & get_event (int idx) const final override
|
||||
const diagnostics::paths::event & get_event (int idx) const final override
|
||||
{
|
||||
return *m_events[idx];
|
||||
}
|
||||
unsigned num_threads () const final override { return 1; }
|
||||
const diagnostic_thread &
|
||||
get_thread (diagnostic_thread_id_t) const final override
|
||||
const diagnostics::paths::thread &
|
||||
get_thread (diagnostics::paths::thread_id_t) const final override
|
||||
{
|
||||
return m_thread;
|
||||
}
|
||||
@@ -2303,7 +2303,8 @@ diagnostic_execution_path_add_event (diagnostic_execution_path *path,
|
||||
|
||||
va_list args;
|
||||
va_start (args, gmsgid);
|
||||
diagnostic_event_id_t result = path->add_event_va (physical_loc,
|
||||
diagnostics::paths::event_id_t result
|
||||
= path->add_event_va (physical_loc,
|
||||
logical_loc,
|
||||
stack_depth,
|
||||
nullptr,
|
||||
@@ -2326,7 +2327,8 @@ diagnostic_execution_path_add_event_va (diagnostic_execution_path *path,
|
||||
FAIL_IF_NULL (path);
|
||||
FAIL_IF_NULL (gmsgid);
|
||||
|
||||
diagnostic_event_id_t result = path->add_event_va (physical_loc,
|
||||
diagnostics::paths::event_id_t result
|
||||
= path->add_event_va (physical_loc,
|
||||
logical_loc,
|
||||
stack_depth,
|
||||
nullptr,
|
||||
|
||||
@@ -1865,7 +1865,7 @@ handle_thread_flow_location_object (const json::object &tflow_loc_obj,
|
||||
libgdiagnostics::graph state_graph;
|
||||
if (auto sarif_state_graph
|
||||
= maybe_get_property_bag_value<json::object> (tflow_loc_obj,
|
||||
"gcc/diagnostic_event/state_graph"))
|
||||
"gcc/diagnostics/paths/event/state_graph"))
|
||||
{
|
||||
enum status s
|
||||
= handle_graph_object (*sarif_state_graph, run_obj, state_graph);
|
||||
|
||||
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#define GCC_PRETTY_PRINT_FORMAT_IMPL_H
|
||||
|
||||
#include "pretty-print.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
|
||||
/* A struct representing a pending item to be printed within
|
||||
pp_format.
|
||||
@@ -224,14 +224,14 @@ struct pp_token_end_url : public pp_token
|
||||
|
||||
struct pp_token_event_id : public pp_token
|
||||
{
|
||||
pp_token_event_id (diagnostic_event_id_t event_id)
|
||||
pp_token_event_id (diagnostics::paths::event_id_t event_id)
|
||||
: pp_token (kind::event_id),
|
||||
m_event_id (event_id)
|
||||
{
|
||||
gcc_assert (event_id.known_p ());
|
||||
}
|
||||
|
||||
diagnostic_event_id_t m_event_id;
|
||||
diagnostics::paths::event_id_t m_event_id;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
||||
@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "pretty-print-markup.h"
|
||||
#include "pretty-print-urlifier.h"
|
||||
#include "diagnostic-color.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "diagnostic-highlight-colors.h"
|
||||
#include "auto-obstack.h"
|
||||
#include "selftest.h"
|
||||
@@ -3413,8 +3413,8 @@ test_pp_format ()
|
||||
"foo", 0x12345678);
|
||||
/* Verify "%@". */
|
||||
{
|
||||
diagnostic_event_id_t first (2);
|
||||
diagnostic_event_id_t second (7);
|
||||
diagnostics::paths::event_id_t first (2);
|
||||
diagnostics::paths::event_id_t second (7);
|
||||
|
||||
ASSERT_PP_FORMAT_2 ("first `free' at (3); second `free' at (8)",
|
||||
"first %<free%> at %@; second %<free%> at %@",
|
||||
|
||||
@@ -105,14 +105,14 @@ selftest::run_tests ()
|
||||
diagnostics_digraphs_cc_tests ();
|
||||
diagnostics_output_spec_cc_tests ();
|
||||
diagnostics_state_graphs_cc_tests ();
|
||||
diagnostics_lazy_paths_cc_tests ();
|
||||
diagnostics_paths_output_cc_tests ();
|
||||
edit_context_cc_tests ();
|
||||
fold_const_cc_tests ();
|
||||
spellcheck_cc_tests ();
|
||||
spellcheck_tree_cc_tests ();
|
||||
tree_cfg_cc_tests ();
|
||||
diagnostic_path_output_cc_tests ();
|
||||
simple_diagnostic_path_cc_tests ();
|
||||
lazy_diagnostic_path_cc_tests ();
|
||||
attribs_cc_tests ();
|
||||
path_coverage_cc_tests ();
|
||||
|
||||
|
||||
@@ -224,10 +224,11 @@ extern void dbgcnt_cc_tests ();
|
||||
extern void diagnostic_color_cc_tests ();
|
||||
extern void diagnostic_format_html_cc_tests ();
|
||||
extern void diagnostic_format_sarif_cc_tests ();
|
||||
extern void diagnostic_path_output_cc_tests ();
|
||||
extern void diagnostic_show_locus_cc_tests ();
|
||||
extern void diagnostics_digraphs_cc_tests ();
|
||||
extern void diagnostics_lazy_paths_cc_tests ();
|
||||
extern void diagnostics_output_spec_cc_tests ();
|
||||
extern void diagnostics_paths_output_cc_tests ();
|
||||
extern void diagnostics_selftest_logical_locations_cc_tests ();
|
||||
extern void diagnostics_state_graphs_cc_tests ();
|
||||
extern void digraph_cc_tests ();
|
||||
@@ -249,7 +250,6 @@ extern void input_cc_tests ();
|
||||
extern void ipa_modref_tree_cc_tests ();
|
||||
extern void json_cc_tests ();
|
||||
extern void json_parser_cc_tests ();
|
||||
extern void lazy_diagnostic_path_cc_tests ();
|
||||
extern void opt_suggestions_cc_tests ();
|
||||
extern void optinfo_emit_json_cc_tests ();
|
||||
extern void opts_cc_tests ();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Concrete classes for implementing diagnostic paths.
|
||||
/* Concrete classes for implementing diagnostic paths, using tree.
|
||||
Copyright (C) 2019-2025 Free Software Foundation, Inc.
|
||||
Contributed by David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
@@ -32,29 +32,31 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "simple-diagnostic-path.h"
|
||||
#include "selftest.h"
|
||||
|
||||
/* class simple_diagnostic_path : public diagnostic_path. */
|
||||
using namespace diagnostics::paths;
|
||||
|
||||
/* class simple_diagnostic_path : public diagnostics::paths::path. */
|
||||
|
||||
simple_diagnostic_path::
|
||||
simple_diagnostic_path (const tree_logical_location_manager &logical_loc_mgr,
|
||||
pretty_printer *event_pp)
|
||||
: diagnostic_path (logical_loc_mgr),
|
||||
: path (logical_loc_mgr),
|
||||
m_event_pp (event_pp),
|
||||
m_localize_events (true)
|
||||
{
|
||||
add_thread ("main");
|
||||
}
|
||||
|
||||
/* Implementation of diagnostic_path::get_event vfunc for
|
||||
/* Implementation of path::get_event vfunc for
|
||||
simple_diagnostic_path: simply return the event in the vec. */
|
||||
|
||||
const diagnostic_event &
|
||||
const event &
|
||||
simple_diagnostic_path::get_event (int idx) const
|
||||
{
|
||||
return *m_events[idx];
|
||||
}
|
||||
|
||||
const diagnostic_thread &
|
||||
simple_diagnostic_path::get_thread (diagnostic_thread_id_t idx) const
|
||||
const thread &
|
||||
simple_diagnostic_path::get_thread (thread_id_t idx) const
|
||||
{
|
||||
return *m_threads[idx];
|
||||
}
|
||||
@@ -67,7 +69,7 @@ simple_diagnostic_path::same_function_p (int event_idx_a,
|
||||
== m_events[event_idx_b]->get_fndecl ());
|
||||
}
|
||||
|
||||
diagnostic_thread_id_t
|
||||
thread_id_t
|
||||
simple_diagnostic_path::add_thread (const char *name)
|
||||
{
|
||||
m_threads.safe_push (new simple_diagnostic_thread (name));
|
||||
@@ -82,7 +84,7 @@ simple_diagnostic_path::add_thread (const char *name)
|
||||
|
||||
Return the id of the new event. */
|
||||
|
||||
diagnostic_event_id_t
|
||||
event_id_t
|
||||
simple_diagnostic_path::add_event (location_t loc, tree fndecl, int depth,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
@@ -108,11 +110,11 @@ simple_diagnostic_path::add_event (location_t loc, tree fndecl, int depth,
|
||||
|
||||
pp_clear_output_area (pp);
|
||||
|
||||
return diagnostic_event_id_t (m_events.length () - 1);
|
||||
return event_id_t (m_events.length () - 1);
|
||||
}
|
||||
|
||||
diagnostic_event_id_t
|
||||
simple_diagnostic_path::add_thread_event (diagnostic_thread_id_t thread_id,
|
||||
event_id_t
|
||||
simple_diagnostic_path::add_thread_event (thread_id_t thread_id,
|
||||
location_t loc,
|
||||
tree fndecl,
|
||||
int depth,
|
||||
@@ -141,7 +143,7 @@ simple_diagnostic_path::add_thread_event (diagnostic_thread_id_t thread_id,
|
||||
|
||||
pp_clear_output_area (pp);
|
||||
|
||||
return diagnostic_event_id_t (m_events.length () - 1);
|
||||
return event_id_t (m_events.length () - 1);
|
||||
}
|
||||
|
||||
/* Mark the most recent event on this path (which must exist) as being
|
||||
@@ -163,7 +165,7 @@ simple_diagnostic_event (location_t loc,
|
||||
tree fndecl,
|
||||
int depth,
|
||||
const char *desc,
|
||||
diagnostic_thread_id_t thread_id)
|
||||
thread_id_t thread_id)
|
||||
: m_loc (loc), m_fndecl (fndecl),
|
||||
m_logical_loc (tree_logical_location_manager::key_from_tree (fndecl)),
|
||||
m_depth (depth), m_desc (xstrdup (desc)),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Concrete classes for implementing diagnostic paths.
|
||||
/* Concrete classes for implementing diagnostic paths, using tree.
|
||||
Copyright (C) 2019-2025 Free Software Foundation, Inc.
|
||||
Contributed by David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
@@ -21,20 +21,23 @@ along with GCC; see the file COPYING3. If not see
|
||||
#ifndef GCC_SIMPLE_DIAGNOSTIC_PATH_H
|
||||
#define GCC_SIMPLE_DIAGNOSTIC_PATH_H
|
||||
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/paths.h"
|
||||
#include "tree-logical-location.h"
|
||||
|
||||
/* Concrete subclasses of the abstract base classes
|
||||
declared in diagnostic-path.h. */
|
||||
|
||||
/* A simple implementation of diagnostic_event. */
|
||||
/* A simple implementation of diagnostic event.
|
||||
This uses "tree" and so is not in "namespace diagnostics". */
|
||||
|
||||
class simple_diagnostic_event : public diagnostic_event
|
||||
class simple_diagnostic_event : public diagnostics::paths::event
|
||||
{
|
||||
public:
|
||||
using thread_id_t = diagnostics::paths::thread_id_t;
|
||||
|
||||
simple_diagnostic_event (location_t loc, tree fndecl, int depth,
|
||||
const char *desc,
|
||||
diagnostic_thread_id_t thread_id = 0);
|
||||
thread_id_t thread_id = 0);
|
||||
~simple_diagnostic_event ();
|
||||
|
||||
location_t get_location () const final override { return m_loc; }
|
||||
@@ -53,7 +56,7 @@ class simple_diagnostic_event : public diagnostic_event
|
||||
{
|
||||
return m_connected_to_next_event;
|
||||
}
|
||||
diagnostic_thread_id_t get_thread_id () const final override
|
||||
thread_id_t get_thread_id () const final override
|
||||
{
|
||||
return m_thread_id;
|
||||
}
|
||||
@@ -72,12 +75,12 @@ class simple_diagnostic_event : public diagnostic_event
|
||||
int m_depth;
|
||||
char *m_desc; // has been i18n-ed and formatted
|
||||
bool m_connected_to_next_event;
|
||||
diagnostic_thread_id_t m_thread_id;
|
||||
thread_id_t m_thread_id;
|
||||
};
|
||||
|
||||
/* A simple implementation of diagnostic_thread. */
|
||||
/* A simple implementation of diagnostics::paths::thread. */
|
||||
|
||||
class simple_diagnostic_thread : public diagnostic_thread
|
||||
class simple_diagnostic_thread : public diagnostics::paths::thread
|
||||
{
|
||||
public:
|
||||
simple_diagnostic_thread (const char *name) : m_name (name) {}
|
||||
@@ -93,28 +96,33 @@ private:
|
||||
/* A simple implementation of diagnostic_path, as a vector of
|
||||
simple_diagnostic_event instances. */
|
||||
|
||||
class simple_diagnostic_path : public diagnostic_path
|
||||
class simple_diagnostic_path : public diagnostics::paths::path
|
||||
{
|
||||
public:
|
||||
using thread = diagnostics::paths::thread;
|
||||
using thread_id_t = diagnostics::paths::thread_id_t;
|
||||
using event = diagnostics::paths::event;
|
||||
using event_id_t = diagnostics::paths::event_id_t;
|
||||
|
||||
simple_diagnostic_path (const tree_logical_location_manager &logical_loc_mgr,
|
||||
pretty_printer *event_pp);
|
||||
|
||||
unsigned num_events () const final override { return m_events.length (); }
|
||||
const diagnostic_event & get_event (int idx) const final override;
|
||||
const event & get_event (int idx) const final override;
|
||||
unsigned num_threads () const final override { return m_threads.length (); }
|
||||
const diagnostic_thread &
|
||||
get_thread (diagnostic_thread_id_t) const final override;
|
||||
const thread &
|
||||
get_thread (thread_id_t) const final override;
|
||||
bool
|
||||
same_function_p (int event_idx_a,
|
||||
int event_idx_b) const final override;
|
||||
|
||||
diagnostic_thread_id_t add_thread (const char *name);
|
||||
thread_id_t add_thread (const char *name);
|
||||
|
||||
diagnostic_event_id_t add_event (location_t loc, tree fndecl, int depth,
|
||||
event_id_t add_event (location_t loc, tree fndecl, int depth,
|
||||
const char *fmt, ...)
|
||||
ATTRIBUTE_GCC_DIAG(5,6);
|
||||
diagnostic_event_id_t
|
||||
add_thread_event (diagnostic_thread_id_t thread_id,
|
||||
event_id_t
|
||||
add_thread_event (thread_id_t thread_id,
|
||||
location_t loc, tree fndecl, int depth,
|
||||
const char *fmt, ...)
|
||||
ATTRIBUTE_GCC_DIAG(6,7);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "gimple.h"
|
||||
#include "gimple-iterator.h"
|
||||
#include "gimple-walk.h"
|
||||
#include "diagnostic-event-id.h"
|
||||
#include "diagnostics/event-id.h"
|
||||
#include "analyzer/common.h"
|
||||
#include "analyzer/analyzer-logging.h"
|
||||
#include "json.h"
|
||||
@@ -120,20 +120,22 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
diagnostic_event::meaning
|
||||
diagnostics::paths::event::meaning
|
||||
get_meaning_for_state_change (const evdesc::state_change &change)
|
||||
const final override
|
||||
{
|
||||
using event = diagnostics::paths::event;
|
||||
|
||||
if (change.is_global_p ())
|
||||
{
|
||||
if (change.m_new_state == m_sm.m_released_gil)
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::release,
|
||||
diagnostic_event::noun::lock);
|
||||
return event::meaning (event::verb::release,
|
||||
event::noun::lock);
|
||||
else if (change.m_new_state == m_sm.get_start_state ())
|
||||
return diagnostic_event::meaning (diagnostic_event::verb::acquire,
|
||||
diagnostic_event::noun::lock);
|
||||
return event::meaning (event::verb::acquire,
|
||||
event::noun::lock);
|
||||
}
|
||||
return diagnostic_event::meaning ();
|
||||
return event::meaning ();
|
||||
}
|
||||
protected:
|
||||
gil_diagnostic (const gil_state_machine &sm) : m_sm (sm)
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "intl.h"
|
||||
#include "plugin-version.h"
|
||||
#include "diagnostic.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "diagnostics/metadata.h"
|
||||
#include "context.h"
|
||||
#include "print-tree.h"
|
||||
@@ -223,7 +222,7 @@ class test_diagnostic_path : public simple_diagnostic_path
|
||||
diagnostic_event_id_t
|
||||
add_event_2 (event_location_t evloc, int stack_depth,
|
||||
const char *desc,
|
||||
diagnostic_thread_id_t thread_id = 0)
|
||||
diagnostics::paths::thread_id_t thread_id = 0)
|
||||
{
|
||||
gcc_assert (evloc.m_fun);
|
||||
return add_thread_event (thread_id, evloc.m_loc, evloc.m_fun->decl,
|
||||
@@ -232,7 +231,7 @@ class test_diagnostic_path : public simple_diagnostic_path
|
||||
diagnostic_event_id_t
|
||||
add_event_2_with_event_id (event_location_t evloc, int stack_depth,
|
||||
const char *fmt,
|
||||
diagnostic_thread_id_t thread_id,
|
||||
diagnostics::paths::thread_id_t thread_id,
|
||||
diagnostic_event_id_t event_id)
|
||||
{
|
||||
gcc_assert (evloc.m_fun);
|
||||
@@ -242,7 +241,7 @@ class test_diagnostic_path : public simple_diagnostic_path
|
||||
}
|
||||
void add_entry (event_location_t evloc, int stack_depth,
|
||||
const char *funcname,
|
||||
diagnostic_thread_id_t thread_id = 0)
|
||||
diagnostics::paths::thread_id_t thread_id = 0)
|
||||
{
|
||||
gcc_assert (evloc.m_fun);
|
||||
add_thread_event (thread_id, evloc.m_loc, evloc.m_fun->decl, stack_depth,
|
||||
@@ -502,8 +501,8 @@ example_4 ()
|
||||
|
||||
gcc_rich_location richloc (call_to_acquire_lock_a_in_bar.m_loc);
|
||||
test_diagnostic_path path (global_dc->get_reference_printer ());
|
||||
diagnostic_thread_id_t thread_1 = path.add_thread ("Thread 1");
|
||||
diagnostic_thread_id_t thread_2 = path.add_thread ("Thread 2");
|
||||
diagnostics::paths::thread_id_t thread_1 = path.add_thread ("Thread 1");
|
||||
diagnostics::paths::thread_id_t thread_2 = path.add_thread ("Thread 2");
|
||||
path.add_entry (entry_to_foo, 0, "foo", thread_1);
|
||||
diagnostic_event_id_t event_a_acquired
|
||||
= path.add_event_2 (call_to_acquire_lock_a_in_foo, 1,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Generate a warning with a diagnostic_path within a header. */
|
||||
/* Generate a warning with a diagnostic path within a header. */
|
||||
|
||||
void test (void *ptr)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ def get_result_by_index(sarif, idx):
|
||||
return results[idx]
|
||||
|
||||
def get_state_graph(events, event_idx):
|
||||
graph = events[event_idx]['properties']['gcc/diagnostic_event/state_graph']
|
||||
graph = events[event_idx]['properties']['gcc/diagnostics/paths/event/state_graph']
|
||||
if 0:
|
||||
print(graph)
|
||||
assert graph is not None
|
||||
|
||||
@@ -213,7 +213,7 @@ semi_embedded_vec<T, NUM_EMBEDDED>::truncate (int len)
|
||||
}
|
||||
|
||||
class fixit_hint;
|
||||
class diagnostic_path;
|
||||
namespace diagnostics { namespace paths { class path; }}
|
||||
|
||||
/* A "rich" source code location, for use when printing diagnostics.
|
||||
A rich_location has one or more carets&ranges, where the carets
|
||||
@@ -520,8 +520,8 @@ class rich_location
|
||||
}
|
||||
|
||||
/* An optional path through the code. */
|
||||
const diagnostic_path *get_path () const { return m_path; }
|
||||
void set_path (const diagnostic_path *path) { m_path = path; }
|
||||
const diagnostics::paths::path *get_path () const { return m_path; }
|
||||
void set_path (const diagnostics::paths::path *path) { m_path = path; }
|
||||
|
||||
/* A flag for hinting that the diagnostic involves character encoding
|
||||
issues, and thus that it will be helpful to the user if we show some
|
||||
@@ -567,7 +567,7 @@ protected:
|
||||
static const int MAX_STATIC_FIXIT_HINTS = 2;
|
||||
semi_embedded_vec <fixit_hint *, MAX_STATIC_FIXIT_HINTS> m_fixit_hints;
|
||||
|
||||
const diagnostic_path *m_path;
|
||||
const diagnostics::paths::path *m_path;
|
||||
};
|
||||
|
||||
/* Abstract base class for labelling a range within a rich_location
|
||||
|
||||
Reference in New Issue
Block a user