From e8de5bad250909c9599da49d07f09fb9a8cabd0f Mon Sep 17 00:00:00 2001 From: Ankur Saini Date: Sun, 25 Jul 2021 14:47:53 +0530 Subject: analyzer: : Refactor callstring to work with pairs of supernodes. 2021-07-25 Ankur Saini gcc/analyzer/ChangeLog: * call-string.cc (call_string::element_t::operator==): New operator. (call_String::element_t::operator!=): New operator. (call_string::element_t::get_caller_function): New function. (call_string::element_t::get_callee_function): New function. (call_string::call_string): Refactor to Initialise m_elements. (call_string::operator=): Refactor to work with m_elements. (call_string::operator==): Likewise. (call_string::to_json): Likewise. (call_string::hash): Refactor to hash e.m_caller. (call_string::push_call): Refactor to work with m_elements. (call_string::push_call): New overload to push call via supernodes. (call_string::pop): Refactor to work with m_elements. (call_string::calc_recursion_depth): Likewise. (call_string::cmp): Likewise. (call_string::validate): Likewise. (call_string::operator[]): Likewise. * call-string.h (class supernode): New forward decl. (struct call_string::element_t): New struct. (call_string::call_string): Refactor to initialise m_elements. (call_string::bool empty_p): Refactor to work with m_elements. (call_string::get_callee_node): New decl. (call_string::get_caller_node): New decl. (m_elements): Replaces m_return_edges. * program-point.cc (program_point::get_function_at_depth): Refactor to work with new call-string format. (program_point::validate): Likewise. (program_point::on_edge): Likewise. --- gcc/analyzer/program-point.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'gcc/analyzer/program-point.cc') diff --git a/gcc/analyzer/program-point.cc b/gcc/analyzer/program-point.cc index d73b621..d9f50da 100644 --- a/gcc/analyzer/program-point.cc +++ b/gcc/analyzer/program-point.cc @@ -350,7 +350,7 @@ program_point::get_function_at_depth (unsigned depth) const if (depth == m_call_string.length ()) return m_function_point.get_function (); else - return m_call_string[depth]->get_caller_function (); + return m_call_string[depth].get_caller_function (); } /* Assert that this object is sane. */ @@ -367,7 +367,7 @@ program_point::validate () const /* The "callee" of the final entry in the callstring should be the function of the m_function_point. */ if (m_call_string.length () > 0) - gcc_assert (m_call_string[m_call_string.length () - 1]->get_callee_function () + gcc_assert (m_call_string[m_call_string.length () - 1].get_callee_function () == get_function ()); } @@ -438,8 +438,10 @@ program_point::on_edge (exploded_graph &eg, logger->log ("rejecting return edge: empty call string"); return false; } - const return_superedge *top_of_stack = m_call_string.pop (); - if (top_of_stack != succ) + const call_string::element_t top_of_stack = m_call_string.pop (); + call_string::element_t current_call_string_element (succ->m_dest, + succ->m_src); + if (top_of_stack != current_call_string_element) { if (logger) logger->log ("rejecting return edge: return to wrong callsite"); -- cgit v1.1