]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Change how C parser looks up type tag names
authorTom Tromey <tom@tromey.com>
Tue, 5 Aug 2025 23:32:55 +0000 (17:32 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 8 Sep 2025 20:06:10 +0000 (14:06 -0600)
commited1057031bd38df25878ade56740bf79b720f5e9
tree0d65c773437d7536573a1f758a1639e4443ef63a
parentb318480f27322c15c6b10c1bab4418e81d44b77e
Change how C parser looks up type tag names

In an earlier version of this series, Simon noticed that something
like "ptype struct type" was much slower.

The deep problem here is the hack in best_symbol -- in this particular
case the C parser is including SEARCH_VAR_DOMAIN, which means that a
type is not "best".

Fixing best_symbol would be good to do, but it's difficult and I
already had many struggles getting this series to this point.  So,
rather than fix that, I elected to modify the parser.

The key insight here is that the name lookup in classify_name is
useless when a tag name is expected.  This patch adds a flag so that
this lookup is not done.  (Incidentally, this kind of thing is much
more straightforward in a recursive descent parser, something like
classify_name would only be applied post-lexing where appropriate.)

This change speeds up the lookup by avoiding the best_symbol hack,
instead searching only for a type.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
gdb/c-exp.y