]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa: Fix pritting of symtab_node type [PR122512]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Fri, 31 Oct 2025 21:35:41 +0000 (14:35 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 1 Nov 2025 02:07:30 +0000 (19:07 -0700)
The problem here r16-4747-g529c25ed6e0a06 changed
symtab_type to toplevel_type and then added 2 types
at the begining but didn't update symtab_type_names.
This obvious patch changes symtab_type_names to toplevel_type_names,
adds a _MAX type to toplevel_type and a comment about keeping them in sync.
Also adds an static assert to make sure if someone adds a toplevel_type
that toplevel_type_names get updated too.

Pushed as obvious after a build and test.

PR ipa/122512
gcc/ChangeLog:

* cgraph.h (enum toplevel_type): Add TOPLEVEL_MAX. Add comment
about keeping toplevel_type_names in sync.
* symtab.cc (symtab_type_names): Rename to ...
(toplevel_type_names): Add new types and add an assert about
the size.
(symtab_node::get_symtab_type_string): Use toplevel_type_names
instead of symtab_type_names.
(symtab_node::dump_base): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/cgraph.h
gcc/symtab.cc

index a937d0a574afd1aa7d7707eb7060db6b9a0b4bca..aa2207b1dd20c80909067b6b476e26df05d38607 100644 (file)
@@ -38,6 +38,8 @@ class ipa_opt_pass_d;
 typedef ipa_opt_pass_d *ipa_opt_pass;
 
 /* Toplevel consists of functions, variables and assembly.
+   Make sure toplevel_type_names in symtab.cc is kept in sync
+   with this.
    TODO: add labels and CONST_DECLs.  */
 enum toplevel_type
 {
@@ -45,7 +47,8 @@ enum toplevel_type
   TOPLEVEL_ASM,
   SYMTAB_SYMBOL,
   SYMTAB_FUNCTION,
-  SYMTAB_VARIABLE
+  SYMTAB_VARIABLE,
+  TOPLEVEL_MAX
 };
 
 /* Section names are stored as reference counted strings in GGC safe hashtable
index 20dfe09ec2fef06b33627d1d630e27d54fa12f32..fb2aca5f4f7af3942b50f090a43b4fa76d32abb8 100644 (file)
@@ -873,7 +873,16 @@ symtab_node::dump_referring (FILE *file)
   fprintf (file, "\n");
 }
 
-static const char * const symtab_type_names[] = {"symbol", "function", "variable"};
+static const char * const toplevel_type_names[] =
+{
+ "base",
+ "asm",
+ "symbol",
+ "function",
+ "variable",
+};
+
+static_assert (ARRAY_SIZE(toplevel_type_names)==TOPLEVEL_MAX);
 
 /* Dump the visibility of the symbol.  */
 
@@ -889,7 +898,7 @@ symtab_node::get_visibility_string () const
 const char *
 symtab_node::get_symtab_type_string () const
 {
-  return symtab_type_names[type];
+  return toplevel_type_names[type];
 }
 
 /* Dump base fields of symtab nodes to F.  Not to be used directly.  */
@@ -904,7 +913,7 @@ symtab_node::dump_base (FILE *f)
   fprintf (f, "%s (%s)", dump_asm_name (), name ());
   if (dump_flags & TDF_ADDRESS)
     dump_addr (f, " @", (void *)this);
-  fprintf (f, "\n  Type: %s", symtab_type_names[type]);
+  fprintf (f, "\n  Type: %s", toplevel_type_names[type]);
 
   if (definition)
     fprintf (f, " definition");