https://gcc.gnu.org/g:9aac2e6ea201af2c4435793f3077bb879e1e42cf
commit r17-6444-g9aac2e6ea201af2c4435793f3077bb879e1e42cf Author: Oleg Tolmatcev <[email protected]> Date: Tue Nov 17 22:03:21 2026 +0100 analyzer: Avoid duplicate location prefixes and an unsigned comparison warning The pretty-printer's %wx directive includes the 0x prefix, so the literal 0x in analyzer logging and DOT output produces a duplicate prefix. Remove the literal prefix at those call sites. The call-string length is unsigned. Make the loop index unsigned to avoid a signed comparison warning. gcc/analyzer/ChangeLog: * engine.cc (leak_ploc_fixer_for_epath::fixup_for_epath): Remove the redundant 0x prefix before %wx. (exploded_graph_diagnostic_digraph::add_node_for_enode): Make the call-string loop index unsigned. * supergraph-fixup-locations.cc (location_fixer::consider_node): Remove the redundant 0x prefix before %wx. * supergraph.cc (supergraph::populate_for_basic_block): Likewise. (supernode::dump_dot): Likewise. (superedge::dump_label_to_pp): Likewise. Signed-off-by: Oleg Tolmatcev <[email protected]> Diff: --- gcc/analyzer/engine.cc | 6 +++--- gcc/analyzer/supergraph-fixup-locations.cc | 2 +- gcc/analyzer/supergraph.cc | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 790d940ba7de..459c006689f4 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -328,7 +328,7 @@ public: && SSA_NAME_VAR (lhs) == SSA_NAME_VAR (m_var)) { if (logger) - logger->log ("using location 0x%wx from gassign", + logger->log ("using location %wx from gassign", assign->location); ploc.m_event_loc_info.m_loc = assign->location; return; @@ -386,7 +386,7 @@ public: if (useful_location_p (stmt->location)) { if (logger) - logger->log ("using location 0x%wx from stmt", + logger->log ("using location %wx from stmt", stmt->location); ploc.m_event_loc_info.m_loc = stmt->location; return; @@ -2000,7 +2000,7 @@ private: auto &cs = point.get_call_string (); auto cs_arr = std::make_unique<json::array> (); - for (int i = 0; i < cs.length (); ++i) + for (unsigned int i = 0; i < cs.length (); ++i) { auto e = cs[i]; auto obj = std::make_unique<json::object> (); diff --git a/gcc/analyzer/supergraph-fixup-locations.cc b/gcc/analyzer/supergraph-fixup-locations.cc index d03714872f75..201da64c03ae 100644 --- a/gcc/analyzer/supergraph-fixup-locations.cc +++ b/gcc/analyzer/supergraph-fixup-locations.cc @@ -75,7 +75,7 @@ public: node->m_loc = in_edge->m_src->m_loc; m_stats.m_num_copies++; if (m_logger) - m_logger->log ("copying location 0x%wx from SN %i to SN %i", + m_logger->log ("copying location %wx from SN %i to SN %i", node->m_loc, in_edge->m_src->m_id, node->m_id); for (auto out_edge : node->m_succs) diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc index 254c9423393c..9506933aa667 100644 --- a/gcc/analyzer/supergraph.cc +++ b/gcc/analyzer/supergraph.cc @@ -251,7 +251,7 @@ supergraph::populate_for_basic_block (basic_block bb, /* We have an empty basic block with one out-edge, perhaps part of an empty infinite loop. */ if (logger) - logger->log ("using location 0x%wx from outedge", + logger->log ("using location %wx from outedge", outedge->goto_locus); initial_snode_in_bb->m_loc = outedge->goto_locus; } @@ -1007,7 +1007,7 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const pp_string (pp, "<TR><TD>UNKNOWN_LOCATION</TD></TR>"); else if (get_pure_location (m_loc) == UNKNOWN_LOCATION) { - pp_printf (pp, "<TR><TD>location: 0x%wx</TD></TR>", m_loc); + pp_printf (pp, "<TR><TD>location: %wx</TD></TR>", m_loc); pp_string (pp, "<TR><TD>UNKNOWN_LOCATION</TD></TR>"); } else @@ -1024,7 +1024,7 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const } if (show_location) { - pp_printf (pp, "<TR><TD>location: 0x%wx</TD></TR>", m_loc); + pp_printf (pp, "<TR><TD>location: %wx</TD></TR>", m_loc); /* Print changes to the expanded location (or all of it if we have multiple in-edges). */ @@ -1074,7 +1074,7 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const if (args.m_node_annotator) args.m_node_annotator->add_node_annotations (gv, *this); - pp_printf (pp, "<TR><TD>m_stmt_loc: 0x%wx</TD></TR>", m_stmt_loc); + pp_printf (pp, "<TR><TD>m_stmt_loc: %wx</TD></TR>", m_stmt_loc); pp_string (pp, "</TABLE>>];\n\n"); pp_flush (pp); @@ -1260,7 +1260,7 @@ superedge::dump_label_to_pp (pretty_printer *pp, bool user_facing) const pp_string (pp, ")"); } if (cfg_edge->goto_locus > BUILTINS_LOCATION) - pp_printf (pp, " (has goto_locus: 0x%wx)", cfg_edge->goto_locus); + pp_printf (pp, " (has goto_locus: %wx)", cfg_edge->goto_locus); } }
