public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Patrick Palka <patrick@parcs.ath.cx>, 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()
Date: Mon, 22 Jun 2015 17:37:00 -0000	[thread overview]
Message-ID: <55884727.70107@redhat.com> (raw)
In-Reply-To: <1433871067-30661-2-git-send-email-patrick@parcs.ath.cx>

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

  reply	other threads:[~2015-06-22 17:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09 17:31 [PATCH 1/3] Refactor entry point to -Wmisleading-indentation Patrick Palka
2015-06-09 17:31 ` [PATCH 2/3] Remove is_first_nonwhitespace_on_line(), instead improve get_visual_column() Patrick Palka
2015-06-22 17:37   ` Jeff Law [this message]
2015-06-09 18:01 ` [PATCH 3/3] Improve -Wmissing-indentation heuristics Patrick Palka
2015-06-18 16:46   ` David Malcolm
2015-06-18 16:58     ` Patrick Palka
2015-06-18 17:15       ` Patrick Palka
2015-06-22 16:51       ` Jeff Law
2015-06-22 17:38   ` Jeff Law
2015-06-18 15:45 ` [PATCH 1/3] Refactor entry point to -Wmisleading-indentation Patrick Palka
2015-06-18 16:48   ` David Malcolm
2015-06-18 17:09     ` Patrick Palka
2015-06-22 16:37     ` Jeff Law
2015-06-22 17:32 ` Jeff Law
2015-06-22 19:03   ` Patrick Palka
2015-06-23 19:14     ` Patrick Palka
2015-07-28  2:36       ` Patrick Palka
2015-07-31 16:56         ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55884727.70107@redhat.com \
    --to=law@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=patrick@parcs.ath.cx \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).