* [committed] analyzer: refactor custom_event, introducing precanned_custom_event class
@ 2021-06-18 15:22 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2021-06-18 15:22 UTC (permalink / raw)
To: gcc-patches
I have followup work where a custom event's description would be better
handled via a vfunc rather that a precanned string, hence this
refactoring to make it easy to add custom_event subclasses.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as 86606d2ab731a4b8dbbe1e5318a1920210abd65d.
gcc/analyzer/ChangeLog:
* checker-path.cc (class custom_event): Make abstract to allow for
custom vfuncs, splitting existing implementation into...
(class precanned_custom_event): New subclass.
(custom_event::get_desc): Move to...
(precanned_custom_event::get_desc): ...subclass.
* checker-path.h (class custom_event): Make abstract to allow for
custom vfuncs, splitting existing implementation into...
(class precanned_custom_event): New subclass.
* diagnostic-manager.cc (diagnostic_manager::add_events_for_eedge):
Use precanned_custom_event.
* engine.cc
(stale_jmp_buf::maybe_add_custom_events_for_superedge): Likewise.
* sm-signal.cc (signal_delivery_edge_info_t::add_events_to_path):
Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
gcc/analyzer/checker-path.cc | 6 +++---
gcc/analyzer/checker-path.h | 22 +++++++++++++++++-----
gcc/analyzer/diagnostic-manager.cc | 2 +-
gcc/analyzer/engine.cc | 2 +-
gcc/analyzer/sm-signal.cc | 7 ++++---
5 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc
index e6f838b7d52..e10c8e2bb7c 100644
--- a/gcc/analyzer/checker-path.cc
+++ b/gcc/analyzer/checker-path.cc
@@ -162,14 +162,14 @@ debug_event::get_desc (bool) const
return label_text::borrow (m_desc);
}
-/* class custom_event : public checker_event. */
+/* class precanned_custom_event : public custom_event. */
/* Implementation of diagnostic_event::get_desc vfunc for
- custom_event.
+ precanned_custom_event.
Use the saved string as the event's description. */
label_text
-custom_event::get_desc (bool) const
+precanned_custom_event::get_desc (bool) const
{
return label_text::borrow (m_desc);
}
diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h
index f76bb94e7cc..1843c4bc7b4 100644
--- a/gcc/analyzer/checker-path.h
+++ b/gcc/analyzer/checker-path.h
@@ -56,6 +56,7 @@ extern const char *event_kind_to_string (enum event_kind ek);
checker_event
debug_event (EK_DEBUG)
custom_event (EK_CUSTOM)
+ precanned_custom_event
statement_event (EK_STMT)
function_entry_event (EK_FUNCTION_ENTRY)
state_change_event (EK_STATE_CHANGE)
@@ -144,19 +145,30 @@ private:
char *m_desc;
};
-/* A concrete event subclass for custom events. These are not filtered,
+/* An abstract event subclass for custom events. These are not filtered,
as they are likely to be pertinent to the diagnostic. */
class custom_event : public checker_event
{
+protected:
+ custom_event (location_t loc, tree fndecl, int depth)
+ : checker_event (EK_CUSTOM, loc, fndecl, depth)
+ {
+ }
+};
+
+/* A concrete custom_event subclass with a precanned message. */
+
+class precanned_custom_event : public custom_event
+{
public:
- custom_event (location_t loc, tree fndecl, int depth,
- const char *desc)
- : checker_event (EK_CUSTOM, loc, fndecl, depth),
+ precanned_custom_event (location_t loc, tree fndecl, int depth,
+ const char *desc)
+ : custom_event (loc, fndecl, depth),
m_desc (xstrdup (desc))
{
}
- ~custom_event ()
+ ~precanned_custom_event ()
{
free (m_desc);
}
diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc
index 443ff058f65..7eb4ed8a4f2 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -1587,7 +1587,7 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
"this path would have been rejected as infeasible"
" at this edge: ");
pb.get_feasibility_problem ()->dump_to_pp (&pp);
- emission_path->add_event (new custom_event
+ emission_path->add_event (new precanned_custom_event
(dst_point.get_location (),
dst_point.get_fndecl (),
dst_stack_depth,
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 529965af187..f322fdb6497 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -1395,7 +1395,7 @@ public:
{
/* Compare with diagnostic_manager::add_events_for_superedge. */
const int src_stack_depth = src_point.get_stack_depth ();
- m_stack_pop_event = new custom_event
+ m_stack_pop_event = new precanned_custom_event
(src_point.get_location (),
src_point.get_fndecl (),
src_stack_depth,
diff --git a/gcc/analyzer/sm-signal.cc b/gcc/analyzer/sm-signal.cc
index d7e7e7cab04..42be8094997 100644
--- a/gcc/analyzer/sm-signal.cc
+++ b/gcc/analyzer/sm-signal.cc
@@ -238,9 +238,10 @@ public:
FINAL OVERRIDE
{
emission_path->add_event
- (new custom_event (UNKNOWN_LOCATION, NULL_TREE, 0,
- "later on,"
- " when the signal is delivered to the process"));
+ (new precanned_custom_event
+ (UNKNOWN_LOCATION, NULL_TREE, 0,
+ "later on,"
+ " when the signal is delivered to the process"));
}
};
--
2.26.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-18 15:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 15:22 [committed] analyzer: refactor custom_event, introducing precanned_custom_event class David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).