From patchwork Wed Sep 4 11:04:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Dos Reis X-Patchwork-Id: 272574 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2269A2C0040 for ; Wed, 4 Sep 2013 21:04:45 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=IKSmPljCR4uM646O8lF9fy3EdxCDDuoM7ZaD94V49vl2LaivSgnuL u8Tc/I33x/Saz4gTzoNVixmavt35h/dc3fcsJD+nn7xsXvewqPpLP6Gxzc+nIts7 Zhk7pkELRS/qyZuoCN4ECcBXFsi3OF9mt80k9kmdbwLaBCWTA+jw3Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=llBv5DqeZZCIoezA9ZwFQyCheXM=; b=fm0xwfvnVwM9Egyp2ADD Bi4rucmHwkF3YRX+wsBRILG01QbOpFFfjziw8VunfqwWgDQJfh7OT9Rss9MGw57P a58bF7PfQmdb3vQmPEbByMJdicaWztKkiqEucj2MGNDai+gQD59arMHXzd3hM/Q4 6cR46e0hPpfn/PaJc8kbVLc= Received: (qmail 4903 invoked by alias); 4 Sep 2013 11:04:37 -0000 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 Received: (qmail 4893 invoked by uid 89); 4 Sep 2013 11:04:37 -0000 Received: from www.axiomatics.org (HELO mail.axiomatics.org) (66.228.53.191) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Sep 2013 11:04:37 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, NO_RELAYS autolearn=ham version=3.3.2 X-HELO: mail.axiomatics.org Received: by mail.axiomatics.org (Postfix, from userid 1000) id 14B15ECB0; Wed, 4 Sep 2013 06:04:34 -0500 (CDT) From: Gabriel Dos Reis To: gcc-patches@gcc.gnu.org Subject: Clean up pretty printers [21/n] Date: Wed, 04 Sep 2013 06:04:33 -0500 Message-ID: <87li3crgou.fsf@euclid.axiomatics.org> Lines: 278 MIME-Version: 1.0 Tested on an x86_64-suse-linux. Applied to trunk. -- Gaby 2013-09-04 Gabriel Dos Reis c-family/ * c-pretty-print.h (c_pretty_printer::simple_type_specifier): Now a virtual member function. (pp_simple_type_specifier): Remove. (pp_c_type_specifier): Likewise. * c-pretty-print.c (c_pretty_printer::simple_type_specifier): Rename from pp_c_type_specifier. Adjust. (c_pretty_printer::c_pretty_printer): Do not assign to simple_type_specifier. cp/ * cxx-pretty-print.h (cxx_pretty_printer::simple_type_specifier): Declare as overrider. * cxx-pretty-print.c (cxx_pretty_printer::simple_type_specifier): Rename from pp_cxx_simple_type_specifier. (cxx_pretty_printer::cxx_pretty_printer): Do not assign to simple_type_specifier. Index: c-family/c-pretty-print.c =================================================================== --- c-family/c-pretty-print.c (revision 202240) +++ c-family/c-pretty-print.c (working copy) @@ -305,7 +305,10 @@ } } -/* type-specifier: +/* simple-type-specifier: + type-specifier + + type-specifier: void char short @@ -328,17 +331,17 @@ __vector__ */ void -pp_c_type_specifier (c_pretty_printer *pp, tree t) +c_pretty_printer::simple_type_specifier (tree t) { const enum tree_code code = TREE_CODE (t); switch (code) { case ERROR_MARK: - pp->translate_string (""); + translate_string (""); break; case IDENTIFIER_NODE: - pp_c_identifier (pp, IDENTIFIER_POINTER (t)); + pp_c_identifier (this, IDENTIFIER_POINTER (t)); break; case VOID_TYPE: @@ -349,7 +352,7 @@ if (TYPE_NAME (t)) { t = TYPE_NAME (t); - pp_c_type_specifier (pp, t); + simple_type_specifier (t); } else { @@ -360,11 +363,11 @@ t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t)); if (TYPE_NAME (t)) { - pp_c_type_specifier (pp, t); + simple_type_specifier (t); if (TYPE_PRECISION (t) != prec) { - pp_colon (pp); - pp_decimal_int (pp, prec); + pp_colon (this); + pp_decimal_int (this, prec); } } else @@ -372,52 +375,52 @@ switch (code) { case INTEGER_TYPE: - pp->translate_string (TYPE_UNSIGNED (t) - ? "translate_string ("translate_string ("id_expression (t); + id_expression (t); else - pp->translate_string (""); + translate_string (""); break; case UNION_TYPE: case RECORD_TYPE: case ENUMERAL_TYPE: if (code == UNION_TYPE) - pp_c_ws_string (pp, "union"); + pp_c_ws_string (this, "union"); else if (code == RECORD_TYPE) - pp_c_ws_string (pp, "struct"); + pp_c_ws_string (this, "struct"); else if (code == ENUMERAL_TYPE) - pp_c_ws_string (pp, "enum"); + pp_c_ws_string (this, "enum"); else - pp->translate_string (""); + translate_string (""); if (TYPE_NAME (t)) - pp->id_expression (TYPE_NAME (t)); + id_expression (TYPE_NAME (t)); else - pp->translate_string (""); + translate_string (""); break; default: - pp_unsupported_tree (pp, t); + pp_unsupported_tree (this, t); break; } } @@ -483,7 +486,7 @@ break; default: - pp_simple_type_specifier (pp, t); + pp->simple_type_specifier (t); break; } if ((pp->flags & pp_c_flag_gnu_v3) && code != POINTER_TYPE) @@ -2328,7 +2331,6 @@ type_specifier_seq = pp_c_specifier_qualifier_list; ptr_operator = pp_c_pointer; parameter_list = pp_c_parameter_type_list; - simple_type_specifier = pp_c_type_specifier; } Index: c-family/c-pretty-print.h =================================================================== --- c-family/c-pretty-print.h (revision 202240) +++ c-family/c-pretty-print.h (working copy) @@ -69,6 +69,7 @@ virtual void declaration (tree); virtual void declaration_specifiers (tree); + virtual void simple_type_specifier (tree); virtual void function_specifier (tree); virtual void storage_class_specifier (tree); virtual void declarator (tree); @@ -88,7 +89,6 @@ c_pretty_print_fn type_specifier_seq; c_pretty_print_fn ptr_operator; c_pretty_print_fn parameter_list; - c_pretty_print_fn simple_type_specifier; }; #define pp_c_tree_identifier(PPI, ID) \ @@ -97,7 +97,6 @@ #define pp_type_specifier_seq(PP, D) (PP)->type_specifier_seq (PP, D) #define pp_ptr_operator(PP, D) (PP)->ptr_operator (PP, D) #define pp_parameter_list(PP, T) (PP)->parameter_list (PP, T) -#define pp_simple_type_specifier(PP, T) (PP)->simple_type_specifier (PP, T) void pp_c_whitespace (c_pretty_printer *); void pp_c_left_paren (c_pretty_printer *); @@ -124,7 +123,6 @@ void pp_c_type_qualifier_list (c_pretty_printer *, tree); void pp_c_parameter_type_list (c_pretty_printer *, tree); void pp_c_specifier_qualifier_list (c_pretty_printer *, tree); -void pp_c_type_specifier (c_pretty_printer *, tree); /* Expressions. */ void pp_c_logical_or_expression (c_pretty_printer *, tree); void pp_c_expression_list (c_pretty_printer *, tree); Index: cp/cxx-pretty-print.c =================================================================== --- cp/cxx-pretty-print.c (revision 202240) +++ cp/cxx-pretty-print.c (working copy) @@ -1249,32 +1249,32 @@ double void */ -static void -pp_cxx_simple_type_specifier (cxx_pretty_printer *pp, tree t) +void +cxx_pretty_printer::simple_type_specifier (tree t) { switch (TREE_CODE (t)) { case RECORD_TYPE: case UNION_TYPE: case ENUMERAL_TYPE: - pp_cxx_qualified_id (pp, t); + pp_cxx_qualified_id (this, t); break; case TEMPLATE_TYPE_PARM: case TEMPLATE_TEMPLATE_PARM: case TEMPLATE_PARM_INDEX: case BOUND_TEMPLATE_TEMPLATE_PARM: - pp_cxx_unqualified_id (pp, t); + pp_cxx_unqualified_id (this, t); break; case TYPENAME_TYPE: - pp_cxx_ws_string (pp, "typename"); - pp_cxx_nested_name_specifier (pp, TYPE_CONTEXT (t)); - pp_cxx_unqualified_id (pp, TYPE_NAME (t)); + pp_cxx_ws_string (this, "typename"); + pp_cxx_nested_name_specifier (this, TYPE_CONTEXT (t)); + pp_cxx_unqualified_id (this, TYPE_NAME (t)); break; default: - pp_c_type_specifier (pp, t); + c_pretty_printer::simple_type_specifier (t); break; } } @@ -1300,7 +1300,7 @@ case TYPE_DECL: case BOUND_TEMPLATE_TEMPLATE_PARM: pp_cxx_cv_qualifier_seq (pp, t); - pp_cxx_simple_type_specifier (pp, t); + pp->simple_type_specifier (t); break; case METHOD_TYPE: @@ -2427,5 +2427,4 @@ type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq; parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause; - simple_type_specifier = (pp_fun) pp_cxx_simple_type_specifier; } Index: cp/cxx-pretty-print.h =================================================================== --- cp/cxx-pretty-print.h (revision 202240) +++ cp/cxx-pretty-print.h (working copy) @@ -46,6 +46,7 @@ void statement (tree); void declaration (tree); void declaration_specifiers (tree); + void simple_type_specifier (tree); void function_specifier (tree); void declarator (tree); void direct_declarator (tree);