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

Gabor Buella via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 2 01:01:49 PDT 2018


GBuella added a comment.

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 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:
    ^


Repository:
  rL LLVM

https://reviews.llvm.org/D46304





More information about the llvm-commits mailing list