'-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'],
df-problems.o \
df-scan.o \
dfp.o \
+ diagnostics/lazy-paths.o \
digraph.o \
dojump.o \
dominance.o \
jump.o \
langhooks.o \
late-combine.o \
- lazy-diagnostic-path.o \
lcm.o \
lists.o \
loop-doloop.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 \
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 \
# 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)
{
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),
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;
{
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)
}
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;
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)
{
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);
#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"
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 ())
{
}
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,
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
#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"
-/* 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>.
}
}
-/* class checker_event : public diagnostic_event. */
+/* class checker_event : public diagnostics::paths::event. */
/* checker_event's ctor. */
}
}
-/* 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
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;
/* 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. */
/* 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. */
{
}
-/* 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. */
{
}
-/* 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. */
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);
{
}
-/* 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.
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, ")");
}
}
-/* 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)
/* 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
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 ();
/* 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
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,
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);
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,
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);
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,
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);
/* 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
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);
/* 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
/* 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
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 (),
/* 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,
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);
-/* 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>.
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)
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; }
}
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;
}
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; }
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;
}
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;
};
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;
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. */
-/* 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>.
-/* 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>.
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];
}
{
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;
}
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;
/* 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;
};
#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"
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);
/* 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 (),
#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"
#define GCC_ANALYZER_PENDING_DIAGNOSTIC_H
#include "diagnostics/metadata.h"
-#include "diagnostic-path.h"
#include "analyzer/sm.h"
namespace ana {
};
/* 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. */
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),
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;
};
pending_diagnostic::emit vfunc.
The rich_location will have already been populated with a
- diagnostic_path. */
+ diagnostics::paths::path. */
class diagnostic_emission_context
{
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. */
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"
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
}
/* 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:
}
/* 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)"
#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"
#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"
#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"
#include "analyzer/common.h"
-#include "diagnostic-event-id.h"
+#include "diagnostics/event-id.h"
#include "stringpool.h"
#include "attribs.h"
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:
}
private:
- diagnostic_event_id_t m_open_event;
+ diagnostics::paths::event_id_t m_open_event;
std::unique_ptr<program_state> m_final_state;
};
}
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
}
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
}
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. */
#include "analyzer/common.h"
-#include "diagnostic-event-id.h"
+#include "diagnostics/event-id.h"
#include "selftest.h"
#include "analyzer/analyzer-logging.h"
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:
}
private:
- diagnostic_event_id_t m_first_fclose_event;
+ diagnostics::paths::event_id_t m_first_fclose_event;
};
class file_leak : public file_diagnostic
}
private:
- diagnostic_event_id_t m_fopen_event;
+ diagnostics::paths::event_id_t m_fopen_event;
std::unique_ptr<program_state> m_final_state;
};
#include "analyzer/common.h"
-#include "diagnostic-event-id.h"
+#include "diagnostics/event-id.h"
#include "stringpool.h"
#include "attribs.h"
#include "xml-printer.h"
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:
}
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;
};
}
private:
- diagnostic_event_id_t m_first_free_event;
+ diagnostics::paths::event_id_t m_first_free_event;
const char *m_funcname;
};
}
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
}
private:
- diagnostic_event_id_t m_free_event;
+ diagnostics::paths::event_id_t m_free_event;
const deallocator *m_deallocator;
};
}
private:
- diagnostic_event_id_t m_alloc_event;
+ diagnostics::paths::event_id_t m_alloc_event;
std::unique_ptr<program_state> m_final_state;
};
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;
#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"
#include "analyzer/common.h"
-#include "diagnostic-event-id.h"
+#include "diagnostics/event-id.h"
#include "analyzer/analyzer-logging.h"
#include "analyzer/sm.h"
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,
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. */
#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"
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)
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:
}
private:
- diagnostic_event_id_t m_va_end_event;
+ diagnostics::paths::event_id_t m_va_end_event;
const char *m_usage_fnname;
};
}
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;
};
#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"
}
std::unique_ptr<xml::node>
- maybe_make_state_diagram (const diagnostic_event &event);
+ maybe_make_state_diagram (const paths::event &event);
private:
void
}
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;
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),
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))
{
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 */
{
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,
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);
#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"
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
{
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; }
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,
}
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)
}
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
}
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 ());
/* 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)
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;
}
/* 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> ();
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 ());
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);
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),
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,
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);
{
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
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));
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;
}
#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"
# 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
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);
}
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; }
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;
#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"
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. */
/* 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. */
-/* 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>
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.
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
{
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 */
#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,
- int event_idx_b) const
+lazy_path::same_function_p (int event_idx_a,
+ int event_idx_b) const
{
lazily_generate_path ();
return m_inner_path->same_function_p (event_idx_a, event_idx_b);
}
void
-lazy_diagnostic_path::lazily_generate_path () const
+lazy_path::lazily_generate_path () const
{
if (!m_inner_path)
m_inner_path = make_inner_path ();
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);
/* 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. */
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
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;
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 */
#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"
namespace {
using namespace diagnostics;
+using namespace diagnostics::paths;
/* A bundle of state for printing a path. */
};
/* 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)
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. */
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 ())));
}
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;
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;
};
/* 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 ())
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),
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;
// 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;
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
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
{
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 ()),
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 ()
}
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)
{
(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
{
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);
{
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);
// 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). */
{
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);
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);
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 ());
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;
}
}
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_)
{
}
}
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 ())
{
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);
}
}
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);
}
}
-/* 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)
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);
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;
}
/* 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)
/* 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;
#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
#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, '{');
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)
{
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)
{
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)
{
(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;
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))
{
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 ();
/* 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");
}
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; }
class sarif_object;
namespace diagnostics {
-namespace digraphs {
- class digraph;
-} // namespace digraphs
+ namespace digraphs {
+ class digraph;
+ } // 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
/* 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.
enum property m_property;
};
- virtual ~diagnostic_event () {}
+ virtual ~event () {}
virtual location_t get_location () const = 0;
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;
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. */
/* 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. */
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)
{
}
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 */
#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
/* 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];
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];
}
== 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));
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,
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,
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
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);
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);
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,
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)),
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
/* 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; }
{
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;
}
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) {}
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,
- const char *fmt, ...)
+ 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);
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
#endif /* #if CHECKING_P */
-#endif /* ! GCC_SELFTEST_DIAGNOSTIC_PATH_H */
+#endif /* ! GCC_DIAGNOSTICS_SELFTEST_PATHS_H */
@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:
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}.
#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"
};
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 ();
}
}
};
-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,
gcc_assert (m_msg_buf);
}
- /* diagnostic_event vfunc implementations. */
+ /* diagnostics::paths::event vfunc implementations. */
location_t get_location () const final override
{
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;
}
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) {}
/* 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,
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;
}
va_list args;
va_start (args, gmsgid);
- diagnostic_event_id_t result = path->add_event_va (physical_loc,
- logical_loc,
- stack_depth,
- nullptr,
- gmsgid, &args);
+ diagnostics::paths::event_id_t result
+ = path->add_event_va (physical_loc,
+ logical_loc,
+ stack_depth,
+ nullptr,
+ gmsgid, &args);
va_end (args);
return as_diagnostic_event_id (result);
FAIL_IF_NULL (path);
FAIL_IF_NULL (gmsgid);
- diagnostic_event_id_t result = path->add_event_va (physical_loc,
- logical_loc,
- stack_depth,
- nullptr,
- gmsgid, args);
+ diagnostics::paths::event_id_t result
+ = path->add_event_va (physical_loc,
+ logical_loc,
+ stack_depth,
+ nullptr,
+ gmsgid, args);
return as_diagnostic_event_id (result);
}
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);
#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.
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 <>
#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"
"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 %@",
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 ();
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 ();
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 ();
-/* 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>
#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];
}
== 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));
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, ...)
{
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,
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
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)),
-/* 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>
#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; }
{
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;
}
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) {}
/* 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,
- const char *fmt, ...)
+ 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);
#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"
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)
#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"
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,
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);
}
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,
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,
-/* Generate a warning with a diagnostic_path within a header. */
+/* Generate a warning with a diagnostic path within a header. */
void test (void *ptr)
{
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
}
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
}
/* 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
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