forked from OSchip/llvm-project
[Sema] Factor diags with %plural. No functionality change intended.
llvm-svn: 233387
This commit is contained in:
parent
45523ffd07
commit
3a8650af77
|
@ -3801,34 +3801,14 @@ def note_template_parameter_pack_here : Note<
|
|||
"previous %select{template type|non-type template|template template}0 "
|
||||
"parameter%select{| pack}1 declared here">;
|
||||
|
||||
def err_unexpanded_parameter_pack_0 : Error<
|
||||
def err_unexpanded_parameter_pack : Error<
|
||||
"%select{expression|base type|declaration type|data member type|bit-field "
|
||||
"size|static assertion|fixed underlying type|enumerator value|"
|
||||
"using declaration|friend declaration|qualifier|initializer|default argument|"
|
||||
"non-type template parameter type|exception type|partial specialization|"
|
||||
"__if_exists name|__if_not_exists name|lambda|block}0 "
|
||||
"contains an unexpanded parameter pack">;
|
||||
def err_unexpanded_parameter_pack_1 : Error<
|
||||
"%select{expression|base type|declaration type|data member type|bit-field "
|
||||
"size|static assertion|fixed underlying type|enumerator value|"
|
||||
"using declaration|friend declaration|qualifier|initializer|default argument|"
|
||||
"non-type template parameter type|exception type|partial specialization|"
|
||||
"__if_exists name|__if_not_exists name|lambda|block}0 "
|
||||
"contains unexpanded parameter pack %1">;
|
||||
def err_unexpanded_parameter_pack_2 : Error<
|
||||
"%select{expression|base type|declaration type|data member type|bit-field "
|
||||
"size|static assertion|fixed underlying type|enumerator value|"
|
||||
"using declaration|friend declaration|qualifier|initializer|default argument|"
|
||||
"non-type template parameter type|exception type|partial specialization|"
|
||||
"__if_exists name|__if_not_exists name|lambda|block}0 "
|
||||
"contains unexpanded parameter packs %1 and %2">;
|
||||
def err_unexpanded_parameter_pack_3_or_more : Error<
|
||||
"%select{expression|base type|declaration type|data member type|bit-field "
|
||||
"size|static assertion|fixed underlying type|enumerator value|"
|
||||
"using declaration|friend declaration|qualifier|initializer|default argument|"
|
||||
"non-type template parameter type|exception type|partial specialization|"
|
||||
"__if_exists name|__if_not_exists name|lambda|block}0 "
|
||||
"contains unexpanded parameter packs %1, %2, ...">;
|
||||
"__if_exists name|__if_not_exists name|lambda|block}0 contains"
|
||||
"%plural{0: an|:}1 unexpanded parameter pack"
|
||||
"%plural{0:|1: %2|2:s %2 and %3|:s %2, %3, ...}1">;
|
||||
|
||||
def err_pack_expansion_without_parameter_packs : Error<
|
||||
"pack expansion does not contain any unexpanded parameter packs">;
|
||||
|
@ -6878,29 +6858,18 @@ def warn_case_empty_range : Warning<"empty case range specified">;
|
|||
def warn_missing_case_for_condition :
|
||||
Warning<"no case matching constant switch condition '%0'">;
|
||||
|
||||
def warn_def_missing_case1 : Warning<
|
||||
"enumeration value %0 not explicitly handled in switch">,
|
||||
InGroup<SwitchEnum>, DefaultIgnore;
|
||||
def warn_def_missing_case2 : Warning<
|
||||
"enumeration values %0 and %1 not explicitly handled in switch">,
|
||||
InGroup<SwitchEnum>, DefaultIgnore;
|
||||
def warn_def_missing_case3 : Warning<
|
||||
"enumeration values %0, %1, and %2 not explicitly handled in switch">,
|
||||
InGroup<SwitchEnum>, DefaultIgnore;
|
||||
def warn_def_missing_cases : Warning<
|
||||
"%0 enumeration values not explicitly handled in switch: %1, %2, %3...">,
|
||||
def warn_def_missing_case : Warning<"%plural{"
|
||||
"1:enumeration value %1 not explicitly handled in switch|"
|
||||
"2:enumeration values %1 and %2 not explicitly handled in switch|"
|
||||
"3:enumeration values %1, %2, and %3 not explicitly handled in switch|"
|
||||
":%0 enumeration values not explicitly handled in switch: %1, %2, %3...}0">,
|
||||
InGroup<SwitchEnum>, DefaultIgnore;
|
||||
|
||||
def warn_missing_case1 : Warning<"enumeration value %0 not handled in switch">,
|
||||
InGroup<Switch>;
|
||||
def warn_missing_case2 : Warning<
|
||||
"enumeration values %0 and %1 not handled in switch">,
|
||||
InGroup<Switch>;
|
||||
def warn_missing_case3 : Warning<
|
||||
"enumeration values %0, %1, and %2 not handled in switch">,
|
||||
InGroup<Switch>;
|
||||
def warn_missing_cases : Warning<
|
||||
"%0 enumeration values not handled in switch: %1, %2, %3...">,
|
||||
def warn_missing_case : Warning<"%plural{"
|
||||
"1:enumeration value %1 not handled in switch|"
|
||||
"2:enumeration values %1 and %2 not handled in switch|"
|
||||
"3:enumeration values %1, %2, and %3 not handled in switch|"
|
||||
":%0 enumeration values not handled in switch: %1, %2, %3...}0">,
|
||||
InGroup<Switch>;
|
||||
|
||||
def warn_unannotated_fallthrough : Warning<
|
||||
|
|
|
@ -1133,29 +1133,15 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
|
|||
Diag(TheDefaultStmt->getDefaultLoc(), diag::warn_unreachable_default);
|
||||
|
||||
// Produce a nice diagnostic if multiple values aren't handled.
|
||||
switch (UnhandledNames.size()) {
|
||||
case 0: break;
|
||||
case 1:
|
||||
Diag(CondExpr->getExprLoc(), TheDefaultStmt
|
||||
? diag::warn_def_missing_case1 : diag::warn_missing_case1)
|
||||
<< UnhandledNames[0];
|
||||
break;
|
||||
case 2:
|
||||
Diag(CondExpr->getExprLoc(), TheDefaultStmt
|
||||
? diag::warn_def_missing_case2 : diag::warn_missing_case2)
|
||||
<< UnhandledNames[0] << UnhandledNames[1];
|
||||
break;
|
||||
case 3:
|
||||
Diag(CondExpr->getExprLoc(), TheDefaultStmt
|
||||
? diag::warn_def_missing_case3 : diag::warn_missing_case3)
|
||||
<< UnhandledNames[0] << UnhandledNames[1] << UnhandledNames[2];
|
||||
break;
|
||||
default:
|
||||
Diag(CondExpr->getExprLoc(), TheDefaultStmt
|
||||
? diag::warn_def_missing_cases : diag::warn_missing_cases)
|
||||
<< (unsigned)UnhandledNames.size()
|
||||
<< UnhandledNames[0] << UnhandledNames[1] << UnhandledNames[2];
|
||||
break;
|
||||
if (!UnhandledNames.empty()) {
|
||||
DiagnosticBuilder DB = Diag(CondExpr->getExprLoc(),
|
||||
TheDefaultStmt ? diag::warn_def_missing_case
|
||||
: diag::warn_missing_case)
|
||||
<< (int)UnhandledNames.size();
|
||||
|
||||
for (size_t I = 0, E = std::min(UnhandledNames.size(), (size_t)3);
|
||||
I != E; ++I)
|
||||
DB << UnhandledNames[I];
|
||||
}
|
||||
|
||||
if (!hasCasesNotInSwitch)
|
||||
|
|
|
@ -251,15 +251,10 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
|
|||
Locations.push_back(Unexpanded[I].second);
|
||||
}
|
||||
|
||||
DiagnosticBuilder DB
|
||||
= Names.size() == 0? Diag(Loc, diag::err_unexpanded_parameter_pack_0)
|
||||
<< (int)UPPC
|
||||
: Names.size() == 1? Diag(Loc, diag::err_unexpanded_parameter_pack_1)
|
||||
<< (int)UPPC << Names[0]
|
||||
: Names.size() == 2? Diag(Loc, diag::err_unexpanded_parameter_pack_2)
|
||||
<< (int)UPPC << Names[0] << Names[1]
|
||||
: Diag(Loc, diag::err_unexpanded_parameter_pack_3_or_more)
|
||||
<< (int)UPPC << Names[0] << Names[1];
|
||||
DiagnosticBuilder DB = Diag(Loc, diag::err_unexpanded_parameter_pack)
|
||||
<< (int)UPPC << (int)Names.size();
|
||||
for (size_t I = 0, E = std::min(Names.size(), (size_t)2); I != E; ++I)
|
||||
DB << Names[I];
|
||||
|
||||
for (unsigned I = 0, N = Locations.size(); I != N; ++I)
|
||||
DB << SourceRange(Locations[I]);
|
||||
|
|
Loading…
Reference in New Issue