[llvm] r321217 - Do not generate an empty switch statement as it causes MSVC to issue diagnostics about switch statements without case or default labels.
Aaron Ballman via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 20 12:09:30 PST 2017
Author: aaronballman
Date: Wed Dec 20 12:09:30 2017
New Revision: 321217
URL: http://llvm.org/viewvc/llvm-project?rev=321217&view=rev
Log:
Do not generate an empty switch statement as it causes MSVC to issue diagnostics about switch statements without case or default labels.
Modified:
llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=321217&r1=321216&r2=321217&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Wed Dec 20 12:09:30 2017
@@ -3551,8 +3551,10 @@ void GlobalISelEmitter::emitImmPredicate
}
OS << "bool " << Target.getName() << "InstructionSelector::testImmPredicate_"
- << TypeIdentifier << "(unsigned PredicateID, " << Type << " Imm) const {\n"
- << " switch (PredicateID) {\n";
+ << TypeIdentifier << "(unsigned PredicateID, " << Type
+ << " Imm) const {\n";
+ if (!MatchedRecords.empty())
+ OS << " switch (PredicateID) {\n";
for (const auto *Record : MatchedRecords) {
OS << " case GIPFP_" << TypeIdentifier << "_Predicate_"
<< Record->getName() << ": {\n"
@@ -3561,8 +3563,9 @@ void GlobalISelEmitter::emitImmPredicate
<< " return false;\n"
<< " }\n";
}
- OS << " }\n"
- << " llvm_unreachable(\"Unknown predicate\");\n"
+ if (!MatchedRecords.empty())
+ OS << " }\n";
+ OS << " llvm_unreachable(\"Unknown predicate\");\n"
<< " return false;\n"
<< "}\n";
}
More information about the llvm-commits
mailing list