Does the clang version we use for all the spiffy warnings support
-Wimplicit-fallthrough ?
I see firefox has a MOZ_FALLTHROUGH macro that expands
to [[clang::fallthrough]] for clang and just plain /*fall-through*/ for
everything else.
If we had support for something like that, and could rewrite all our
current /*fall-through*/ and //FALL_THROUGH etc comments to that macro,
then perhaps we could enable this warning by default and we wouldn't
see as many of these missing breaks getting missed until the next
coverity run as I've been seeing over the last few weeks.
On that topic, while I don't want to start a style war, some
consistency in switch/case/break+brace layout would, I suspect, be
helpful. I'm a fan of an indent after switch and after case, and break
aligned to the body of case. With any scoping braces required for a
case encompassing the final break
switch (foo)
{
case bar:
things...
break;
case baz:
{
things...
break;
}
}
(which is the same as the mozilla guidelines https://developer.mozilla.
org/en-US/docs/Mozilla/Developer_guide/Coding_Style)
this is the other sane pattern we generally use, which I could live
with. Though I think we should use one or the other consistently.
switch (foo)
{
case bar:
things...
break;
case baz:
{
things...
}
break;
}
While this I find particularly painful and common when switch
statements end up multipage long with switches inside switches
switch (foo)
{
case bar:
break;
case baz:
{
things...
}
break;
case qux:
things...
break;
case tay:
{
things...
}
break;
}
Context
- clang -Wimplicit-fallthrough and missing breaks · Caolán McNamara
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.