diff --git a/utils/TableGen/SubtargetEmitter.cpp b/utils/TableGen/SubtargetEmitter.cpp index a70dbc97287..6cc28d7c7f9 100644 --- a/utils/TableGen/SubtargetEmitter.cpp +++ b/utils/TableGen/SubtargetEmitter.cpp @@ -87,7 +87,7 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) { << "static llvm::SubtargetFeatureKV FeatureKV[] = {\n"; // For each feature - for (unsigned i = 0, N = FeatureList.size(); i < N;) { + for (unsigned i = 0, N = FeatureList.size(); i < N; ++i) { // Next feature Record *Feature = FeatureList[i]; @@ -95,6 +95,8 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) { std::string CommandLineName = Feature->getValueAsString("Name"); std::string Desc = Feature->getValueAsString("Desc"); + if (CommandLineName.empty()) continue; + // Emit as { "feature", "decription", feactureEnum } OS << " { " << "\"" << CommandLineName << "\", " @@ -103,7 +105,7 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) { << " }"; // Depending on 'if more in the list' emit comma - if (++i < N) OS << ","; + if ((i + 1) < N) OS << ","; OS << "\n"; }