This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Don't emit -Wunguarded-availability for switch cases
ClosedPublic

Authored by erik.pilkington on Aug 15 2017, 5:19 PM.

Details

Summary

Currently, this has pretty terrible ergonomics for the fairly common case of switching over an enum which has some entries that are partial. Thanks to Nico Weber for pointing this out!

Thanks,
Erik

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman edited edge metadata.Aug 17 2017, 4:16 AM

Thanks! There are two issues that I see:

lib/Sema/SemaDeclAttr.cpp
7519 ↗(On Diff #111288)

GNU case statements can also have a RHS expression in a range. You should avoid using children completely and just traverse the sub stmt instead.

7520 ↗(On Diff #111288)

You should call TraverseStmt instead because we have special logic for tracking the statement stack for a fixit. We can produce an incorrect multi-statement fixit if the case's sub statement is a compound statement when we call Base::TraverseStmt.

Ah, good point. This new patch does that.
Thanks,
Erik

This revision is now accepted and ready to land.Aug 18 2017, 3:17 AM
This revision was automatically updated to reflect the committed changes.