Skip to content

Commit 967b3a3

Browse files
committed
[Diagnostics] Adjust getCallInfo to accept TypedNode instead of expression
1 parent 4ea7f3b commit 967b3a3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,9 +3909,8 @@ bool MissingArgumentsFailure::diagnoseAsError() {
39093909
unsigned numArguments = 0;
39103910
bool hasTrailingClosure = false;
39113911

3912-
auto *rawAnchor = getRawAnchor().get<const Expr *>();
39133912
std::tie(fnExpr, argExpr, numArguments, hasTrailingClosure) =
3914-
getCallInfo(const_cast<Expr *>(rawAnchor));
3913+
getCallInfo(getRawAnchor());
39153914

39163915
// TODO(diagnostics): We should be able to suggest this fix-it
39173916
// unconditionally.
@@ -3987,7 +3986,7 @@ bool MissingArgumentsFailure::diagnoseSingleMissingArgument() const {
39873986
bool hasTrailingClosure = false;
39883987

39893988
std::tie(fnExpr, argExpr, insertableEndIdx, hasTrailingClosure) =
3990-
getCallInfo(const_cast<Expr *>(anchor.get<const Expr *>()));
3989+
getCallInfo(anchor);
39913990

39923991
if (!argExpr)
39933992
return false;
@@ -4293,17 +4292,17 @@ bool MissingArgumentsFailure::isMisplacedMissingArgument(
42934292
}
42944293

42954294
std::tuple<Expr *, Expr *, unsigned, bool>
4296-
MissingArgumentsFailure::getCallInfo(Expr *anchor) const {
4297-
if (auto *call = dyn_cast<CallExpr>(anchor)) {
4295+
MissingArgumentsFailure::getCallInfo(TypedNode anchor) const {
4296+
if (auto *call = getAsExpr<CallExpr>(anchor)) {
42984297
return std::make_tuple(call->getFn(), call->getArg(),
42994298
call->getNumArguments(), call->hasTrailingClosure());
4300-
} else if (auto *UME = dyn_cast<UnresolvedMemberExpr>(anchor)) {
4299+
} else if (auto *UME = getAsExpr<UnresolvedMemberExpr>(anchor)) {
43014300
return std::make_tuple(UME, UME->getArgument(), UME->getNumArguments(),
43024301
UME->hasTrailingClosure());
4303-
} else if (auto *SE = dyn_cast<SubscriptExpr>(anchor)) {
4302+
} else if (auto *SE = getAsExpr<SubscriptExpr>(anchor)) {
43044303
return std::make_tuple(SE, SE->getIndex(), SE->getNumArguments(),
43054304
SE->hasTrailingClosure());
4306-
} else if (auto *OLE = dyn_cast<ObjectLiteralExpr>(anchor)) {
4305+
} else if (auto *OLE = getAsExpr<ObjectLiteralExpr>(anchor)) {
43074306
return std::make_tuple(OLE, OLE->getArg(), OLE->getNumArguments(),
43084307
OLE->hasTrailingClosure());
43094308
}

lib/Sema/CSDiagnostics.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,10 +1278,11 @@ class MissingArgumentsFailure final : public FailureDiagnostic {
12781278
/// `@Foo(answer: 42) var question = "ultimate question"`
12791279
bool isPropertyWrapperInitialization() const;
12801280

1281-
/// Gather informatioin associated with expression that represents
1281+
/// Gather information associated with expression that represents
12821282
/// a call - function, arguments, # of arguments and whether it has
12831283
/// a trailing closure.
1284-
std::tuple<Expr *, Expr *, unsigned, bool> getCallInfo(Expr *anchor) const;
1284+
std::tuple<Expr *, Expr *, unsigned, bool>
1285+
getCallInfo(TypedNode anchor) const;
12851286

12861287
/// Transform given argument into format suitable for a fix-it
12871288
/// text e.g. `[<label>:]? <#<type#>`

0 commit comments

Comments
 (0)