[committed] analyzer: fix warning_event::get_desc for global state changes
David Malcolm
dmalcolm@redhat.com
Fri Sep 18 21:41:55 GMT 2020
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.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to master as 1df487a5204462f1ec0b1eab39b0a463a8d6b89f.
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(-)
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");
}
--
2.26.2
More information about the Gcc-patches
mailing list