1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[AsmParser] Suppress compile warning for targets with no register diags

This fixes the "switch statement contains 'default' but no 'case' labels"
warnings in table-generated code introduced in r315295.

llvm-svn: 315571
This commit is contained in:
Oliver Stannard 2017-10-12 09:28:23 +00:00
parent bbced01275
commit 1e4e2341bd

View File

@ -2256,20 +2256,26 @@ static void emitOperandMatchErrorDiagStrings(AsmMatcherInfo &Info, raw_ostream &
static void emitRegisterMatchErrorFunc(AsmMatcherInfo &Info, raw_ostream &OS) {
OS << "static unsigned getDiagKindFromRegisterClass(MatchClassKind "
"RegisterClass) {\n";
OS << " switch (RegisterClass) {\n";
for (const auto &CI: Info.Classes) {
if (CI.isRegisterClass() && !CI.DiagnosticType.empty()) {
OS << " case " << CI.Name << ":\n";
OS << " return " << Info.Target.getName() << "AsmParser::Match_"
<< CI.DiagnosticType << ";\n";
if (std::none_of(Info.Classes.begin(), Info.Classes.end(),
[](const ClassInfo &CI) {
return CI.isRegisterClass() && !CI.DiagnosticType.empty();
})) {
OS << " return MCTargetAsmParser::Match_InvalidOperand;\n";
} else {
OS << " switch (RegisterClass) {\n";
for (const auto &CI: Info.Classes) {
if (CI.isRegisterClass() && !CI.DiagnosticType.empty()) {
OS << " case " << CI.Name << ":\n";
OS << " return " << Info.Target.getName() << "AsmParser::Match_"
<< CI.DiagnosticType << ";\n";
}
}
OS << " default:\n";
OS << " return MCTargetAsmParser::Match_InvalidOperand;\n";
OS << " }\n";
}
OS << " default:\n";
OS << " return MCTargetAsmParser::Match_InvalidOperand;\n";
OS << " }\n";
OS << "}\n\n";
}