On Wed, Aug 21, 2013 at 6:54 AM, Aaron Ballman <[email protected]>wrote:
> On Tue, Aug 20, 2013 at 7:16 PM, Christian Wailes > <[email protected]> wrote: > >> > + > >> > + if (!FunDecl->hasAttr<CallableWhenUnconsumedAttr>()) return; > >> > + > >> > + if (PState.IsVar) { > >> > + const VarDecl *Var = PState.getVar(); > >> > + > >> > + switch (StateMap->getState(Var)) { > >> > + case CS_Consumed: > >> > + Analyzer.WarningsHandler.warnUseWhileConsumed( > >> > + FunDecl->getNameAsString(), Var->getNameAsString(), > >> > + Call->getExprLoc()); > >> > + break; > >> > + > >> > + case CS_Unknown: > >> > + Analyzer.WarningsHandler.warnUseInUnknownState( > >> > + FunDecl->getNameAsString(), Var->getNameAsString(), > >> > + Call->getExprLoc()); > >> > + break; > >> > + > >> > + default: > >> > + break; > >> > >> Should the default be unreachable? > >> > > > > No, there are other cases besides Consumed and Unknown. I just don't > want > > to do anything for those cases. > > I worry that this will cause extra warnings in some of the build bots > because the other enumerants are not covered in the switch statement. > The same is true elsewhere. It is a bit of a clang coding convention to use fully-covered switches with no default. That way, when someone adds an enum value, the compiler will warn on all of the switches missing cases. We shouldn't get warnings for a partially covered switch with a default (like this one), although we will for fully covered switches with a default. There are only two enums vs one default, so I'd cover the switch to leverage the warning.
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
