@@ -4862,18 +4862,16 @@ class AsyncConverter : private SourceEntityWalker {
4862
4862
bool AddPlaceholder = Placeholders.count (D);
4863
4863
StringRef Name = newNameFor (D, false );
4864
4864
if (AddPlaceholder || !Name.empty ())
4865
- return addCustom (DRE->getStartLoc (),
4866
- Lexer::getLocForEndOfToken (SM, DRE->getEndLoc ()),
4867
- [&]() {
4868
- if (AddPlaceholder)
4869
- OS << PLACEHOLDER_START;
4870
- if (!Name.empty ())
4871
- OS << Name;
4872
- else
4873
- D->getName ().print (OS);
4874
- if (AddPlaceholder)
4875
- OS << PLACEHOLDER_END;
4876
- });
4865
+ return addCustom (DRE->getSourceRange (), [&]() {
4866
+ if (AddPlaceholder)
4867
+ OS << PLACEHOLDER_START;
4868
+ if (!Name.empty ())
4869
+ OS << Name;
4870
+ else
4871
+ D->getName ().print (OS);
4872
+ if (AddPlaceholder)
4873
+ OS << PLACEHOLDER_END;
4874
+ });
4877
4875
}
4878
4876
} else if (isa<ForceValueExpr>(E) || isa<BindOptionalExpr>(E)) {
4879
4877
// Remove a force unwrap or optional chain of a returned success value,
@@ -4887,19 +4885,18 @@ class AsyncConverter : private SourceEntityWalker {
4887
4885
// completely valid.
4888
4886
if (auto *D = E->getReferencedDecl ().getDecl ()) {
4889
4887
if (Unwraps.count (D))
4890
- return addCustom (E->getStartLoc (), E-> getEndLoc (). getAdvancedLoc ( 1 ),
4888
+ return addCustom (E->getSourceRange ( ),
4891
4889
[&]() { OS << newNameFor (D, true ); });
4892
4890
}
4893
4891
} else if (NestedExprCount == 0 ) {
4894
4892
if (CallExpr *CE = TopHandler.getAsHandlerCall (E))
4895
- return addCustom (CE->getStartLoc (), CE->getEndLoc ().getAdvancedLoc (1 ),
4896
- [&]() { addHandlerCall (CE); });
4893
+ return addCustom (CE->getSourceRange (), [&]() { addHandlerCall (CE); });
4897
4894
4898
4895
if (auto *CE = dyn_cast<CallExpr>(E)) {
4899
4896
auto HandlerDesc = AsyncHandlerDesc::find (
4900
4897
getUnderlyingFunc (CE->getFn ()), StartNode.dyn_cast <Expr *>() == CE);
4901
4898
if (HandlerDesc.isValid ())
4902
- return addCustom (CE->getStartLoc (), CE-> getEndLoc (). getAdvancedLoc ( 1 ),
4899
+ return addCustom (CE->getSourceRange ( ),
4903
4900
[&]() { addAsyncAlternativeCall (CE, HandlerDesc); });
4904
4901
}
4905
4902
}
@@ -4915,11 +4912,10 @@ class AsyncConverter : private SourceEntityWalker {
4915
4912
return true ;
4916
4913
}
4917
4914
4918
- bool addCustom (SourceLoc End, SourceLoc NextAddedLoc,
4919
- std::function<void ()> Custom = {}) {
4920
- addRange (LastAddedLoc, End);
4915
+ bool addCustom (SourceRange Range, std::function<void ()> Custom = {}) {
4916
+ addRange (LastAddedLoc, Range.Start );
4921
4917
Custom ();
4922
- LastAddedLoc = NextAddedLoc ;
4918
+ LastAddedLoc = Lexer::getLocForEndOfToken (SM, Range. End ) ;
4923
4919
return false ;
4924
4920
}
4925
4921
0 commit comments