From: Joe Perches <joe@perches.com>
To: Nick Desaulniers <ndesaulniers@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>
Subject: Re: [PATCH] cvt_fallthrough: A tool to convert /* fallthrough */ comments to fallthrough;
Date: Mon, 09 Mar 2020 12:55:14 -0700 [thread overview]
Message-ID: <e8db6d1a92001b02bbe2c2a1fc3413e1d44aa0a4.camel@perches.com> (raw)
In-Reply-To: <CAKwvOdkzc3AtpkRcZU06yvAEzp_bjw55HkpGui6RsAcy=FhnJw@mail.gmail.com>
On Mon, 2020-03-09 at 12:36 -0700, Nick Desaulniers wrote:
> On Thu, Feb 20, 2020 at 4:21 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> > On Thu, 20 Feb 2020 12:30:21 -0800 Joe Perches <joe@perches.com> wrote:
> >
> > > Convert /* fallthrough */ style comments to the pseudo-keyword fallthrough
> > > to allow clang 10 and higher to work at finding missing fallthroughs too.
> > >
> > > Requires a git repository and overwrites the input files.
> > >
> > > Typical command use:
> > > ./scripts/cvt_fallthrough.pl <path|file>
> > >
> > > i.e.:
> > >
> > > $ ./scripts/cvt_fallthrough.pl block
> > > converts all files in block and its subdirectories
> > > $ ./scripts/cvt_fallthrough.pl drivers/net/wireless/zydas/zd1201.c
> > > converts a single file
> > >
> > > A fallthrough comment with additional comments is converted akin to:
> > >
> > > - /* fall through - maybe userspace knows this conn_id. */
> > > + fallthrough; /* maybe userspace knows this conn_id */
> > >
> > > A fallthrough comment or fallthrough; between successive case statements
> > > is deleted.
> > >
> > > e.g.:
> > >
> > > case FOO:
> > > /* fallthrough */ (or fallthrough;)
> > > case BAR:
> > >
> > > is converted to:
> > >
> > > case FOO:
> > > case BAR:
> > >
> > > Signed-off-by: Joe Perches <joe@perches.com>
> > > ---
> > > scripts/cvt_fallthrough.pl | 215 +++++++++++++++++++++++++++++++++++++
> >
> > Do we need this in the tree long-term? Or is it a matters of "hey
> > Linus, please run this" then something like add a checkpatch rule to
> > catch future slipups?
>
> Just for some added context, please see
> https://reviews.llvm.org/D73852, where support for parsing some forms
> of fallthrough statements was added to Clang in a broken state by a
> contributor, but then ripped out by the code owner (of the clang front
> end to LLVM, and also happens to be the C++ ISO spec editor). He
> provides further clarification
> https://bugs.llvm.org/show_bug.cgi?id=43465#c37.
>
> I'm inclined to agree with him; to implement this, we need to keep
> around comments for semantic analyses, a later phase of compilation
> than preprocessing. It feels like a layering violation to either not
> discard comments as soon as possible, or emit diagnostics from the
> preprocessor. And as Joe's data shows, there's the classic issue
> faced when using regexes to solve a problem; suddenly you now have two
> problems.
> https://xkcd.com/1171/
>
> I would like to see this patch landed, though I am curious as toward's
> Andrew's question ('Or is it a matters of "hey Linus, please run
> this"') of what's the imagined workflow here, since it seems like the
> script needs to be run per file. I suppose you could still do that
> treewide, but is that the intention, or is it to do so on a per
> subsystem level?
A single treewide run of a script like this really could make
it quite hard to later backport various fixes to stable trees.
A depth-first per-maintained subsystem run of the script with
commits could be useful and would much more easily allow backports.
Unfortunately there's no tool to apply such a script to the tree
per subsystem as far as I know.
Such a depth-first apply and commit tool could really be quite
useful though.
next prev parent reply other threads:[~2020-03-09 19:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 20:30 [PATCH] cvt_fallthrough: A tool to convert /* fallthrough */ comments to fallthrough; Joe Perches
2020-02-21 0:21 ` Andrew Morton
2020-02-21 2:24 ` Joe Perches
2020-03-09 19:36 ` Nick Desaulniers
2020-03-09 19:55 ` Joe Perches [this message]
2020-03-07 21:30 ` Gustavo A. R. Silva
2020-03-08 3:01 ` Joe Perches
2020-03-08 6:46 ` Gustavo A. R. Silva
2020-03-08 7:02 ` Joe Perches
2020-03-08 7:11 ` Gustavo A. R. Silva
2020-03-08 8:58 ` Joe Perches
2020-03-08 19:14 ` Gustavo A. R. Silva
2020-03-08 19:44 ` Joe Perches
2020-03-08 22:04 ` Gustavo A. R. Silva
2020-03-08 22:05 ` Joe Perches
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=e8db6d1a92001b02bbe2c2a1fc3413e1d44aa0a4.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=clang-built-linux@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ndesaulniers@google.com \
/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 NNTP newsgroup(s).