[SILGen] Minor improvements to generateEnumCaseBlocks

Noticed by MichaelG while reviewing my changes in the previous commit.
No intended functionality change.
This commit is contained in:
Jordan Rose
2018-02-21 10:33:35 -08:00
parent 36eae9d4f6
commit 49e71c9415

View File

@@ -1710,7 +1710,7 @@ static void generateEnumCaseBlocks(
auto enumDecl = sourceType.getEnumOrBoundGenericEnum(); auto enumDecl = sourceType.getEnumOrBoundGenericEnum();
llvm::DenseMap<EnumElementDecl*, unsigned> caseToIndex; llvm::SmallDenseMap<EnumElementDecl *, unsigned, 16> caseToIndex;
for (auto &row : rows) { for (auto &row : rows) {
EnumElementDecl *formalElt; EnumElementDecl *formalElt;
Pattern *subPattern = nullptr; Pattern *subPattern = nullptr;
@@ -1774,12 +1774,10 @@ static void generateEnumCaseBlocks(
if (canAssumeExhaustive) { if (canAssumeExhaustive) {
// Check that Sema didn't let any cases slip through. (This can happen // Check that Sema didn't let any cases slip through. (This can happen
// with @_downgrade_exhaustivity_check.) // with @_downgrade_exhaustivity_check.)
for (auto elt : enumDecl->getAllElements()) { canAssumeExhaustive = llvm::all_of(enumDecl->getAllElements(),
if (!caseToIndex.count(elt)) { [&](const EnumElementDecl *elt) {
canAssumeExhaustive = false; return caseToIndex.count(elt);
break; });
}
}
} }
if (!canAssumeExhaustive) if (!canAssumeExhaustive)