]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Rename lookup_struct_typedef
authorTom Tromey <tom@tromey.com>
Sun, 16 Nov 2025 17:33:37 +0000 (10:33 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 2 Dec 2025 16:22:45 +0000 (09:22 -0700)
The helper function lookup_struct_typedef is only ever called with
"noerr=1".  This patch removes the parameter, changes the name, and
removes some unnecessary code.

gdb/c-exp.y
gdb/objc-lang.c
gdb/objc-lang.h

index 9f1cb1b2e2a4da5e0aae7825c8830cf81c51cb4f..6dd2b0800dda7abadc2952f76310eda9d90d7391 100644 (file)
@@ -3167,8 +3167,8 @@ classify_name (struct parser_state *par_state, const struct block *block,
          struct symbol *sym;
 
          yylval.theclass.theclass = Class;
-         sym = lookup_struct_typedef (copy.c_str (),
-                                      par_state->expression_context_block, 1);
+         sym = lookup_struct_noerr (copy.c_str (),
+                                    par_state->expression_context_block);
          if (sym)
            yylval.theclass.type = sym->type ();
          return CLASSNAME;
index b6f42b982eb326f7c534000aef695df3e3b5a464..b307a0022b5d68b16bdc49f0e5b26664118e2373 100644 (file)
@@ -79,31 +79,14 @@ struct objc_method {
 static const registry<objfile>::key<unsigned int> objc_objfile_data;
 
 /* Lookup a structure type named "struct NAME", visible in lexical
-   block BLOCK.  If NOERR is nonzero, return zero if NAME is not
-   suitably defined.  */
+   block BLOCK.  Return nullptr if no such type is found.  */
 
 struct symbol *
-lookup_struct_typedef (const char *name, const struct block *block, int noerr)
+lookup_struct_noerr (const char *name, const struct block *block)
 {
-  struct symbol *sym;
-
-  sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
-
-  if (sym == NULL)
-    {
-      if (noerr)
-       return 0;
-      else
-       error (_("No struct type named %s."), name);
-    }
-  if (sym->type ()->code () != TYPE_CODE_STRUCT)
-    {
-      if (noerr)
-       return 0;
-      else
-       error (_("This context has class, union or enum %s, not a struct."),
-              name);
-    }
+  symbol *sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
+  if (sym == nullptr || sym->type ()->code () != TYPE_CODE_STRUCT)
+    return nullptr;
   return sym;
 }
 
@@ -212,9 +195,9 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len)
   else
     error (_("NSString: internal error -- no way to create new NSString"));
 
-  sym = lookup_struct_typedef("NSString", 0, 1);
+  sym = lookup_struct_noerr ("NSString", 0);
   if (sym == NULL)
-    sym = lookup_struct_typedef("NXString", 0, 1);
+    sym = lookup_struct_noerr ("NXString", 0);
   if (sym == NULL)
     type = builtin_type (gdbarch)->builtin_data_ptr;
   else
index ec6fbe7aaf94d9bd75c0ecd61a417842bd4d8613..d6a7509f21a92e3e2a0d506b3a1adec69d30be33 100644 (file)
@@ -44,8 +44,7 @@ extern void start_msglist (void);
 extern void add_msglist (struct stoken *str, int addcolon);
 extern int end_msglist (struct parser_state *);
 
-struct symbol *lookup_struct_typedef (const char *name,
-                                     const struct block *block,
-                                     int noerr);
+struct symbol *lookup_struct_noerr (const char *name,
+                                   const struct block *block);
 
 #endif /* GDB_OBJC_LANG_H */