[llvm] r310356 - Appease compilers that have the -Wcovered-switch-default switch.

Alex L via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 8 06:54:50 PDT 2017


On 8 August 2017 at 13:41, Nemanja Ivanovic via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: nemanjai
> Date: Tue Aug  8 05:41:56 2017
> New Revision: 310356
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310356&view=rev
> Log:
> Appease compilers that have the -Wcovered-switch-default switch.
>
>
> Modified:
>     llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
> PowerPC/PPCISelDAGToDAG.cpp?rev=310356&r1=310355&r2=310356&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Tue Aug  8 05:41:56
> 2017
> @@ -2814,7 +2814,6 @@ SDValue PPCDAGToDAGISel::getCompoundZero
>
>    // Produce the value that needs to be either zero or sign extended.
>    switch (CmpTy) {
> -  default: llvm_unreachable("Unknown Zero-comparison type.");
>    case ZeroCompare::GEZExt:
>    case ZeroCompare::GESExt:
>      ToExtend = SDValue(CurDAG->getMachineNode(Is32Bit ? PPC::NOR :
> PPC::NOR8,
> @@ -2850,7 +2849,6 @@ SDValue PPCDAGToDAGISel::getCompoundZero
>    assert(Is32Bit && "Should have handled the 32-bit sequences above.");
>    // For 32-bit sequences, the extensions differ between GE/LE cases.
>    switch (CmpTy) {
> -  default: llvm_unreachable("Unknown Zero-comparison type.");
>    case ZeroCompare::GEZExt: {
>      SDValue ShiftOps[] =
>        { ToExtend, getI32Imm(1, dl), getI32Imm(31, dl), getI32Imm(31, dl)
> };
> @@ -2867,6 +2865,11 @@ SDValue PPCDAGToDAGISel::getCompoundZero
>      return SDValue(CurDAG->getMachineNode(PPC::ADDI, dl, MVT::i32,
> ToExtend,
>                                            getI32Imm(-1, dl)), 0);
>    }
> +
> +  // Some compilers warn if there's a default label in the switch above,
> others
> +  // warn if there isn't a return statement here or in a default label.
> Appease
> +  // both (even though this is unreachable).
> +  return SDValue();
>

You can just use `llvm_unreachable` here instead of the return.


>  }
>
>  /// Produces a zero-extended result of comparing two 32-bit values
> according to
>
>
> _______________________________________________
> 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/20170808/68dd9755/attachment.html>


More information about the llvm-commits mailing list