@@ -2844,38 +2844,47 @@ void SILGenFunction::emitSwitchFallthrough(FallthroughStmt *S) {
2844
2844
2845
2845
if (!caseStmt->hasBoundDecls ()) {
2846
2846
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 ())
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 ()) {
2857
2864
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 ;
2874
- }
2875
2865
}
2866
+
2867
+ SILValue value = var.getSecond ().value ;
2868
+
2869
+ if (value->getType ().isAddressOnly (M)) {
2870
+ context->Emission .emitAddressOnlyInitialization (expected, value);
2871
+ break ;
2872
+ }
2873
+
2874
+ if (var.getSecond ().box ) {
2875
+ auto &lowering = getTypeLowering (value->getType ());
2876
+ auto argValue = lowering.emitLoad (B, CurrentSILLoc, value,
2877
+ LoadOwnershipQualifier::Copy);
2878
+ args.push_back (argValue);
2879
+ break ;
2880
+ }
2881
+
2882
+ auto argValue = B.emitCopyValueOperation (CurrentSILLoc, value);
2883
+ args.push_back (argValue);
2884
+ break ;
2876
2885
}
2877
- Cleanups.emitBranchAndCleanups (sharedDest, S, args);
2878
2886
}
2887
+ Cleanups.emitBranchAndCleanups (sharedDest, S, args);
2879
2888
}
2880
2889
2881
2890
0 commit comments