@@ -1889,11 +1889,11 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
18891889 SourceLoc removeRangeStart;
18901890 SourceLoc removeRangeEnd;
18911891
1892- auto *argExpr = CE->getArg ();
1893- auto argList = getOriginalArgumentList (argExpr );
1892+ auto *argList = CE->getArgs ();
1893+ auto originalArgs = argList-> getOriginalArguments ( );
18941894
1895- size_t numElementsWithinParens = argList. args .size ();
1896- numElementsWithinParens -= argList .getNumTrailingClosures ();
1895+ size_t numElementsWithinParens = originalArgs .size ();
1896+ numElementsWithinParens -= originalArgs .getNumTrailingClosures ();
18971897 if (selfIndex >= numElementsWithinParens)
18981898 return ;
18991899
@@ -1904,48 +1904,48 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
19041904 if (numElementsWithinParens != 2 )
19051905 return ;
19061906 } else {
1907- if (parsed.ArgumentLabels .size () != argList. args .size () - 1 )
1907+ if (parsed.ArgumentLabels .size () != originalArgs .size () - 1 )
19081908 return ;
19091909 }
19101910
1911- selfExpr = argList. args [selfIndex];
1911+ selfExpr = originalArgs [selfIndex]. getExpr () ;
19121912
19131913 if (selfIndex + 1 == numElementsWithinParens) {
19141914 if (selfIndex > 0 ) {
19151915 // Remove from the previous comma to the close-paren (half-open).
1916- removeRangeStart = argList. args [selfIndex- 1 ] ->getEndLoc ();
1916+ removeRangeStart = originalArgs [selfIndex - 1 ]. getExpr () ->getEndLoc ();
19171917 removeRangeStart = Lexer::getLocForEndOfToken (sourceMgr,
19181918 removeRangeStart);
19191919 } else {
19201920 // Remove from after the open paren to the close paren (half-open).
1921- removeRangeStart = Lexer::getLocForEndOfToken (sourceMgr,
1922- argExpr ->getStartLoc ());
1921+ removeRangeStart =
1922+ Lexer::getLocForEndOfToken (sourceMgr, argList ->getStartLoc ());
19231923 }
19241924
19251925 // Prefer the r-paren location, so that we get the right behavior when
19261926 // there's a trailing closure, but handle some implicit cases too.
1927- removeRangeEnd = argList. rParenLoc ;
1927+ removeRangeEnd = argList-> getRParenLoc () ;
19281928 if (removeRangeEnd.isInvalid ())
1929- removeRangeEnd = argExpr ->getEndLoc ();
1929+ removeRangeEnd = argList ->getEndLoc ();
19301930
19311931 } else {
19321932 // Remove from the label to the start of the next argument (half-open).
1933- SourceLoc labelLoc = argList. labelLocs [selfIndex];
1933+ SourceLoc labelLoc = originalArgs [selfIndex]. getLabelLoc () ;
19341934 if (labelLoc.isValid ())
19351935 removeRangeStart = labelLoc;
19361936 else
19371937 removeRangeStart = selfExpr->getStartLoc ();
19381938
1939- SourceLoc nextLabelLoc = argList. labelLocs [selfIndex + 1 ];
1939+ SourceLoc nextLabelLoc = originalArgs [selfIndex + 1 ]. getLabelLoc () ;
19401940 if (nextLabelLoc.isValid ())
19411941 removeRangeEnd = nextLabelLoc;
19421942 else
1943- removeRangeEnd = argList. args [selfIndex + 1 ]->getStartLoc ();
1943+ removeRangeEnd = originalArgs [selfIndex + 1 ]. getExpr () ->getStartLoc ();
19441944 }
19451945
19461946 // Avoid later argument label fix-its for this argument.
19471947 if (!parsed.isPropertyAccessor ()) {
1948- Identifier oldLabel = argList. labels [selfIndex];
1948+ Identifier oldLabel = originalArgs [selfIndex]. getLabel () ;
19491949 StringRef oldLabelStr;
19501950 if (!oldLabel.empty ())
19511951 oldLabelStr = oldLabel.str ();
@@ -2046,7 +2046,7 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
20462046
20472047 // Renaming from SubscriptExpr to CallExpr. Insert function name and
20482048 // replace square brackets with parens.
2049- diag.fixItReplace (SE->getIndex ()->getStartLoc (),
2049+ diag.fixItReplace (SE->getArgs ()->getStartLoc (),
20502050 (" ." + baseReplace.str () + " (" ).str ());
20512051 diag.fixItReplace (SE->getEndLoc (), " )" );
20522052 } else {
@@ -2060,45 +2060,37 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
20602060 }
20612061 }
20622062
2063- if (!call)
2064- return ;
2065-
2066- Expr *argExpr;
2067- if (auto *CE = dyn_cast<CallExpr>(call))
2068- argExpr = CE->getArg ();
2069- else if (auto *SE = dyn_cast<SubscriptExpr>(call))
2070- argExpr = SE->getIndex ();
2071- else
2063+ if (!call || !call->getArgs ())
20722064 return ;
20732065
2074- auto argList = getOriginalArgumentList (argExpr);
2066+ auto *argList = call->getArgs ();
2067+ auto originalArgs = argList->getOriginalArguments ();
20752068
20762069 if (parsed.IsGetter ) {
2077- diag.fixItRemove (argExpr ->getSourceRange ());
2070+ diag.fixItRemove (argList ->getSourceRange ());
20782071 return ;
20792072 }
20802073
20812074 if (parsed.IsSetter ) {
20822075 const Expr *newValueExpr = nullptr ;
20832076
2084- if (argList. args .size () >= 1 ) {
2077+ if (originalArgs .size () >= 1 ) {
20852078 size_t newValueIndex = 0 ;
20862079 if (parsed.isInstanceMember ()) {
20872080 assert (parsed.SelfIndex .getValue () == 0 ||
20882081 parsed.SelfIndex .getValue () == 1 );
20892082 newValueIndex = !parsed.SelfIndex .getValue ();
20902083 }
2091- newValueExpr = argList. args [newValueIndex];
2084+ newValueExpr = originalArgs [newValueIndex]. getExpr () ;
20922085 } else {
2093- newValueExpr = argList. args [0 ];
2086+ newValueExpr = originalArgs [0 ]. getExpr () ;
20942087 }
20952088
2096- diag.fixItReplaceChars (argExpr ->getStartLoc (), newValueExpr->getStartLoc (),
2089+ diag.fixItReplaceChars (argList ->getStartLoc (), newValueExpr->getStartLoc (),
20972090 " = " );
2098- diag.fixItRemoveChars (Lexer::getLocForEndOfToken (sourceMgr,
2099- newValueExpr->getEndLoc ()),
2100- Lexer::getLocForEndOfToken (sourceMgr,
2101- argExpr->getEndLoc ()));
2091+ diag.fixItRemoveChars (
2092+ Lexer::getLocForEndOfToken (sourceMgr, newValueExpr->getEndLoc ()),
2093+ Lexer::getLocForEndOfToken (sourceMgr, argList->getEndLoc ()));
21022094 return ;
21032095 }
21042096
@@ -2162,28 +2154,23 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
21622154 return false ;
21632155 };
21642156
2165- if (auto *parenExpr = dyn_cast<ParenExpr>(argExpr) ) {
2166- if (updateLabelsForArg (parenExpr-> getSubExpr ()))
2157+ for (auto arg : *argList ) {
2158+ if (updateLabelsForArg (arg. getExpr ()))
21672159 return ;
2168- } else {
2169- for (auto *arg : cast<TupleExpr>(argExpr)->getElements ()) {
2170- if (updateLabelsForArg (arg))
2171- return ;
2172- }
21732160 }
21742161
2175- if (argumentLabelIDs.size () != argList. args .size ()) {
2162+ if (argumentLabelIDs.size () != originalArgs .size ()) {
21762163 // Mismatched lengths; give up.
21772164 return ;
21782165 }
21792166
21802167 // If any of the argument labels are mismatched, perform label correction.
2181- for (auto i : indices (argList. args )) {
2168+ for (auto i : indices (originalArgs )) {
21822169 // The argument label of an unlabeled trailing closure is ignored.
2183- if (argList. isUnlabeledTrailingClosureIdx (i))
2170+ if (originalArgs. isUnlabeledTrailingClosureIndex (i))
21842171 continue ;
2185- if (argumentLabelIDs[i] != argList. labels [i]) {
2186- diagnoseArgumentLabelError (ctx, argExpr , argumentLabelIDs,
2172+ if (argumentLabelIDs[i] != originalArgs [i]. getLabel () ) {
2173+ diagnoseArgumentLabelError (ctx, argList , argumentLabelIDs,
21872174 parsed.IsSubscript , &diag);
21882175 return ;
21892176 }
@@ -3172,8 +3159,8 @@ ExprAvailabilityWalker::diagnoseIncDecRemoval(const ValueDecl *D, SourceRange R,
31723159 // Otherwise, it must be an index type. Rewrite to:
31733160 // "lvalue = lvalue.successor()".
31743161 auto &SM = Context.SourceMgr ;
3175- auto CSR = Lexer::getCharSourceRangeFromSourceRange (SM,
3176- call->getArg ()->getSourceRange ());
3162+ auto CSR = Lexer::getCharSourceRangeFromSourceRange (
3163+ SM, call->getArgs ()->getSourceRange ());
31773164 replacement = " = " + SM.extractText (CSR).str ();
31783165 replacement += isInc ? " .successor()" : " .predecessor()" ;
31793166 }
@@ -3191,7 +3178,7 @@ ExprAvailabilityWalker::diagnoseIncDecRemoval(const ValueDecl *D, SourceRange R,
31913178 if (isa<PrefixUnaryExpr>(call)) {
31923179 // Prefix: remove the ++ or --.
31933180 diag.fixItRemove (call->getFn ()->getSourceRange ());
3194- diag.fixItInsertAfter (call->getArg ()->getEndLoc (), replacement);
3181+ diag.fixItInsertAfter (call->getArgs ()->getEndLoc (), replacement);
31953182 } else {
31963183 // Postfix: replace the ++ or --.
31973184 diag.fixItReplace (call->getFn ()->getSourceRange (), replacement);
@@ -3227,8 +3214,9 @@ ExprAvailabilityWalker::diagnoseMemoryLayoutMigration(const ValueDecl *D,
32273214 if (Property.empty ())
32283215 return false ;
32293216
3230- auto args = dyn_cast<ParenExpr>(call->getArg ());
3231- if (!args)
3217+ auto *args = call->getArgs ();
3218+ auto *subject = args->getUnlabeledUnaryExpr ();
3219+ if (!subject)
32323220 return false ;
32333221
32343222 DeclName Name;
@@ -3242,8 +3230,6 @@ ExprAvailabilityWalker::diagnoseMemoryLayoutMigration(const ValueDecl *D,
32423230 Name, true , " " , EncodedMessage.Message );
32433231 diag.highlight (R);
32443232
3245- auto subject = args->getSubExpr ();
3246-
32473233 StringRef Prefix = " MemoryLayout<" ;
32483234 StringRef Suffix = " >." ;
32493235
0 commit comments