From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24438 invoked by alias); 22 Jun 2015 17:34:35 -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 24429 invoked by uid 89); 22 Jun 2015 17:34:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham 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; Mon, 22 Jun 2015 17:34:33 +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 C2D523672A4; Mon, 22 Jun 2015 17:34:32 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-49.phx2.redhat.com [10.3.113.49]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5MHYW3K024724; Mon, 22 Jun 2015 13:34:32 -0400 Message-ID: <55884727.70107@redhat.com> Date: Mon, 22 Jun 2015 17:37:00 -0000 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Patrick Palka , gcc-patches@gcc.gnu.org CC: dmalcolm@redhat.com Subject: Re: [PATCH 2/3] Remove is_first_nonwhitespace_on_line(), instead improve get_visual_column() References: <1433871067-30661-1-git-send-email-patrick@parcs.ath.cx> <1433871067-30661-2-git-send-email-patrick@parcs.ath.cx> In-Reply-To: <1433871067-30661-2-git-send-email-patrick@parcs.ath.cx> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg01486.txt.bz2 On 06/09/2015 11:31 AM, Patrick Palka wrote: > This patch removes the function is_first_nonwhitespace_on_line() in > favor of augmenting the function get_visual_column() to optionally > return the visual column corresponding to the first non-whitespace character > on the line. Existing usage of is_first_nonwhitespace_on_line() can > be trivially replaced by calling get_visual_column() and comparing *out > with *first_nws. > > The rationale for this change is that in many cases it is better to use > the visual column of the first non-whitespace character rather than the > visual column of the token. Consider: > > if (p) { > foo (1); > } else // GUARD > if (q) // BODY > foo (2); > foo (3); // NEXT > > Here, with current heuristics, we do not emit a warning because we > notice that the visual columns of each token line up ("suggesting" > autogenerated code). Yet it is obvious that we should warn here because > it misleadingly looks like the foo (3); statement is guarded by the > else. > > If we instead consider the visual column of the first non-whitespace > character on the guard line, the columns will not line up thus we will > emit the warning. This will be done in the next patch. > > gcc/c-family/ChangeLog: > > * c-indentation.c (get_visual_column): Add parameter first_nws, > use it. Update comment documenting the function. > (is_first_nonwhitespace_on_line): Remove. > (should_warn_for_misleading_indentation): Replace usage of > of is_first_nonwhitespace_on_line with get_visual_column. Same comment/question WRT testing as the prior patch. OK once you've confirmed bootstrap & regression testing was completed successfully. jeff