@@ -4862,18 +4862,16 @@ class AsyncConverter : private SourceEntityWalker {
48624862 bool AddPlaceholder = Placeholders.count (D);
48634863 StringRef Name = newNameFor (D, false );
48644864 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+ });
48774875 }
48784876 } else if (isa<ForceValueExpr>(E) || isa<BindOptionalExpr>(E)) {
48794877 // Remove a force unwrap or optional chain of a returned success value,
@@ -4887,19 +4885,18 @@ class AsyncConverter : private SourceEntityWalker {
48874885 // completely valid.
48884886 if (auto *D = E->getReferencedDecl ().getDecl ()) {
48894887 if (Unwraps.count (D))
4890- return addCustom (E->getStartLoc (), E-> getEndLoc (). getAdvancedLoc ( 1 ),
4888+ return addCustom (E->getSourceRange ( ),
48914889 [&]() { OS << newNameFor (D, true ); });
48924890 }
48934891 } else if (NestedExprCount == 0 ) {
48944892 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); });
48974894
48984895 if (auto *CE = dyn_cast<CallExpr>(E)) {
48994896 auto HandlerDesc = AsyncHandlerDesc::find (
49004897 getUnderlyingFunc (CE->getFn ()), StartNode.dyn_cast <Expr *>() == CE);
49014898 if (HandlerDesc.isValid ())
4902- return addCustom (CE->getStartLoc (), CE-> getEndLoc (). getAdvancedLoc ( 1 ),
4899+ return addCustom (CE->getSourceRange ( ),
49034900 [&]() { addAsyncAlternativeCall (CE, HandlerDesc); });
49044901 }
49054902 }
@@ -4915,11 +4912,10 @@ class AsyncConverter : private SourceEntityWalker {
49154912 return true ;
49164913 }
49174914
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 );
49214917 Custom ();
4922- LastAddedLoc = NextAddedLoc ;
4918+ LastAddedLoc = Lexer::getLocForEndOfToken (SM, Range. End ) ;
49234919 return false ;
49244920 }
49254921
0 commit comments