From 1df487a5204462f1ec0b1eab39b0a463a8d6b89f Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 17 Sep 2020 09:41:29 -0400 Subject: analyzer: fix warning_event::get_desc for global state changes When experimenting the a new state_machine with global state I noticed that the fallback handling in warning_event::get_desc assumes we have per-value states, and ICEs on global states. Fixed thusly. gcc/analyzer/ChangeLog: * checker-path.cc (warning_event::get_desc): Handle global state changes. --- gcc/analyzer/checker-path.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'gcc') diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc index 2503d02..c281316 100644 --- a/gcc/analyzer/checker-path.cc +++ b/gcc/analyzer/checker-path.cc @@ -872,11 +872,17 @@ warning_event::get_desc (bool can_colorize) const { if (m_sm && flag_analyzer_verbose_state_changes) { - label_text result - = make_label_text (can_colorize, - "%s (%qE is in state %qs)", - ev_desc.m_buffer, - m_var, m_state->get_name ()); + label_text result; + if (m_var) + result = make_label_text (can_colorize, + "%s (%qE is in state %qs)", + ev_desc.m_buffer, + m_var, m_state->get_name ()); + else + result = make_label_text (can_colorize, + "%s (in global state %qs)", + ev_desc.m_buffer, + m_state->get_name ()); ev_desc.maybe_free (); return result; } @@ -886,9 +892,16 @@ warning_event::get_desc (bool can_colorize) const } if (m_sm) - return make_label_text (can_colorize, - "here (%qE is in state %qs)", - m_var, m_state->get_name ()); + { + if (m_var) + return make_label_text (can_colorize, + "here (%qE is in state %qs)", + m_var, m_state->get_name ()); + else + return make_label_text (can_colorize, + "here (in global state %qs)", + m_state->get_name ()); + } else return label_text::borrow ("here"); } -- cgit v1.1