[PATCH] Improving LowerSwitch behavior for contiguous ranges
Joerg Sonnenberger
joerg at britannica.bec.de
Wed Jun 11 06:18:50 PDT 2014
On Wed, Jun 11, 2014 at 02:05:23AM +0100, Marcello Maggioni wrote:
> Hello Joerg,
>
> by unreachable default you mean something like this?
>
> int foo(int a) {
> switch (a) {
> case 0:
> return 10;
> case 1:
> return 20;
> case 2:
> return 2;
> case 8:
> return 3;
> case 9:
> return 4;
> case 10:
> return 5;
> default:
> abort();
> }
> }
More like explicit __builtin_unreachable(), since abort() still has side
effects. Practical use case is switching over an enum.
Joerg
More information about the llvm-commits
mailing list