[PATCH] D46304: [MC] Add llvm_unreachable to toString to fix compile time warning.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 7 16:05:26 PDT 2018


dblaikie added a comment.

In https://reviews.llvm.org/D46304#1084947, @GBuella wrote:

> In https://reviews.llvm.org/D46304#1083824, @fhahn wrote:
>
> > In https://reviews.llvm.org/D46304#1083822, @andreadb wrote:
> >
> > > I just saw that Gabor fixed it at revision 331251 adding a 'default' case.
> > >  http://llvm.org/viewvc/llvm-project?view=revision&revision=331251
> >
> >
> > Ah thanks for pointing me to that :) @GBuella I think one minor drawback of adding a default cast is that we won't get compiler warning for missing cases, but then when WasmSymbolType is not an enum class, you probably won't get them anyways.
>
>
> Thanks for the fix!
>  Yes, since enum is defined as "enum WasmSymbolType : unsigned { ... }", the enumeration values are [0 ... UINT_MAX], as ISO says:
>  "For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type."
>
> So the wording of this warning is definitely wrong (unless there would be cases for 2^32 enumeration values):
>
>   llvm/lib/MC/WasmObjectWriter.cpp:50:3: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
>     default:
>     ^
>


Hey there - I implemented this diagnostic many a year ago. Yeah, technically maybe "covers all enumerators" might be more accurate phrasing?


Repository:
  rL LLVM

https://reviews.llvm.org/D46304





More information about the llvm-commits mailing list