Use block_enum instead of int for better typesafety

Message ID 20190711183827.242710-1-cbiesinger@google.com
State Superseded
Headers show
Series
  • Use block_enum instead of int for better typesafety
Related show

Commit Message

Christian Biesinger via gdb-patches July 11, 2019, 6:38 p.m.
---
 gdb/symtab.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

-- 
2.22.0.410.gd8fdbe21b5-goog

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 4920d94a24..54eb97ae0f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -92,7 +92,8 @@  struct block_symbol lookup_local_symbol (const char *name,
 					 enum language language);
 
 static struct block_symbol
-  lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
+  lookup_symbol_in_objfile (struct objfile *objfile,
+			    enum block_enum block_index,
 			    const char *name, const domain_enum domain);
 
 /* Type of the data stored on the program space.  */
@@ -2244,8 +2245,9 @@  lookup_global_symbol_from_objfile (struct objfile *main_objfile,
    static symbols.  */
 
 static struct block_symbol
-lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
-				  const char *name, const domain_enum domain)
+lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
+				  enum block_enum block_index, const char *name,
+				  const domain_enum domain)
 {
   gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
 
@@ -2516,11 +2518,13 @@  lookup_symbol_in_static_block (const char *name,
    BLOCK_INDEX is one of GLOBAL_BLOCK or STATIC_BLOCK.  */
 
 static struct block_symbol
-lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
+lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
 			  const char *name, const domain_enum domain)
 {
   struct block_symbol result;
 
+  gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
+
   if (symbol_lookup_debug)
     {
       fprintf_unfiltered (gdb_stdlog,