[llvm] r208694 - Teach the table generator to not generate switch statements containing only a default label with no cases. This solves some warnings with MSVC.
Aaron Ballman
aaron at aaronballman.com
Tue May 13 05:52:36 PDT 2014
Author: aaronballman
Date: Tue May 13 07:52:35 2014
New Revision: 208694
URL: http://llvm.org/viewvc/llvm-project?rev=208694&view=rev
Log:
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.
Modified:
llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=208694&r1=208693&r2=208694&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Tue May 13 07:52:35 2014
@@ -1008,20 +1008,23 @@ void AsmWriterEmitter::EmitPrintAliasIns
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";
}
More information about the llvm-commits
mailing list