Skip to content

Commit f9832e9

Browse files
committed
[Refactoring] Tweak handling of return and break placeholders
- Add a missing return to the break statement placeholder handling. - Only turn the `return` token into a placeholder, as we still want to apply the transformation to the sub expression. This stops us from crashing by attempting to walk into the return sub-expression. rdar://77789360
1 parent 1830773 commit f9832e9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/IDE/Refactoring.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5608,12 +5608,14 @@ class AsyncConverter : private SourceEntityWalker {
56085608
// it would have been lifted out of the switch statement.
56095609
if (auto *SS = dyn_cast<SwitchStmt>(BS->getTarget())) {
56105610
if (HandledSwitches.contains(SS))
5611-
replaceRangeWithPlaceholder(S->getSourceRange());
5611+
return replaceRangeWithPlaceholder(S->getSourceRange());
56125612
}
56135613
} else if (isa<ReturnStmt>(S) && NestedExprCount == 0) {
56145614
// For a return, if it's not nested inside another closure or function,
56155615
// turn it into a placeholder, as it will be lifted out of the callback.
5616-
replaceRangeWithPlaceholder(S->getSourceRange());
5616+
// Note that we only turn the 'return' token into a placeholder as we
5617+
// still want to be able to apply transforms to the argument.
5618+
replaceRangeWithPlaceholder(S->getStartLoc());
56175619
}
56185620
}
56195621
return true;

0 commit comments

Comments
 (0)