forked from OSchip/llvm-project
parent
6f35f5cf5d
commit
02627a22cf
|
@ -728,34 +728,34 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
|
||||||
// TODO: we might want to check whether case values are out of the
|
// TODO: we might want to check whether case values are out of the
|
||||||
// enum even if we don't want to check whether all cases are handled.
|
// enum even if we don't want to check whether all cases are handled.
|
||||||
if (!TheDefaultStmt) {
|
if (!TheDefaultStmt) {
|
||||||
EnumValsTy::const_iterator EI = EnumVals.begin();
|
EnumValsTy::const_iterator EI = EnumVals.begin();
|
||||||
for (CaseValsTy::const_iterator CI = CaseVals.begin();
|
for (CaseValsTy::const_iterator CI = CaseVals.begin();
|
||||||
CI != CaseVals.end(); CI++) {
|
CI != CaseVals.end(); CI++) {
|
||||||
while (EI != EIend && EI->first < CI->first)
|
while (EI != EIend && EI->first < CI->first)
|
||||||
EI++;
|
EI++;
|
||||||
if (EI == EIend || EI->first > CI->first)
|
if (EI == EIend || EI->first > CI->first)
|
||||||
Diag(CI->second->getLHS()->getExprLoc(), diag::warn_not_in_enum)
|
Diag(CI->second->getLHS()->getExprLoc(), diag::warn_not_in_enum)
|
||||||
<< ED->getDeclName();
|
<< ED->getDeclName();
|
||||||
}
|
}
|
||||||
// See which of case ranges aren't in enum
|
// See which of case ranges aren't in enum
|
||||||
EI = EnumVals.begin();
|
EI = EnumVals.begin();
|
||||||
for (CaseRangesTy::const_iterator RI = CaseRanges.begin();
|
for (CaseRangesTy::const_iterator RI = CaseRanges.begin();
|
||||||
RI != CaseRanges.end() && EI != EIend; RI++) {
|
RI != CaseRanges.end() && EI != EIend; RI++) {
|
||||||
while (EI != EIend && EI->first < RI->first)
|
while (EI != EIend && EI->first < RI->first)
|
||||||
EI++;
|
EI++;
|
||||||
|
|
||||||
if (EI == EIend || EI->first != RI->first) {
|
if (EI == EIend || EI->first != RI->first) {
|
||||||
Diag(RI->second->getLHS()->getExprLoc(), diag::warn_not_in_enum)
|
Diag(RI->second->getLHS()->getExprLoc(), diag::warn_not_in_enum)
|
||||||
<< ED->getDeclName();
|
<< ED->getDeclName();
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::APSInt Hi = RI->second->getRHS()->EvaluateAsInt(Context);
|
llvm::APSInt Hi = RI->second->getRHS()->EvaluateAsInt(Context);
|
||||||
while (EI != EIend && EI->first < Hi)
|
while (EI != EIend && EI->first < Hi)
|
||||||
EI++;
|
EI++;
|
||||||
if (EI == EIend || EI->first != Hi)
|
if (EI == EIend || EI->first != Hi)
|
||||||
Diag(RI->second->getRHS()->getExprLoc(), diag::warn_not_in_enum)
|
Diag(RI->second->getRHS()->getExprLoc(), diag::warn_not_in_enum)
|
||||||
<< ED->getDeclName();
|
<< ED->getDeclName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check which enum vals aren't in switch
|
// Check which enum vals aren't in switch
|
||||||
CaseValsTy::const_iterator CI = CaseVals.begin();
|
CaseValsTy::const_iterator CI = CaseVals.begin();
|
||||||
|
@ -779,15 +779,15 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RI == CaseRanges.end() || EI->first < RI->first) {
|
if (RI == CaseRanges.end() || EI->first < RI->first) {
|
||||||
hasCasesNotInSwitch = true;
|
hasCasesNotInSwitch = true;
|
||||||
if (!TheDefaultStmt)
|
if (!TheDefaultStmt)
|
||||||
Diag(CondExpr->getExprLoc(), diag::warn_missing_cases)
|
Diag(CondExpr->getExprLoc(), diag::warn_missing_cases)
|
||||||
<< EI->second->getDeclName();
|
<< EI->second->getDeclName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasCasesNotInSwitch)
|
if (!hasCasesNotInSwitch)
|
||||||
SS->setAllEnumCasesCovered();
|
SS->setAllEnumCasesCovered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue