public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Patrick Palka <patrick@parcs.ath.cx>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] [RFC] PR c++/16874: make it easier to use anonymous namespaces
Date: Mon, 01 Dec 2014 07:17:00 -0000	[thread overview]
Message-ID: <21628.5616.357757.175619@ruffy2.mtv.corp.google.com> (raw)
In-Reply-To: <1417404096-16170-1-git-send-email-patrick@parcs.ath.cx>

Patrick Palka writes:
 > Symbols referring to names defined inside a top-level C++ anonymous
 > namespace have an "(anonymous namespace)::" prefix attached to them.
 > Referring to such symbols in commands such as "print" and "break" is
 > cumbersome because the prefix is tricky to type and symbols with this
 > prefix do not TAB-complete properly.
 > 
 > To make it easier to refer to such symbols, this patch allows the user
 > to omit "(anonymous namespace)::" prefix from these symbols.  In other
 > words, this patch allows the symbol "(anonymous namespace)::FOO" to be
 > referred to as "FOO".  Likewise  "(anonymous namespace)::FOO::BAR" ==>
 > "FOO::BAR".  But not "FOO::(anonymous namespace)::BAZ" ==> "FOO::BAZ"
 > because the anonymous namespace in question is not the top-level one.
 > It also doesn't handle "(anonymous namespace)::(anonymous namespace)::FOO"
 > ==> "FOO".
 > 
 > This patch is implemented in three hunks.  The cp-namespace.c hunk
 > handles the elision of the anon prefix during symbol lookup in the
 > expression context (.e.g. "print foo").  The linespec.c hunk handles the
 > elision of the anon prefix during symbol lookup in the breakpoint
 > context (e.g. "break foo").  And finally the symtab.c hunk handles the
 > elision of the anon prefix during symbol completion.  This patch does
 > not yet have a test case, but nonetheless I would very much appreciate
 > comments on the approach that this patch takes in address the mentioned
 > PR.
 > 
 > I chose this approach because symbols defined in the root anonymous
 > namespace are very akin to static symbols so it is intuitive and
 > convenient to treat them as such, that is, to pretend that their
 > (anonymous namespace):: prefix doesn't even exist (unless the prefix was
 > explicitly given by the user).
 > 
 > gdb/ChangeLog:
 > 
 > 	* cp-support.h (cp_in_root_anonymous_namespace_p): New function.
 > 	* cp-namespace.c (cp_lookup_symbol_nonlocal): Try looking for
 > 	the symbol within the root anonymous namespace.
 > 	* linespec.c (find_linespec_symbols): Likewise.
 > 	* symtab.c (completion_list_add_name): Ignore the root anonymous
 > 	namespace prefix when looking for matching symbols.

Cool.

I need to look this over but can't in the next few days.
On the off chance that someone else looks it over and
gives it an OK, please hold off committing this until
I can review it too.

Thanks!

  reply	other threads:[~2014-12-01  7:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01  3:22 Patrick Palka
2014-12-01  7:17 ` Doug Evans [this message]
2014-12-07 23:33 ` Doug Evans

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=21628.5616.357757.175619@ruffy2.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=patrick@parcs.ath.cx \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).