Skip to content

Commit 78ae82e

Browse files
committed
[Async Refactoring] Code style improvements
1 parent 4cd2bb6 commit 78ae82e

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;
@@ -6422,21 +6422,7 @@ class AsyncConverter : private SourceEntityWalker {
64226422
// Print the function result type, making sure to omit a '-> Void' return.
64236423
if (!TopHandler.willAsyncReturnVoid()) {
64246424
OS << " -> ";
6425-
if (ReturnTypes.size() > 1)
6426-
OS << "(";
6427-
6428-
llvm::interleave(
6429-
ReturnTypes,
6430-
[&](LabeledReturnType TypeAndLabel) {
6431-
if (!TypeAndLabel.Label.empty()) {
6432-
OS << TypeAndLabel.Label << tok::colon << " ";
6433-
}
6434-
TypeAndLabel.Ty->print(OS);
6435-
},
6436-
[&]() { OS << ", "; });
6437-
6438-
if (ReturnTypes.size() > 1)
6439-
OS << ")";
6425+
addAsyncFuncReturnType(TopHandler);
64406426
}
64416427

64426428
if (FD->hasBody())
@@ -6477,10 +6463,13 @@ class AsyncConverter : private SourceEntityWalker {
64776463
// for the completion handler call, e.g 'return completion(args...)'. In
64786464
// that case, be sure not to add another return.
64796465
auto *parent = getWalker().Parent.getAsStmt();
6480-
AddedReturnOrThrow = !(parent && isa<ReturnStmt>(parent) &&
6481-
!cast<ReturnStmt>(parent)->isImplicit());
6482-
if (AddedReturnOrThrow)
6466+
if (parent && isa<ReturnStmt>(parent) &&
6467+
!cast<ReturnStmt>(parent)->isImplicit()) {
6468+
// The statement already has a return keyword. Don't add another one.
6469+
AddedReturnOrThrow = false;
6470+
} else {
64836471
OS << tok::kw_return;
6472+
}
64846473
} else {
64856474
OS << tok::kw_throw;
64866475
}

0 commit comments

Comments
 (0)