From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54147 invoked by alias); 18 Jun 2015 16:46:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 54134 invoked by uid 89); 18 Jun 2015 16:46:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 18 Jun 2015 16:46:45 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 3CC5638DCB5; Thu, 18 Jun 2015 16:46:44 +0000 (UTC) Received: from [10.3.232.67] (vpn-232-67.phx2.redhat.com [10.3.232.67]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5IGkh3Q006211; Thu, 18 Jun 2015 12:46:43 -0400 Message-ID: <1434645552.14663.149.camel@surprise> Subject: Re: [PATCH 1/3] Refactor entry point to -Wmisleading-indentation From: David Malcolm To: Patrick Palka Cc: GCC Patches Date: Thu, 18 Jun 2015 16:48:00 -0000 In-Reply-To: References: <1433871067-30661-1-git-send-email-patrick@parcs.ath.cx> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg01288.txt.bz2 On Thu, 2015-06-18 at 11:41 -0400, Patrick Palka wrote: > On Tue, Jun 9, 2015 at 1:31 PM, Patrick Palka wrote: > > This patch refactors the entry point of -Wmisleading-indentation from: > > > > void > > warn_for_misleading_indentation (location_t guard_loc, > > location_t body_loc, > > location_t next_stmt_loc, > > enum cpp_ttype next_tok_type, > > const char *guard_kind); > > > > to > > > > struct token_indent_info > > { > > location_t location; > > cpp_ttype type; > > rid keyword; > > }; > > > > void > > warn_for_misleading_indentation (const token_indent_info &guard_tinfo, > > const token_indent_info &body_tinfo, > > const token_indent_info &next_tinfo); > > > > The purpose of this refactoring is to expose more information to the > > -Wmisleading-indentation implementation to allow for more advanced > > heuristics and for better coverage. > > > > (I decided to keep the usage of const references because nobody > > seems to mind. Also I added a new header file, c-indentation.h.) > > > > gcc/c-family/ChangeLog: > > > > * c-indentation.h (struct token_indent_info): Define. > > (get_token_indent_info): Define. > > (warn_for_misleading_information): Declare. > > * c-common.h (warn_for_misleading_information): Remove. > > * c-identation.c (warn_for_misleading_indentation): > > Change declaration to take three token_indent_infos. Adjust > > accordingly. > > * c-identation.c (should_warn_for_misleading_indentation): > > Likewise. Bail out early if the body is a compound statement. > > (guard_tinfo_to_string): Define. > > > > gcc/c/ChangeLog: > > > > * c-parser.c (c_parser_if_body): Take token_indent_info > > argument. Call warn_for_misleading_indentation even when the > > body is a semicolon. Extract token_indent_infos corresponding > > to the guard, body and next tokens. Adjust call to > > warn_for_misleading_indentation accordingly. > > (c_parser_else_body): Likewise. > > (c_parser_if_statement): Likewise. > > (c_parser_while_statement): Likewise. > > (c_parser_for_statement): Likewise. > > > > gcc/cp/ChangeLog: > > > > * parser.c (cp_parser_selection_statement): Move handling of > > semicolon body to ... > > (cp_parser_implicitly_scoped_statement): .. here. Call > > warn_for_misleading_indentation even when the body is a > > semicolon. Extract token_indent_infos corresponding to the > > guard, body and next tokens. Adjust call to > > warn_for_misleading_indentation accordingly. Take > > token_indent_info argument. > > (cp_parser_already_scoped_statement): Likewise. > > (cp_parser_selection_statement, cp_parser_iteration_statement): > > Extract a token_indent_info corresponding to the guard token. > > Pinging this series. FWIW, they look reasonable to me; I'm not a reviewer.