Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: fix PR gdb/2489
Date: Tue, 03 Feb 2009 01:20:00 -0000	[thread overview]
Message-ID: <200902030121.48729.pedro@codesourcery.com> (raw)
In-Reply-To: <m3hc3cmj25.fsf@fleche.redhat.com>

On Tuesday 03 February 2009 00:59:46, Tom Tromey wrote:
> Pedro> +  for (i = TYPE_NFN_FIELDS (type) - 1; i >=0; --i)
> Pedro> +    {
> Pedro> +      char *name = TYPE_FN_FIELDLIST_NAME (type, i);
> Pedro> +      if (name && ! strncmp (name, fieldname, namelen))
> Pedro> +       {
> Pedro> +         if (!type_name)
> Pedro> +           type_name = type_name_no_tag (type);
> Pedro> +         /* Omit constructors from the completion list.  */
> Pedro> +         if (strcmp (type_name, name))
> Pedro> +           {
> 
> Pedro> Can type_name ever be NULL here then?
> 
> The reason for the check here is that we compute type_name the first
> time we need it.  It is initialized to NULL, but only set once.

Oh, sorry, I guess I wasn't clear.  I meant after the
type_name_no_tag call, at the strcmp line.

I mainly asked due to this:

 /* Return a typename for a struct/union/enum type without "struct ",
    "union ", or "enum ".  If the type has a NULL name, return NULL.  */

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 char *
 type_name_no_tag (const struct type *type)
 {
   if (TYPE_TAG_NAME (type) != NULL)
     return TYPE_TAG_NAME (type);

   /* Is there code which expects this to return the name if there is
      no tag name?  My guess is that this is mainly used for C++ in
      cases where the two will always be the same.  */
   return TYPE_NAME (type);
 }

I don't know if that can happen here.  That was also the reason I
suggested an annonymous struct/class test.

On Tuesday 03 February 2009 00:59:46, Tom Tromey wrote:
> Pedro> (I wish we had a function we could call that abstracted and
> Pedro> made easier to write/read these completion tests.)
> 
> I rewrote the tests to use the "complete" command rather than sending
> a TAB.  This makes them much simpler.
> 

Indeed!  Much nicer.

-- 
Pedro Alves


  parent reply	other threads:[~2009-02-03  1:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-01 19:15 Tom Tromey
2008-10-21 22:25 ` Pedro Alves
2009-02-03  1:02   ` Tom Tromey
2009-02-03  1:10     ` Tom Tromey
2009-02-03  1:20     ` Pedro Alves [this message]
2009-02-03  1:38       ` Tom Tromey
2009-02-03 19:20         ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200902030121.48729.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox