[llvm] r312834 - [TargetTransformInfo] Remove the extra "default" in a switch that all enum values has been covered.

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 10 11:17:05 PDT 2017


The recommended pattern is to put the llvm_unreachable after the switch:

https://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations

-- Sean Silva

On Fri, Sep 8, 2017 at 4:34 PM, Guozhi Wei via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: carrot
> Date: Fri Sep  8 16:34:28 2017
> New Revision: 312834
>
> URL: http://llvm.org/viewvc/llvm-project?rev=312834&view=rev
> Log:
> [TargetTransformInfo] Remove the extra "default" in a switch that all enum
> values has been covered.
>
> In function TargetTransformInfo::getInstructionCost, all enum values in
> the switch statement has been covered, so the default is unnecessary, and
> may cause error with option -Werror,-Wcovered-switch-default, so remove
> it.
>
>
> Modified:
>     llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h
>
> Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/
> TargetTransformInfo.h?rev=312834&r1=312833&r2=312834&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h (original)
> +++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h Fri Sep  8
> 16:34:28 2017
> @@ -141,11 +141,9 @@ public:
>
>      case TCK_CodeSize:
>        return getUserCost(I);
> -
> -    default:
> -      llvm_unreachable("Unknown instruction cost kind");
> -      return 0;
>      }
> +
> +    return 0;
>    }
>
>    /// \brief Underlying constants for 'cost' values in this interface.
>
>
> _______________________________________________
> 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/20170910/5e5a4ef9/attachment.html>


More information about the llvm-commits mailing list