From: David Malcolm Date: Thu, 17 Sep 2020 13:41:29 +0000 (-0400) Subject: analyzer: fix warning_event::get_desc for global state changes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1df487a5204462f1ec0b1eab39b0a463a8d6b89f;p=gcc.git 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. --- diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc index 2503d024a83..c28131651c6 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"); }