Skip to content

Commit 372fe24

Browse files
committed
[SpaceEngine] Don't include redundant cases into "covered" space
There is no reason to include spaces which have already been covered by some other cases in the `switch` statement, excluding such cases helps to reduce some of the work done by exhaustiveness checker.
1 parent 99858b7 commit 372fe24

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/Sema/TypeCheckSwitchStmt.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,7 @@ namespace {
11851185
TC.diagnose(caseItem.getStartLoc(),
11861186
diag::redundant_particular_case)
11871187
.highlight(caseItem.getSourceRange());
1188+
continue;
11881189
} else {
11891190
Expr *cachedExpr = nullptr;
11901191
if (checkRedundantLiteral(caseItem.getPattern(), cachedExpr)) {
@@ -1195,6 +1196,7 @@ namespace {
11951196
TC.diagnose(cachedExpr->getLoc(),
11961197
diag::redundant_particular_literal_case_here)
11971198
.highlight(cachedExpr->getSourceRange());
1199+
continue;
11981200
}
11991201
}
12001202
spaces.push_back(projection);

0 commit comments

Comments
 (0)