aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-07-07 15:50:26 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2022-07-07 15:56:08 -0400
commit52f538fa4a13d5d439f6db2c2657791fbddd934c (patch)
treec8eef19ac7074fd77bf703ea5b4d148acac27889
parenta8dce13c076019688f6d6aaaa338a2911022b336 (diff)
downloadgcc-52f538fa4a13d5d439f6db2c2657791fbddd934c.zip
gcc-52f538fa4a13d5d439f6db2c2657791fbddd934c.tar.gz
gcc-52f538fa4a13d5d439f6db2c2657791fbddd934c.tar.bz2
analyzer: use label_text for superedge::get_description
gcc/analyzer/ChangeLog: * checker-path.cc (start_cfg_edge_event::get_desc): Update for superedge::get_description returning a label_text. * engine.cc (feasibility_state::maybe_update_for_edge): Likewise. * supergraph.cc (superedge::dump): Likewise. (superedge::get_description): Convert return type from char * to label_text. * supergraph.h (superedge::get_description): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
-rw-r--r--gcc/analyzer/checker-path.cc3
-rw-r--r--gcc/analyzer/engine.cc5
-rw-r--r--gcc/analyzer/supergraph.cc13
-rw-r--r--gcc/analyzer/supergraph.h2
4 files changed, 9 insertions, 14 deletions
diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc
index 959ffdd..211cf3e 100644
--- a/gcc/analyzer/checker-path.cc
+++ b/gcc/analyzer/checker-path.cc
@@ -594,8 +594,7 @@ label_text
start_cfg_edge_event::get_desc (bool can_colorize) const
{
bool user_facing = !flag_analyzer_verbose_edges;
- label_text edge_desc
- = label_text::take (m_sedge->get_description (user_facing));
+ label_text edge_desc (m_sedge->get_description (user_facing));
if (user_facing)
{
if (edge_desc.m_buffer && strlen (edge_desc.m_buffer) > 0)
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 0674c8b..888123f 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -4586,12 +4586,11 @@ feasibility_state::maybe_update_for_edge (logger *logger,
{
if (logger)
{
- char *desc = sedge->get_description (false);
+ label_text desc (sedge->get_description (false));
logger->log (" sedge: SN:%i -> SN:%i %s",
sedge->m_src->m_index,
sedge->m_dest->m_index,
- desc);
- free (desc);
+ desc.m_buffer);
}
const gimple *last_stmt = src_point.get_supernode ()->get_last_stmt ();
diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc
index f023c53..52b48524 100644
--- a/gcc/analyzer/supergraph.cc
+++ b/gcc/analyzer/supergraph.cc
@@ -854,13 +854,12 @@ void
superedge::dump (pretty_printer *pp) const
{
pp_printf (pp, "edge: SN: %i -> SN: %i", m_src->m_index, m_dest->m_index);
- char *desc = get_description (false);
- if (strlen (desc) > 0)
+ label_text desc (get_description (false));
+ if (strlen (desc.m_buffer) > 0)
{
pp_space (pp);
- pp_string (pp, desc);
+ pp_string (pp, desc.m_buffer);
}
- free (desc);
}
/* Dump this superedge to stderr. */
@@ -998,17 +997,15 @@ superedge::get_any_callgraph_edge () const
/* Build a description of this superedge (e.g. "true" for the true
edge of a conditional, or "case 42:" for a switch case).
- The caller is responsible for freeing the result.
-
If USER_FACING is false, the result also contains any underlying
CFG edge flags. e.g. " (flags FALLTHRU | DFS_BACK)". */
-char *
+label_text
superedge::get_description (bool user_facing) const
{
pretty_printer pp;
dump_label_to_pp (&pp, user_facing);
- return xstrdup (pp_formatted_text (&pp));
+ return label_text::take (xstrdup (pp_formatted_text (&pp)));
}
/* Implementation of superedge::dump_label_to_pp for non-switch CFG
diff --git a/gcc/analyzer/supergraph.h b/gcc/analyzer/supergraph.h
index 42c6df5..e9a5be2 100644
--- a/gcc/analyzer/supergraph.h
+++ b/gcc/analyzer/supergraph.h
@@ -331,7 +331,7 @@ class superedge : public dedge<supergraph_traits>
::edge get_any_cfg_edge () const;
cgraph_edge *get_any_callgraph_edge () const;
- char *get_description (bool user_facing) const;
+ label_text get_description (bool user_facing) const;
protected:
superedge (supernode *src, supernode *dest, enum edge_kind kind)