[llvm-commits] [llvm] r141313 - /llvm/trunk/lib/VMCore/Core.cpp

David Blaikie dblaikie at gmail.com
Thu Oct 6 20:52:08 PDT 2011


On Thu, Oct 6, 2011 at 8:47 PM, Matt Beaumont-Gay <matthewbg at google.com>wrote:

> On Thu, Oct 6, 2011 at 20:25, David Blaikie <dblaikie at gmail.com> wrote:
> >> @@ -666,6 +666,7 @@
> >>        default:
> >>            assert(false && "Unhandled Opcode.");
> >>     }
> >> +    return static_cast<LLVMOpcode>(0);
> >
> > If you used llvm_unreachable instead of assert(false) in that default
> case,
> > then you should be able to go without the (effectively unreachable)
> return
> > here.
> >
> > And/or you could skip the default entirely if your switch covers all the
> > values of the enum - I sent out a CR to remove all these unnecessary
> default
> > cases (in both clang & llvm) a while back but I'm not sure anyone said
> 'yae'
> > or 'nae' to it.
>
> I have no strong feelings on this matter. If there is a preferred
> style, it should be documented on the Coding Standards page.


Indeed - it (requesting people remove default cases on switches that cover
all enumeration values) seems to come up as fairly common CR feedback, at
least on cfe-commits but I haven't seen a clear statement in the coding
standards.

I'll see about getting some discussion towards formalizing the approach on
llvm-dev or the like.

- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111006/f652a97f/attachment.html>


More information about the llvm-commits mailing list