Skip to content

Commit d7d58cb

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 ef318a1 commit d7d58cb

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
@@ -5600,12 +5600,14 @@ class AsyncConverter : private SourceEntityWalker {
56005600
// it would have been lifted out of the switch statement.
56015601
if (auto *SS = dyn_cast<SwitchStmt>(BS->getTarget())) {
56025602
if (HandledSwitches.contains(SS))
5603-
replaceRangeWithPlaceholder(S->getSourceRange());
5603+
return replaceRangeWithPlaceholder(S->getSourceRange());
56045604
}
56055605
} else if (isa<ReturnStmt>(S) && NestedExprCount == 0) {
56065606
// For a return, if it's not nested inside another closure or function,
56075607
// turn it into a placeholder, as it will be lifted out of the callback.
5608-
replaceRangeWithPlaceholder(S->getSourceRange());
5608+
// Note that we only turn the 'return' token into a placeholder as we
5609+
// still want to be able to apply transforms to the argument.
5610+
replaceRangeWithPlaceholder(S->getStartLoc());
56095611
}
56105612
}
56115613
return true;

0 commit comments

Comments
 (0)