diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-01-03 09:26:16 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-01-14 20:53:05 -0500 |
commit | e2a538b1c31a13fc3d2f6d8ac3f341437775e984 (patch) | |
tree | 42d3259504b5264ee52cb8d51f8936a1cba91c86 | |
parent | 94946989e82cfa996873bcf6273242f5606cd7f5 (diff) | |
download | gcc-e2a538b1c31a13fc3d2f6d8ac3f341437775e984.zip gcc-e2a538b1c31a13fc3d2f6d8ac3f341437775e984.tar.gz gcc-e2a538b1c31a13fc3d2f6d8ac3f341437775e984.tar.bz2 |
analyzer: cleanups to checker_path
This patch adds DISABLE_COPY_AND_ASSIGN to checker_path, and makes its
fields private.
gcc/analyzer/ChangeLog:
* checker-path.h (checker_path::get_checker_event): New function.
(checker_path): Add DISABLE_COPY_AND_ASSIGN; make fields private.
* diagnostic-manager.cc
(diagnostic_manager::prune_for_sm_diagnostic): Replace direct
access to checker_path::m_events with accessor functions. Fix
overlong line.
(diagnostic_manager::prune_interproc_events): Replace direct
access to checker_path::m_events with accessor functions.
(diagnostic_manager::finish_pruning): Likewise.
-rw-r--r-- | gcc/analyzer/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/analyzer/checker-path.h | 8 | ||||
-rw-r--r-- | gcc/analyzer/diagnostic-manager.cc | 37 |
3 files changed, 40 insertions, 17 deletions
diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index 863bf3f..d5dd0ca 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,5 +1,17 @@ 2020-01-14 David Malcolm <dmalcolm@redhat.com> + * checker-path.h (checker_path::get_checker_event): New function. + (checker_path): Add DISABLE_COPY_AND_ASSIGN; make fields private. + * diagnostic-manager.cc + (diagnostic_manager::prune_for_sm_diagnostic): Replace direct + access to checker_path::m_events with accessor functions. Fix + overlong line. + (diagnostic_manager::prune_interproc_events): Replace direct + access to checker_path::m_events with accessor functions. + (diagnostic_manager::finish_pruning): Likewise. + +2020-01-14 David Malcolm <dmalcolm@redhat.com> + * checker-path.h (checker_event::clone): Delete vfunc decl. (debug_event::clone): Delete vfunc impl. (custom_event::clone): Delete vfunc impl. diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h index 31d4004..20bab77 100644 --- a/gcc/analyzer/checker-path.h +++ b/gcc/analyzer/checker-path.h @@ -452,6 +452,11 @@ public: return *m_events[idx]; } + checker_event *get_checker_event (int idx) + { + return m_events[idx]; + } + void dump (pretty_printer *pp) const; void debug () const; @@ -502,6 +507,9 @@ public: return false; } +private: + DISABLE_COPY_AND_ASSIGN(checker_path); + /* The events that have occurred along this path. */ auto_delete_vec<checker_event> m_events; diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc index ea2ff30..a00d9f7 100644 --- a/gcc/analyzer/diagnostic-manager.cc +++ b/gcc/analyzer/diagnostic-manager.cc @@ -961,10 +961,10 @@ diagnostic_manager::prune_for_sm_diagnostic (checker_path *path, tree var, state_machine::state_t state) const { - int idx = path->m_events.length () - 1; - while (idx >= 0 && idx < (signed)path->m_events.length ()) + int idx = path->num_events () - 1; + while (idx >= 0 && idx < (signed)path->num_events ()) { - checker_event *base_event = path->m_events[idx]; + checker_event *base_event = path->get_checker_event (idx); if (get_logger ()) { if (sm) @@ -1096,7 +1096,8 @@ diagnostic_manager::prune_for_sm_diagnostic (checker_path *path, log ("filtering event %i: CFG edge", idx); path->delete_event (idx); /* Also delete the corresponding EK_END_CFG_EDGE. */ - gcc_assert (path->m_events[idx]->m_kind == EK_END_CFG_EDGE); + gcc_assert (path->get_checker_event (idx)->m_kind + == EK_END_CFG_EDGE); path->delete_event (idx); } } @@ -1193,18 +1194,19 @@ diagnostic_manager::prune_interproc_events (checker_path *path) const do { changed = false; - int idx = path->m_events.length () - 1; + int idx = path->num_events () - 1; while (idx >= 0) { /* Prune [..., call, function-entry, return, ...] triples. */ - if (idx + 2 < (signed)path->m_events.length () - && path->m_events[idx]->is_call_p () - && path->m_events[idx + 1]->is_function_entry_p () - && path->m_events[idx + 2]->is_return_p ()) + if (idx + 2 < (signed)path->num_events () + && path->get_checker_event (idx)->is_call_p () + && path->get_checker_event (idx + 1)->is_function_entry_p () + && path->get_checker_event (idx + 2)->is_return_p ()) { if (get_logger ()) { - label_text desc (path->m_events[idx]->get_desc (false)); + label_text desc + (path->get_checker_event (idx)->get_desc (false)); log ("filtering events %i-%i:" " irrelevant call/entry/return: %s", idx, idx + 2, desc.m_buffer); @@ -1220,13 +1222,14 @@ diagnostic_manager::prune_interproc_events (checker_path *path) const /* Prune [..., call, return, ...] pairs (for -fanalyzer-verbosity=0). */ - if (idx + 1 < (signed)path->m_events.length () - && path->m_events[idx]->is_call_p () - && path->m_events[idx + 1]->is_return_p ()) + if (idx + 1 < (signed)path->num_events () + && path->get_checker_event (idx)->is_call_p () + && path->get_checker_event (idx + 1)->is_return_p ()) { if (get_logger ()) { - label_text desc (path->m_events[idx]->get_desc (false)); + label_text desc + (path->get_checker_event (idx)->get_desc (false)); log ("filtering events %i-%i:" " irrelevant call/return: %s", idx, idx + 1, desc.m_buffer); @@ -1256,10 +1259,10 @@ diagnostic_manager::finish_pruning (checker_path *path) const { if (!path->interprocedural_p ()) { - int idx = path->m_events.length () - 1; - while (idx >= 0 && idx < (signed)path->m_events.length ()) + int idx = path->num_events () - 1; + while (idx >= 0 && idx < (signed)path->num_events ()) { - checker_event *base_event = path->m_events[idx]; + checker_event *base_event = path->get_checker_event (idx); if (base_event->m_kind == EK_FUNCTION_ENTRY) { log ("filtering event %i:" |