Skip to content

Commit d0472e1

Browse files
committed
[Async Refactoring] Code style improvements
1 parent 7a68a1d commit d0472e1

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

lib/IDE/Refactoring.cpp

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ bool RefactoringActionCollapseNestedIfStmt::performChange() {
18341834
EditConsumer, SM,
18351835
Lexer::getCharSourceRangeFromSourceRange(SM, OuterIf->getSourceRange()));
18361836

1837-
OS << tok::kw_if << " ";
1837+
OS << tok::kw_if << " ";
18381838

18391839
// Emit conditions.
18401840
bool first = true;
@@ -6406,21 +6406,7 @@ class AsyncConverter : private SourceEntityWalker {
64066406
// Print the function result type, making sure to omit a '-> Void' return.
64076407
if (!TopHandler.willAsyncReturnVoid()) {
64086408
OS << " -> ";
6409-
if (ReturnTypes.size() > 1)
6410-
OS << "(";
6411-
6412-
llvm::interleave(
6413-
ReturnTypes,
6414-
[&](LabeledReturnType TypeAndLabel) {
6415-
if (!TypeAndLabel.Label.empty()) {
6416-
OS << TypeAndLabel.Label << tok::colon << " ";
6417-
}
6418-
TypeAndLabel.Ty->print(OS);
6419-
},
6420-
[&]() { OS << ", "; });
6421-
6422-
if (ReturnTypes.size() > 1)
6423-
OS << ")";
6409+
addAsyncFuncReturnType(TopHandler);
64246410
}
64256411

64266412
if (FD->hasBody())
@@ -6461,10 +6447,13 @@ class AsyncConverter : private SourceEntityWalker {
64616447
// for the completion handler call, e.g 'return completion(args...)'. In
64626448
// that case, be sure not to add another return.
64636449
auto *parent = getWalker().Parent.getAsStmt();
6464-
AddedReturnOrThrow = !(parent && isa<ReturnStmt>(parent) &&
6465-
!cast<ReturnStmt>(parent)->isImplicit());
6466-
if (AddedReturnOrThrow)
6450+
if (parent && isa<ReturnStmt>(parent) &&
6451+
!cast<ReturnStmt>(parent)->isImplicit()) {
6452+
// The statement already has a return keyword. Don't add another one.
6453+
AddedReturnOrThrow = false;
6454+
} else {
64676455
OS << tok::kw_return;
6456+
}
64686457
} else {
64696458
OS << tok::kw_throw;
64706459
}

0 commit comments

Comments
 (0)