[llvm] r295799 - Fix -Wcovered-switch-default.

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 01:43:54 PST 2017


On Wed, Feb 22, 2017 at 8:42 AM, David Blaikie <dblaikie at gmail.com> wrote:

> The unreachable outside a switch is usually in the case of a fully covered
> switch to address the way that other compilers conservatively assume that a
> covered switch may still be skipped (due to values that are not
> enumerators, but in the representable range of the enumeration). In this
> case, of a switch with a  default (not fully covered), unreachable in the
> default is OK/good I think.
>

But then you don't get Clang's warning which assumes that the intent is to
cover all enumerators, so you don't get the reminder to update this
location if you add one.

-- Sean Silva


>
> On Tue, Feb 21, 2017 at 11:01 PM Sean Silva via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Usually we put the unreachable outside the switch:
>>
>> http://llvm.org/docs/CodingStandards.html#don-t-
>> use-default-labels-in-fully-covered-switches-over-enumerations
>>
>> On Tue, Feb 21, 2017 at 5:01 PM, Rui Ueyama via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>> Author: ruiu
>> Date: Tue Feb 21 19:01:45 2017
>> New Revision: 295799
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295799&view=rev
>> Log:
>> Fix -Wcovered-switch-default.
>>
>> Modified:
>>     llvm/trunk/lib/Object/ArchiveWriter.cpp
>>
>> Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/
>> ArchiveWriter.cpp?rev=295799&r1=295798&r2=295799&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
>> +++ llvm/trunk/lib/Object/ArchiveWriter.cpp Tue Feb 21 19:01:45 2017
>> @@ -129,9 +129,7 @@ static bool isBSDLike(object::Archive::K
>>    case object::Archive::K_BSD:
>>    case object::Archive::K_DARWIN:
>>      return true;
>> -  case object::Archive::K_MIPS64:
>> -  case object::Archive::K_DARWIN64:
>> -  case object::Archive::K_COFF:
>> +  default:
>>      llvm_unreachable("not supported for writting");
>>    }
>>  }
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>>
>> _______________________________________________
>> 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/20170223/5cccb584/attachment.html>


More information about the llvm-commits mailing list