From patchwork Tue Jun 12 15:58:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sterling Augustine X-Patchwork-Id: 164442 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 46E41B6FBD for ; Wed, 13 Jun 2012 01:58:58 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340121540; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=Qb/jwYy wP2kFQtBQT3QmKmnM5O0=; b=j7sLGuTtW37+5WhXqkBrbnQ2QXqPZBNmbeXg2c1 nWGSyE4xAhZUzMkKX1VuLPV/AG6mU82ApGHbNdbqzRglNE/uUgJkO+s8rCuVe2Wl zbfK3Vyv7DPILRppU6diFtnLGrNRW7vflyftGdk9qLC1r31RPxHe8+TKvNAPBV+P Snfk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=mMtj/GYdaD5U/G3sWqUZSexfzMLIiJZsKmTRWPWYB2pT1w2/qgyGK7yQl6S8WV LH0ac+x8Elm74YqK6uGFtwQf8TpyQRX6YW0v3nUN6byy4bQ1Q5NJW7HLnE2mP6Nx Gt6vJ/j3KN6TgHuScSZcGaxVIDUtTp0ZXflb+WMkqJpcc=; Received: (qmail 18161 invoked by alias); 12 Jun 2012 15:58:52 -0000 Received: (qmail 18135 invoked by uid 22791); 12 Jun 2012 15:58:50 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yx0-f201.google.com (HELO mail-yx0-f201.google.com) (209.85.213.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Jun 2012 15:58:34 +0000 Received: by yenl11 with SMTP id l11so480446yen.2 for ; Tue, 12 Jun 2012 08:58:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=aw1g6XYvF7G8nKBCei5z4hO2SOo+j7wZtEJadEOwmnI=; b=fWY8JB2hqANUF60sFxXTdFV93YhIt+XsTeRBcu9ld6dGshx1n1HjQz1ewVh4TBhebM L+yFw1cUELMueD+cZ9vOG/foV68kSlfL9JTWHU3a3YpaQrGDQ2hoqklHq1YvZ0V+/jSq y1jEtIkaRUyzXFV8dG7BmOSNBlAZ0nUYZipOvPjNa4pcT8jE9oPvtI0FlJWj/02G8E69 QK42u1eW44GZnTogoE0Ca31j69o0OrBLjETm4w8Q4PdtAqsagfjx/ISZ+xttY2ECpeqg FwLruznVQ62VbnzoWTQAm66mCyB03Jwe4v6qffGZQRwBVea+snWRDdkpGkrwWNIiV3QV buHw== Received: by 10.101.24.9 with SMTP id b9mr10754496anj.21.1339516713507; Tue, 12 Jun 2012 08:58:33 -0700 (PDT) Received: by 10.101.24.9 with SMTP id b9mr10754492anj.21.1339516713447; Tue, 12 Jun 2012 08:58:33 -0700 (PDT) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id d5si13060257yhj.7.2012.06.12.08.58.33 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 12 Jun 2012 08:58:33 -0700 (PDT) Received: from sterling.mtv.corp.google.com (sterling.mtv.corp.google.com [172.18.111.14]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id 40AFE10004D; Tue, 12 Jun 2012 08:58:33 -0700 (PDT) Received: by sterling.mtv.corp.google.com (Postfix, from userid 135279) id D95D4160C6E; Tue, 12 Jun 2012 08:58:32 -0700 (PDT) To: reply@codereview.appspotmail.com,gcc-patches@gcc.gnu.org Subject: [Google 4.6] Backport C++ canonicalization patch (issue6297080) Message-Id: <20120612155832.D95D4160C6E@sterling.mtv.corp.google.com> Date: Tue, 12 Jun 2012 08:58:32 -0700 (PDT) From: saugustine@google.com (Sterling Augustine) X-Gm-Message-State: ALoCoQnl1VSSMHQ9/4JvG7cr3JDfS+2A07OOhre6hr+hYZFtAQIZZedWfeX0XWF/U5C+ukwQIPTBE2JZz6M6COv75MZ/AEiUUBYffcNNjIloox9DMtMjnbkXJfDF5TI86h9pmFrJW4yoiSdDRbVbrt4k30SZdOae4g== Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The enclosed patch for Google 4.6 backports the final pubnames-canonicalization patch from top of trunk. It differs slightly from the earlier one because google/4.6 had an earlier implementation already present. OK for Google 4.6? Sterling 2012-06-11 Sterling Augustine * gcc/c-family/c-pretty-print.h: Adjust pp_c_pretty_print_flags enum. * gcc/cp/error.c (decl_as_dwarf_string, lang_decl_dwarf_name): New functions. * gcc/cp/cp-lang.c (cxx_dwarf_name): Call them. * gcc/cp/cp-tree.h: Declare them. --- This patch is available for review at http://codereview.appspot.com/6297080 Index: gcc/c-family/c-pretty-print.h =================================================================== --- gcc/c-family/c-pretty-print.h (revision 188405) +++ gcc/c-family/c-pretty-print.h (working copy) @@ -30,8 +30,8 @@ typedef enum { pp_c_flag_abstract = 1 << 1, - pp_c_flag_last_bit = 2, - pp_c_flag_gnu_v3 = 4 + pp_c_flag_gnu_v3 = 1 << 2, + pp_c_flag_last_bit = 3 } pp_c_pretty_print_flags; Index: gcc/cp/error.c =================================================================== --- gcc/cp/error.c (revision 188405) +++ gcc/cp/error.c (working copy) @@ -2459,7 +2459,22 @@ return pp_formatted_text (cxx_pp); } +/* Wrap decl_as_string with options appropriate for dwarf. */ + const char * +decl_as_dwarf_string (tree decl, int flags) +{ + const char *name; + /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag + here will be adequate to get the desired behaviour. */ + pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3; + name = decl_as_string (decl, flags); + /* Subsequent calls to the pretty printer shouldn't use this style. */ + pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3; + return name; +} + +const char * decl_as_string (tree decl, int flags) { reinit_cxx_pp (); @@ -2479,6 +2494,21 @@ return pp_formatted_text (cxx_pp); } +/* Wrap lang_decl_name with options appropriate for dwarf. */ + +const char * +lang_decl_dwarf_name (tree decl, int v, bool translate) +{ + const char *name; + /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag + here will be adequate to get the desired behaviour. */ + pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3; + name = lang_decl_name (decl, v, translate); + /* Subsequent calls to the pretty printer shouldn't use this style. */ + pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3; + return name; +} + /* Generate the three forms of printable names for cxx_printable_name. */ const char * Index: gcc/cp/cp-lang.c =================================================================== --- gcc/cp/cp-lang.c (revision 188405) +++ gcc/cp/cp-lang.c (working copy) @@ -183,17 +183,11 @@ && (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDANAME_P (DECL_NAME (t)))) return NULL; if (verbosity >= 2) - return decl_as_string (t, + return decl_as_dwarf_string (t, TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME - | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS - | TFF_MATCH_GNU_V3_DEMANGLER); + | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS); - /* decl_as_string handles namespaces--especially anonymous ones--more - appropriately for debugging than cxx_printable_name. But - cxx_printable_name handles templates and global ctors and dtors better. */ - if (TREE_CODE (t) == NAMESPACE_DECL) - return decl_as_string (t, TFF_MATCH_GNU_V3_DEMANGLER); - return cxx_printable_name (t, verbosity); + return lang_decl_dwarf_name (t, verbosity, false); } static enum classify_record Index: gcc/cp/cp-tree.h =================================================================== --- gcc/cp/cp-tree.h (revision 188405) +++ gcc/cp/cp-tree.h (working copy) @@ -4913,8 +4913,10 @@ extern const char *type_as_string_translate (tree, int); extern const char *decl_as_string (tree, int); extern const char *decl_as_string_translate (tree, int); +extern const char *decl_as_dwarf_string (tree, int); extern const char *expr_as_string (tree, int); extern const char *lang_decl_name (tree, int, bool); +extern const char *lang_decl_dwarf_name (tree, int, bool); extern const char *language_to_string (enum languages); extern const char *class_key_or_enum_as_string (tree); extern void print_instantiation_context (void);