From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30626 invoked by alias); 1 Dec 2014 07:17:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 30602 invoked by uid 89); 1 Dec 2014 07:17:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-pa0-f74.google.com Received: from mail-pa0-f74.google.com (HELO mail-pa0-f74.google.com) (209.85.220.74) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 01 Dec 2014 07:17:07 +0000 Received: by mail-pa0-f74.google.com with SMTP id kq14so1211448pab.3 for ; Sun, 30 Nov 2014 23:17:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=UYxrAdbplzjbQrO6HqUilKAM6z2VTQKU+8oTovMafA0=; b=dYmTkIU2OKLS1oPZMC65KMexf/GrKPIX/Zs7TmW3vMDm2g8E7Go4gzPY/LI7bgj51D IX75TeBxZuK2hMGpv/DBCPOvO67fWAPiomk0AakiPGP8WuW4n0mdeq3J8Xc3kOjSp+aV iU9L1pJMvxTdXYRWEDGOaeBLHZw6yQS+9sHsSxhbU+5zSzF39bwvO8py2M+Y1Kk2espb ks1oNjBlxUF6UBaGKGGO8kIkv8y/tLELU8FzWQ7OG4+Z4ReH5ooNEbuqiZe2n24HJKon QfyvkiUQGgqa50eLrvWdVgl8Zr9GsHIxIW4yhZ+N2CaeGOjfy06OP3uh+g/oAuF44TcZ oaBA== X-Gm-Message-State: ALoCoQlbg59lNEg9KuOfYF9ACxuUi+xrLXs2tHbyl23OZ6pKGl7ReQHiKeHlKDSXcmpkrhT/hGVm1nzugYzXxoI1NEt8Oi/1cm5fuPRDUWsFkmUyViFFqjyoDSO59vLyImeFu6VNR/uilOO3KrbiR/bEu1iR9gZTzLvOowV+g+DfSUTN2T6gmeQ= X-Received: by 10.70.47.36 with SMTP id a4mr17013369pdn.0.1417418225927; Sun, 30 Nov 2014 23:17:05 -0800 (PST) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id t24si664793yht.2.2014.11.30.23.17.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Nov 2014 23:17:05 -0800 (PST) Received: from ruffy2.mtv.corp.google.com ([172.17.128.107]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id rrd7aAvV.1; Sun, 30 Nov 2014 23:17:05 -0800 From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <21628.5616.357757.175619@ruffy2.mtv.corp.google.com> Date: Mon, 01 Dec 2014 07:17:00 -0000 To: Patrick Palka Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] [RFC] PR c++/16874: make it easier to use anonymous namespaces In-Reply-To: <1417404096-16170-1-git-send-email-patrick@parcs.ath.cx> References: <1417404096-16170-1-git-send-email-patrick@parcs.ath.cx> X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00002.txt.bz2 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!