mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -1710,7 +1710,7 @@ static void generateEnumCaseBlocks(
|
||||
|
||||
auto enumDecl = sourceType.getEnumOrBoundGenericEnum();
|
||||
|
||||
llvm::DenseMap<EnumElementDecl*, unsigned> caseToIndex;
|
||||
llvm::SmallDenseMap<EnumElementDecl *, unsigned, 16> caseToIndex;
|
||||
for (auto &row : rows) {
|
||||
EnumElementDecl *formalElt;
|
||||
Pattern *subPattern = nullptr;
|
||||
@@ -1774,12 +1774,10 @@ static void generateEnumCaseBlocks(
|
||||
if (canAssumeExhaustive) {
|
||||
// Check that Sema didn't let any cases slip through. (This can happen
|
||||
// with @_downgrade_exhaustivity_check.)
|
||||
for (auto elt : enumDecl->getAllElements()) {
|
||||
if (!caseToIndex.count(elt)) {
|
||||
canAssumeExhaustive = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
canAssumeExhaustive = llvm::all_of(enumDecl->getAllElements(),
|
||||
[&](const EnumElementDecl *elt) {
|
||||
return caseToIndex.count(elt);
|
||||
});
|
||||
}
|
||||
|
||||
if (!canAssumeExhaustive)
|
||||
|
||||
Reference in New Issue
Block a user