aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/analyzer')
-rw-r--r--gcc/analyzer/ChangeLog26
-rw-r--r--gcc/analyzer/checker-event.cc25
-rw-r--r--gcc/analyzer/checker-event.h15
-rw-r--r--gcc/analyzer/checker-path.h5
-rw-r--r--gcc/analyzer/diagnostic-manager.cc12
-rw-r--r--gcc/analyzer/diagnostic-manager.h3
6 files changed, 64 insertions, 22 deletions
diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog
index 186f355..1fbba5d 100644
--- a/gcc/analyzer/ChangeLog
+++ b/gcc/analyzer/ChangeLog
@@ -1,3 +1,29 @@
+2025-05-06 David Malcolm <dmalcolm@redhat.com>
+
+ * checker-event.cc (checker_event::checker_event): Update
+ initialization of m_logical_loc.
+ (checker_event::maybe_add_sarif_properties): Add "builder" param.
+ Replace call to make_sarif_logical_location_object with call to
+ sarif_property_bag::set_logical_location.
+ (superedge_event::maybe_add_sarif_properties): Add "builder"
+ param.
+ * checker-event.h (checker_event::get_logical_location):
+ Reimplement.
+ (checker_event::maybe_add_sarif_properties): Add "builder" param.
+ (checker_event::maybe_add_sarif_properties): Add "builder" param.
+ (checker_event::m_logical_loc): Convert from tree_logical_location
+ to logical_location.
+ (superedge_event::maybe_add_sarif_properties): Add sarif_builder
+ param.
+ * checker-path.h (checker_path::checker_path): Add logical_loc_mgr
+ param.
+ * diagnostic-manager.cc
+ (diagnostic_manager::emit_saved_diagnostic): Pass logical location
+ manager to emission_path ctor.
+ (diagnostic_manager::get_logical_location_manager): New.
+ * diagnostic-manager.h
+ (diagnostic_manager::get_logical_location_manager): New decl.
+
2025-04-30 David Malcolm <dmalcolm@redhat.com>
* sm-malloc.cc (malloc_diagnostic::describe_state_change): Tweak
diff --git a/gcc/analyzer/checker-event.cc b/gcc/analyzer/checker-event.cc
index 958cdbf..e041778 100644
--- a/gcc/analyzer/checker-event.cc
+++ b/gcc/analyzer/checker-event.cc
@@ -112,7 +112,8 @@ checker_event::checker_event (enum event_kind kind,
m_original_depth (loc_info.m_depth),
m_effective_depth (loc_info.m_depth),
m_pending_diagnostic (NULL), m_emission_id (),
- m_logical_loc (loc_info.m_fndecl)
+ m_logical_loc
+ (tree_logical_location_manager::key_from_tree (loc_info.m_fndecl))
{
/* Update effective fndecl and depth if inlining has been recorded. */
if (flag_analyzer_undo_inlining)
@@ -122,7 +123,8 @@ checker_event::checker_event (enum event_kind kind,
{
m_effective_fndecl = info.get_inner_fndecl ();
m_effective_depth += info.get_extra_frames ();
- m_logical_loc = tree_logical_location (m_effective_fndecl);
+ m_logical_loc
+ = tree_logical_location_manager::key_from_tree (m_effective_fndecl);
}
}
}
@@ -141,7 +143,8 @@ checker_event::get_meaning () const
void
checker_event::
-maybe_add_sarif_properties (sarif_object &thread_flow_loc_obj) const
+maybe_add_sarif_properties (sarif_builder &builder,
+ sarif_object &thread_flow_loc_obj) const
{
sarif_property_bag &props = thread_flow_loc_obj.get_or_create_properties ();
#define PROPERTY_PREFIX "gcc/analyzer/checker_event/"
@@ -150,12 +153,11 @@ maybe_add_sarif_properties (sarif_object &thread_flow_loc_obj) const
props.set_string (PROPERTY_PREFIX "kind", event_kind_to_string (m_kind));
if (m_original_fndecl != m_effective_fndecl)
- {
- tree_logical_location logical_loc (m_original_fndecl);
- props.set<sarif_logical_location>
- (PROPERTY_PREFIX "original_fndecl",
- make_sarif_logical_location_object (logical_loc));
- }
+ props.set_logical_location
+ (PROPERTY_PREFIX "original_fndecl",
+ builder,
+ tree_logical_location_manager::key_from_tree (m_original_fndecl));
+
if (m_original_depth != m_effective_depth)
props.set_integer (PROPERTY_PREFIX "original_depth", m_original_depth);
#undef PROPERTY_PREFIX
@@ -502,10 +504,11 @@ state_change_event::get_meaning () const
for superedge_event. */
void
-superedge_event::maybe_add_sarif_properties (sarif_object &thread_flow_loc_obj)
+superedge_event::maybe_add_sarif_properties (sarif_builder &builder,
+ sarif_object &thread_flow_loc_obj)
const
{
- checker_event::maybe_add_sarif_properties (thread_flow_loc_obj);
+ checker_event::maybe_add_sarif_properties (builder, thread_flow_loc_obj);
sarif_property_bag &props = thread_flow_loc_obj.get_or_create_properties ();
#define PROPERTY_PREFIX "gcc/analyzer/superedge_event/"
if (m_sedge)
diff --git a/gcc/analyzer/checker-event.h b/gcc/analyzer/checker-event.h
index f3ab899..2f26b8d 100644
--- a/gcc/analyzer/checker-event.h
+++ b/gcc/analyzer/checker-event.h
@@ -100,12 +100,9 @@ public:
location_t get_location () const final override { return m_loc; }
int get_stack_depth () const final override { return m_effective_depth; }
- const logical_location *get_logical_location () const final override
+ logical_location get_logical_location () const final override
{
- if (m_effective_fndecl)
- return &m_logical_loc;
- else
- return NULL;
+ return m_logical_loc;
}
meaning get_meaning () const override;
bool connect_to_next_event_p () const override { return false; }
@@ -115,7 +112,8 @@ public:
}
void
- maybe_add_sarif_properties (sarif_object &thread_flow_loc_obj) const override;
+ maybe_add_sarif_properties (sarif_builder &,
+ sarif_object &thread_flow_loc_obj) const override;
/* Additional functionality. */
tree get_fndecl () const { return m_effective_fndecl; }
@@ -154,7 +152,7 @@ protected:
int m_effective_depth;
pending_diagnostic *m_pending_diagnostic;
diagnostic_event_id_t m_emission_id; // only set once all pruning has occurred
- tree_logical_location m_logical_loc;
+ logical_location m_logical_loc;
};
/* A concrete event subclass for a purely textual event, for use in
@@ -391,7 +389,8 @@ public:
class superedge_event : public checker_event
{
public:
- void maybe_add_sarif_properties (sarif_object &thread_flow_loc_obj)
+ void maybe_add_sarif_properties (sarif_builder &,
+ sarif_object &thread_flow_loc_obj)
const override;
/* Mark this edge event as being either an interprocedural call or
diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h
index dfc782d..80c975c 100644
--- a/gcc/analyzer/checker-path.h
+++ b/gcc/analyzer/checker-path.h
@@ -31,8 +31,9 @@ namespace ana {
class checker_path : public diagnostic_path
{
public:
- checker_path (logger *logger)
- : diagnostic_path (),
+ checker_path (const logical_location_manager &logical_loc_mgr,
+ logger *logger)
+ : diagnostic_path (logical_loc_mgr),
m_thread ("main"),
m_logger (logger)
{}
diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc
index 7575b16..e5d1a25 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -1580,7 +1580,8 @@ diagnostic_manager::emit_saved_diagnostic (const exploded_graph &eg,
/* This is the diagnostic_path subclass that will be built for
the diagnostic. */
- checker_path emission_path (get_logger ());
+ checker_path emission_path (get_logical_location_manager (),
+ get_logger ());
/* Populate emission_path with a full description of EPATH. */
build_emission_path (pb, *epath, &emission_path);
@@ -1656,6 +1657,15 @@ diagnostic_manager::emit_saved_diagnostic (const exploded_graph &eg,
}
}
+const logical_location_manager &
+diagnostic_manager::get_logical_location_manager () const
+{
+ gcc_assert (global_dc);
+ auto mgr = global_dc->get_logical_location_manager ();
+ gcc_assert (mgr);
+ return *mgr;
+}
+
/* Emit a "path" of events to EMISSION_PATH describing the exploded path
EPATH within EG. */
diff --git a/gcc/analyzer/diagnostic-manager.h b/gcc/analyzer/diagnostic-manager.h
index b62fc7a..aa0bd79 100644
--- a/gcc/analyzer/diagnostic-manager.h
+++ b/gcc/analyzer/diagnostic-manager.h
@@ -191,6 +191,9 @@ public:
}
private:
+ const logical_location_manager &
+ get_logical_location_manager () const;
+
void build_emission_path (const path_builder &pb,
const exploded_path &epath,
checker_path *emission_path) const;