From: Tom Tromey Date: Sun, 16 Nov 2025 17:33:37 +0000 (-0700) Subject: Rename lookup_struct_typedef X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62b8588c517fa7abc32b6bcdeeb1ae719af7cbe6;p=thirdparty%2Fbinutils-gdb.git Rename lookup_struct_typedef 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. --- diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 9f1cb1b2e2a..6dd2b0800dd 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -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; diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index b6f42b982eb..b307a0022b5 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -79,31 +79,14 @@ struct objc_method { static const registry::key 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 diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h index ec6fbe7aaf9..d6a7509f21a 100644 --- a/gdb/objc-lang.h +++ b/gdb/objc-lang.h @@ -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 */