[llvm] r297990 - Silence -Wcovered-switch-default warning.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 20 09:32:12 PDT 2017


Would it be OK/better to read it as an integer and switch over that rather
than reading as an enum and casting back to int? Or are there other
features of the parsing library that favor reading as an enum?

On Thu, Mar 16, 2017 at 1:57 PM Zachary Turner via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: zturner
> Date: Thu Mar 16 15:45:11 2017
> New Revision: 297990
>
> URL: http://llvm.org/viewvc/llvm-project?rev=297990&view=rev
> Log:
> Silence -Wcovered-switch-default warning.
>
> Modified:
>     llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp?rev=297990&r1=297989&r2=297990&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp Thu Mar 16 15:45:11
> 2017
> @@ -62,18 +62,22 @@ Error InfoStream::reload() {
>      PdbRaw_FeatureSig Sig;
>      if (auto EC = Reader.readEnum(Sig))
>        return EC;
> -    switch (Sig) {
> -    case PdbRaw_FeatureSig::VC110:
> +    // Since this value comes from a file, it's possible we have some
> strange
> +    // value which doesn't correspond to any value.  We don't want to
> warn on
> +    // -Wcovered-switch-default in this case, so switch on the integral
> value
> +    // instead of the enumeration value.
> +    switch (uint32_t(Sig)) {
> +    case uint32_t(PdbRaw_FeatureSig::VC110):
>        // No other flags for VC110 PDB.
>        Stop = true;
>        LLVM_FALLTHROUGH;
> -    case PdbRaw_FeatureSig::VC140:
> +    case uint32_t(PdbRaw_FeatureSig::VC140):
>        Features |= PdbFeatureContainsIdStream;
>        break;
> -    case PdbRaw_FeatureSig::NoTypeMerge:
> +    case uint32_t(PdbRaw_FeatureSig::NoTypeMerge):
>        Features |= PdbFeatureNoTypeMerging;
>        break;
> -    case PdbRaw_FeatureSig::MinimalDebugInfo:
> +    case uint32_t(PdbRaw_FeatureSig::MinimalDebugInfo):
>        Features |= PdbFeatureMinimalDebugInfo;
>      default:
>        continue;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170320/c6277d88/attachment.html>


More information about the llvm-commits mailing list