@@ -2521,44 +2521,6 @@ void PatternMatchEmission::emitSharedCaseBlocks() {
2521
2521
}
2522
2522
}
2523
2523
2524
- namespace {
2525
- class FallthroughFinder : public ASTWalker {
2526
- bool &Result;
2527
- public:
2528
- FallthroughFinder (bool &Result) : Result(Result) {}
2529
-
2530
- // We walk through statements. If we find a fallthrough, then we got what
2531
- // we came for.
2532
- std::pair<bool , Stmt *> walkToStmtPre (Stmt *S) override {
2533
- if (isa<FallthroughStmt>(S))
2534
- Result = true ;
2535
-
2536
- return { true , S };
2537
- }
2538
-
2539
- // Expressions, patterns and decls cannot contain fallthrough statements, so
2540
- // there is no reason to walk into them.
2541
- std::pair<bool , Expr *> walkToExprPre (Expr *E) override {
2542
- return { false , E };
2543
- }
2544
- std::pair<bool , Pattern*> walkToPatternPre (Pattern *P) override {
2545
- return { false , P };
2546
- }
2547
-
2548
- bool walkToDeclPre (Decl *D) override { return false ; }
2549
- bool walkToTypeLocPre (TypeLoc &TL) override { return false ; }
2550
- bool walkToTypeReprPre (TypeRepr *T) override { return false ; }
2551
- };
2552
- } // end anonymous namespace
2553
-
2554
-
2555
- static bool containsFallthrough (Stmt *S) {
2556
- bool Result = false ;
2557
- S->walk (FallthroughFinder (Result));
2558
- return Result;
2559
- }
2560
-
2561
-
2562
2524
// / Context info used to emit FallthroughStmts.
2563
2525
// / Since fallthrough-able case blocks must not bind variables, they are always
2564
2526
// / emitted in the outermost scope of the switch.
@@ -2770,8 +2732,8 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
2770
2732
const_cast <Expr*>(labelItem.getGuardExpr ()),
2771
2733
hasFallthrough);
2772
2734
}
2773
-
2774
- hasFallthrough = containsFallthrough ( caseBlock->getBody () );
2735
+
2736
+ hasFallthrough = caseBlock->hasFallthroughDest ( );
2775
2737
}
2776
2738
2777
2739
// Emit alloc_stacks for address-only variables appearing in
0 commit comments