mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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();
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user