@@ -1889,11 +1889,11 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
1889
1889
SourceLoc removeRangeStart;
1890
1890
SourceLoc removeRangeEnd;
1891
1891
1892
- auto *argExpr = CE->getArg ();
1893
- auto argList = getOriginalArgumentList (argExpr );
1892
+ auto *argList = CE->getArgs ();
1893
+ auto originalArgs = argList-> getOriginalArguments ( );
1894
1894
1895
- size_t numElementsWithinParens = argList. args .size ();
1896
- numElementsWithinParens -= argList .getNumTrailingClosures ();
1895
+ size_t numElementsWithinParens = originalArgs .size ();
1896
+ numElementsWithinParens -= originalArgs .getNumTrailingClosures ();
1897
1897
if (selfIndex >= numElementsWithinParens)
1898
1898
return ;
1899
1899
@@ -1904,48 +1904,48 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
1904
1904
if (numElementsWithinParens != 2 )
1905
1905
return ;
1906
1906
} else {
1907
- if (parsed.ArgumentLabels .size () != argList. args .size () - 1 )
1907
+ if (parsed.ArgumentLabels .size () != originalArgs .size () - 1 )
1908
1908
return ;
1909
1909
}
1910
1910
1911
- selfExpr = argList. args [selfIndex];
1911
+ selfExpr = originalArgs [selfIndex]. getExpr () ;
1912
1912
1913
1913
if (selfIndex + 1 == numElementsWithinParens) {
1914
1914
if (selfIndex > 0 ) {
1915
1915
// 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 ();
1917
1917
removeRangeStart = Lexer::getLocForEndOfToken (sourceMgr,
1918
1918
removeRangeStart);
1919
1919
} else {
1920
1920
// 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 ());
1923
1923
}
1924
1924
1925
1925
// Prefer the r-paren location, so that we get the right behavior when
1926
1926
// there's a trailing closure, but handle some implicit cases too.
1927
- removeRangeEnd = argList. rParenLoc ;
1927
+ removeRangeEnd = argList-> getRParenLoc () ;
1928
1928
if (removeRangeEnd.isInvalid ())
1929
- removeRangeEnd = argExpr ->getEndLoc ();
1929
+ removeRangeEnd = argList ->getEndLoc ();
1930
1930
1931
1931
} else {
1932
1932
// 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 () ;
1934
1934
if (labelLoc.isValid ())
1935
1935
removeRangeStart = labelLoc;
1936
1936
else
1937
1937
removeRangeStart = selfExpr->getStartLoc ();
1938
1938
1939
- SourceLoc nextLabelLoc = argList. labelLocs [selfIndex + 1 ];
1939
+ SourceLoc nextLabelLoc = originalArgs [selfIndex + 1 ]. getLabelLoc () ;
1940
1940
if (nextLabelLoc.isValid ())
1941
1941
removeRangeEnd = nextLabelLoc;
1942
1942
else
1943
- removeRangeEnd = argList. args [selfIndex + 1 ]->getStartLoc ();
1943
+ removeRangeEnd = originalArgs [selfIndex + 1 ]. getExpr () ->getStartLoc ();
1944
1944
}
1945
1945
1946
1946
// Avoid later argument label fix-its for this argument.
1947
1947
if (!parsed.isPropertyAccessor ()) {
1948
- Identifier oldLabel = argList. labels [selfIndex];
1948
+ Identifier oldLabel = originalArgs [selfIndex]. getLabel () ;
1949
1949
StringRef oldLabelStr;
1950
1950
if (!oldLabel.empty ())
1951
1951
oldLabelStr = oldLabel.str ();
@@ -2046,7 +2046,7 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
2046
2046
2047
2047
// Renaming from SubscriptExpr to CallExpr. Insert function name and
2048
2048
// replace square brackets with parens.
2049
- diag.fixItReplace (SE->getIndex ()->getStartLoc (),
2049
+ diag.fixItReplace (SE->getArgs ()->getStartLoc (),
2050
2050
(" ." + baseReplace.str () + " (" ).str ());
2051
2051
diag.fixItReplace (SE->getEndLoc (), " )" );
2052
2052
} else {
@@ -2060,45 +2060,37 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
2060
2060
}
2061
2061
}
2062
2062
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 ())
2072
2064
return ;
2073
2065
2074
- auto argList = getOriginalArgumentList (argExpr);
2066
+ auto *argList = call->getArgs ();
2067
+ auto originalArgs = argList->getOriginalArguments ();
2075
2068
2076
2069
if (parsed.IsGetter ) {
2077
- diag.fixItRemove (argExpr ->getSourceRange ());
2070
+ diag.fixItRemove (argList ->getSourceRange ());
2078
2071
return ;
2079
2072
}
2080
2073
2081
2074
if (parsed.IsSetter ) {
2082
2075
const Expr *newValueExpr = nullptr ;
2083
2076
2084
- if (argList. args .size () >= 1 ) {
2077
+ if (originalArgs .size () >= 1 ) {
2085
2078
size_t newValueIndex = 0 ;
2086
2079
if (parsed.isInstanceMember ()) {
2087
2080
assert (parsed.SelfIndex .getValue () == 0 ||
2088
2081
parsed.SelfIndex .getValue () == 1 );
2089
2082
newValueIndex = !parsed.SelfIndex .getValue ();
2090
2083
}
2091
- newValueExpr = argList. args [newValueIndex];
2084
+ newValueExpr = originalArgs [newValueIndex]. getExpr () ;
2092
2085
} else {
2093
- newValueExpr = argList. args [0 ];
2086
+ newValueExpr = originalArgs [0 ]. getExpr () ;
2094
2087
}
2095
2088
2096
- diag.fixItReplaceChars (argExpr ->getStartLoc (), newValueExpr->getStartLoc (),
2089
+ diag.fixItReplaceChars (argList ->getStartLoc (), newValueExpr->getStartLoc (),
2097
2090
" = " );
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 ()));
2102
2094
return ;
2103
2095
}
2104
2096
@@ -2162,28 +2154,23 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
2162
2154
return false ;
2163
2155
};
2164
2156
2165
- if (auto *parenExpr = dyn_cast<ParenExpr>(argExpr) ) {
2166
- if (updateLabelsForArg (parenExpr-> getSubExpr ()))
2157
+ for (auto arg : *argList ) {
2158
+ if (updateLabelsForArg (arg. getExpr ()))
2167
2159
return ;
2168
- } else {
2169
- for (auto *arg : cast<TupleExpr>(argExpr)->getElements ()) {
2170
- if (updateLabelsForArg (arg))
2171
- return ;
2172
- }
2173
2160
}
2174
2161
2175
- if (argumentLabelIDs.size () != argList. args .size ()) {
2162
+ if (argumentLabelIDs.size () != originalArgs .size ()) {
2176
2163
// Mismatched lengths; give up.
2177
2164
return ;
2178
2165
}
2179
2166
2180
2167
// If any of the argument labels are mismatched, perform label correction.
2181
- for (auto i : indices (argList. args )) {
2168
+ for (auto i : indices (originalArgs )) {
2182
2169
// The argument label of an unlabeled trailing closure is ignored.
2183
- if (argList. isUnlabeledTrailingClosureIdx (i))
2170
+ if (originalArgs. isUnlabeledTrailingClosureIndex (i))
2184
2171
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,
2187
2174
parsed.IsSubscript , &diag);
2188
2175
return ;
2189
2176
}
@@ -3172,8 +3159,8 @@ ExprAvailabilityWalker::diagnoseIncDecRemoval(const ValueDecl *D, SourceRange R,
3172
3159
// Otherwise, it must be an index type. Rewrite to:
3173
3160
// "lvalue = lvalue.successor()".
3174
3161
auto &SM = Context.SourceMgr ;
3175
- auto CSR = Lexer::getCharSourceRangeFromSourceRange (SM,
3176
- call->getArg ()->getSourceRange ());
3162
+ auto CSR = Lexer::getCharSourceRangeFromSourceRange (
3163
+ SM, call->getArgs ()->getSourceRange ());
3177
3164
replacement = " = " + SM.extractText (CSR).str ();
3178
3165
replacement += isInc ? " .successor()" : " .predecessor()" ;
3179
3166
}
@@ -3191,7 +3178,7 @@ ExprAvailabilityWalker::diagnoseIncDecRemoval(const ValueDecl *D, SourceRange R,
3191
3178
if (isa<PrefixUnaryExpr>(call)) {
3192
3179
// Prefix: remove the ++ or --.
3193
3180
diag.fixItRemove (call->getFn ()->getSourceRange ());
3194
- diag.fixItInsertAfter (call->getArg ()->getEndLoc (), replacement);
3181
+ diag.fixItInsertAfter (call->getArgs ()->getEndLoc (), replacement);
3195
3182
} else {
3196
3183
// Postfix: replace the ++ or --.
3197
3184
diag.fixItReplace (call->getFn ()->getSourceRange (), replacement);
@@ -3227,8 +3214,9 @@ ExprAvailabilityWalker::diagnoseMemoryLayoutMigration(const ValueDecl *D,
3227
3214
if (Property.empty ())
3228
3215
return false ;
3229
3216
3230
- auto args = dyn_cast<ParenExpr>(call->getArg ());
3231
- if (!args)
3217
+ auto *args = call->getArgs ();
3218
+ auto *subject = args->getUnlabeledUnaryExpr ();
3219
+ if (!subject)
3232
3220
return false ;
3233
3221
3234
3222
DeclName Name;
@@ -3242,8 +3230,6 @@ ExprAvailabilityWalker::diagnoseMemoryLayoutMigration(const ValueDecl *D,
3242
3230
Name, true , " " , EncodedMessage.Message );
3243
3231
diag.highlight (R);
3244
3232
3245
- auto subject = args->getSubExpr ();
3246
-
3247
3233
StringRef Prefix = " MemoryLayout<" ;
3248
3234
StringRef Suffix = " >." ;
3249
3235
0 commit comments