diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2014-05-13 12:52:35 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2014-05-13 12:52:35 +0000 |
commit | b37b01d95c9d3358bbae9ee69c6ab0053c989135 (patch) | |
tree | 024627f7fd6260e99e30e67ae25709d1427667b9 /utils | |
parent | 3beea23c1b9a4b9023fe06b4524680b7b8b9ff83 (diff) |
Teach the table generator to not generate switch statements containing only a default label with no cases. This solves some warnings with MSVC.
No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208694 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/AsmWriterEmitter.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp index 7165effa863..57889ca7542 100644 --- a/utils/TableGen/AsmWriterEmitter.cpp +++ b/utils/TableGen/AsmWriterEmitter.cpp @@ -1008,20 +1008,23 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { O << "void " << Target.getName() << ClassName << "::" << "printCustomAliasOperand(\n" << " const MCInst *MI, unsigned OpIdx,\n" - << " unsigned PrintMethodIdx, raw_ostream &OS) {\n" - << " switch (PrintMethodIdx) {\n" - << " default:\n" - << " llvm_unreachable(\"Unknown PrintMethod kind\");\n" - << " break;\n"; - - for (unsigned i = 0; i < PrintMethods.size(); ++i) { - O << " case " << i << ":\n" - << " " << PrintMethods[i] << "(MI, OpIdx, OS);\n" + << " unsigned PrintMethodIdx, raw_ostream &OS) {\n"; + if (PrintMethods.empty()) + O << " llvm_unreachable(\"Unknown PrintMethod kind\");\n"; + else { + O << " switch (PrintMethodIdx) {\n" + << " default:\n" + << " llvm_unreachable(\"Unknown PrintMethod kind\");\n" << " break;\n"; - } - O << " }\n" - << "}\n\n"; + for (unsigned i = 0; i < PrintMethods.size(); ++i) { + O << " case " << i << ":\n" + << " " << PrintMethods[i] << "(MI, OpIdx, OS);\n" + << " break;\n"; + } + O << " }\n"; + } + O << "}\n\n"; O << "#endif // PRINT_ALIAS_INSTR\n"; } |