20 const auto *Switch = Result.Nodes.getNodeAs<SwitchStmt>(
"switch");
21 std::size_t CaseCount = 0;
22 bool HasDefault =
false;
24 for (
const SwitchCase *CurrentCase = Switch->getSwitchCaseList(); CurrentCase;
25 CurrentCase = CurrentCase->getNextSwitchCase()) {
27 if (isa<DefaultStmt>(CurrentCase))
32 switch (
const SourceLocation Loc = Switch->getBeginLoc(); CaseCount) {
34 diag(Loc,
"switch statement without labels has no effect");
38 diag(Loc,
"switch with default label only");
40 diag(Loc,
"switch with only one case; use an if statement");
44 diag(Loc,
"switch could be better written as an if-else statement");