[cfe-commits] [PATCH] Minor improvement for -Wimplicit-fallthrough

Alexander Kornienko alexfh at google.com
Fri May 25 16:40:24 PDT 2012


Hi Chandler,

On Fri, May 25, 2012 at 11:15 PM, Chandler Carruth <chandlerc at google.com>wrote:

> On Fri, May 25, 2012 at 11:15 AM, Alexander Kornienko <alexfh at google.com>wrote:
>
>> Hi cfe-commits,
>>
>> This patch handles a specific (but surprisingly common) case when a
>> fall-through occurs to a switch label immediately followed by a break;.
>> In this case it doesn't make sense to suggest a fall-through annotation,
>> almost certainly inserting break; is a good fix-it.
>> Example:
>>
>> switch (x) {
>>   case 111:
>>     f();
>>   case 222: // don't offer "[[clang::fallthrough]];", just "break;"
>>     break;
>> }
>>
>> Please, review this patch.
>>
>
> Seems generally good. I think we have 'isa_or_null' which would simplify
> the code implementing it a bit i think? Maybe I've mis-remembered.
>
Nope:

// This file defines the isa<X>(), cast<X>(), dyn_cast<X>(),
cast_or_null<X>(),// and dyn_cast_or_null<X>() templates.


I could use dyn_cast_or_null, but it will not make code clearer.

If it looks good, could you commit it? I don't have commit access yet.

-- 
Regards,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120526/5b88151e/attachment.html>


More information about the cfe-commits mailing list