@@ -2844,38 +2844,41 @@ void SILGenFunction::emitSwitchFallthrough(FallthroughStmt *S) {
28442844
28452845 if (!caseStmt->hasBoundDecls ()) {
28462846 Cleanups.emitBranchAndCleanups (sharedDest, S);
2847- } else {
2848- // Generate branch args to pass along current vars to fallthrough case.
2849- SILModule &M = F.getModule ();
2850- ArrayRef<CaseLabelItem> labelItems = caseStmt->getCaseLabelItems ();
2851- SmallVector<SILValue, 4 > args;
2852- SmallVector<VarDecl *, 4 > expectedVarOrder;
2853- labelItems[0 ].getPattern ()->collectVariables (expectedVarOrder);
2854-
2855- for (auto *expected : expectedVarOrder) {
2856- if (!expected->hasName ())
2857- continue ;
2858- for (auto var : VarLocs) {
2859- auto varDecl = dyn_cast<VarDecl>(var.getFirst ());
2860- if (varDecl && varDecl->hasName () && varDecl->getName () == expected->getName ()) {
2861- SILValue value = var.getSecond ().value ;
2862-
2863- if (value->getType ().isAddressOnly (M)) {
2864- context->Emission .emitAddressOnlyInitialization (expected, value);
2865- } else if (var.getSecond ().box ) {
2866- auto &lowering = getTypeLowering (value->getType ());
2867- auto argValue = lowering.emitLoad (B, CurrentSILLoc, value, LoadOwnershipQualifier::Copy);
2868- args.push_back (argValue);
2869- } else {
2870- auto argValue = B.emitCopyValueOperation (CurrentSILLoc, value);
2871- args.push_back (argValue);
2872- }
2873- break ;
2847+ return ;
2848+ }
2849+
2850+ // Generate branch args to pass along current vars to fallthrough case.
2851+ SILModule &M = F.getModule ();
2852+ ArrayRef<CaseLabelItem> labelItems = caseStmt->getCaseLabelItems ();
2853+ SmallVector<SILValue, 4 > args;
2854+ SmallVector<VarDecl *, 4 > expectedVarOrder;
2855+ labelItems[0 ].getPattern ()->collectVariables (expectedVarOrder);
2856+
2857+ for (auto *expected : expectedVarOrder) {
2858+ if (!expected->hasName ())
2859+ continue ;
2860+ for (auto var : VarLocs) {
2861+ auto varDecl = dyn_cast<VarDecl>(var.getFirst ());
2862+ if (varDecl && varDecl->hasName () &&
2863+ varDecl->getName () == expected->getName ()) {
2864+ SILValue value = var.getSecond ().value ;
2865+
2866+ if (value->getType ().isAddressOnly (M)) {
2867+ context->Emission .emitAddressOnlyInitialization (expected, value);
2868+ } else if (var.getSecond ().box ) {
2869+ auto &lowering = getTypeLowering (value->getType ());
2870+ auto argValue = lowering.emitLoad (B, CurrentSILLoc, value,
2871+ LoadOwnershipQualifier::Copy);
2872+ args.push_back (argValue);
2873+ } else {
2874+ auto argValue = B.emitCopyValueOperation (CurrentSILLoc, value);
2875+ args.push_back (argValue);
28742876 }
2877+ break ;
28752878 }
28762879 }
2877- Cleanups.emitBranchAndCleanups (sharedDest, S, args);
28782880 }
2881+ Cleanups.emitBranchAndCleanups (sharedDest, S, args);
28792882}
28802883
28812884
0 commit comments