Skip to content

Commit 7e788b8

Browse files
committed
[AST] Remove CallerDefaultArgumentExpr
Now that we use DefaultArgumentExpr for both kinds of default arguments, this is no longer needed.
1 parent 9b4779f commit 7e788b8

File tree

10 files changed

+4
-77
lines changed

10 files changed

+4
-77
lines changed

include/swift/AST/Expr.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3916,44 +3916,6 @@ class DefaultArgumentExpr final : public Expr {
39163916
}
39173917
};
39183918

3919-
/// An expression referring to a caller-side default argument left unspecified
3920-
/// at the call site.
3921-
///
3922-
/// A CallerDefaultArgumentExpr must only appear as a direct child of a
3923-
/// ParenExpr or a TupleExpr that is itself a call argument.
3924-
///
3925-
/// FIXME: This only exists to distinguish caller default arguments from arguments
3926-
/// that were specified at the call site. Once we remove SanitizeExpr, we can remove
3927-
/// this hack too.
3928-
class CallerDefaultArgumentExpr final : public Expr {
3929-
/// The expression that is evaluated to produce the default argument value.
3930-
Expr *SubExpr;
3931-
3932-
/// The source location of the argument list.
3933-
SourceLoc Loc;
3934-
3935-
public:
3936-
explicit CallerDefaultArgumentExpr(Expr *subExpr, SourceLoc loc, Type Ty)
3937-
: Expr(ExprKind::CallerDefaultArgument, /*Implicit=*/true, Ty),
3938-
SubExpr(subExpr), Loc(loc) { }
3939-
3940-
SourceRange getSourceRange() const {
3941-
return Loc;
3942-
}
3943-
3944-
Expr *getSubExpr() const {
3945-
return SubExpr;
3946-
}
3947-
3948-
void setSubExpr(Expr *subExpr) {
3949-
SubExpr = subExpr;
3950-
}
3951-
3952-
static bool classof(const Expr *E) {
3953-
return E->getKind() == ExprKind::CallerDefaultArgument;
3954-
}
3955-
};
3956-
39573919
/// ApplyExpr - Superclass of various function calls, which apply an argument to
39583920
/// a function to get a result.
39593921
class ApplyExpr : public Expr {

include/swift/AST/ExprNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ EXPR(DynamicType, Expr)
127127
EXPR(RebindSelfInConstructor, Expr)
128128
EXPR(OpaqueValue, Expr)
129129
EXPR(DefaultArgument, Expr)
130-
EXPR(CallerDefaultArgument, Expr)
131130
EXPR(BindOptional, Expr)
132131
EXPR(OptionalEvaluation, Expr)
133132
EXPR(ForceValue, Expr)

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,12 +2494,6 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
24942494
PrintWithColorRAII(OS, ParenthesisColor) << ')';
24952495
}
24962496

2497-
void visitCallerDefaultArgumentExpr(CallerDefaultArgumentExpr *E) {
2498-
printCommon(E, "caller_default_argument_expr");
2499-
printRec(E->getSubExpr());
2500-
PrintWithColorRAII(OS, ParenthesisColor) << ')';
2501-
}
2502-
25032497
void printArgumentLabels(ArrayRef<Identifier> argLabels) {
25042498
PrintWithColorRAII(OS, ArgumentsColor) << " arg_labels=";
25052499
for (auto label : argLabels) {

lib/AST/ASTWalker.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -483,15 +483,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
483483

484484
Expr *visitDefaultArgumentExpr(DefaultArgumentExpr *E) { return E; }
485485

486-
Expr *visitCallerDefaultArgumentExpr(CallerDefaultArgumentExpr *E) {
487-
if (auto subExpr = doIt(E->getSubExpr())) {
488-
E->setSubExpr(subExpr);
489-
return E;
490-
}
491-
492-
return nullptr;
493-
}
494-
495486
Expr *visitInterpolatedStringLiteralExpr(InterpolatedStringLiteralExpr *E) {
496487
if (auto oldAppendingExpr = E->getAppendingExpr()) {
497488
if (auto appendingExpr = doIt(oldAppendingExpr))

lib/AST/Expr.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ ConcreteDeclRef Expr::getReferencedDecl() const {
312312

313313
NO_REFERENCE(OpaqueValue);
314314
NO_REFERENCE(DefaultArgument);
315-
NO_REFERENCE(CallerDefaultArgument);
316315

317316
PASS_THROUGH_REFERENCE(BindOptional, getSubExpr);
318317
PASS_THROUGH_REFERENCE(OptionalEvaluation, getSubExpr);
@@ -621,7 +620,6 @@ bool Expr::canAppendPostfixExpression(bool appendingPostfixOperator) const {
621620
case ExprKind::RebindSelfInConstructor:
622621
case ExprKind::OpaqueValue:
623622
case ExprKind::DefaultArgument:
624-
case ExprKind::CallerDefaultArgument:
625623
case ExprKind::BindOptional:
626624
case ExprKind::OptionalEvaluation:
627625
return false;

lib/SILGen/ASTVisitor.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ class ASTVisitor : public swift::ASTVisitor<ImplClass,
6060
llvm_unreachable("DefaultArgumentExpr should not appear in this position");
6161
}
6262

63-
ExprRetTy visitCallerDefaultArgumentExpr(CallerDefaultArgumentExpr *E, Args... AA) {
64-
return static_cast<ImplClass*>(this)->visit(E->getSubExpr(),
65-
std::forward<Args>(AA)...);
66-
}
67-
6863
ExprRetTy visitVarargExpansionExpr(VarargExpansionExpr *E, Args... AA) {
6964
return static_cast<ImplClass*>(this)->visit(E->getSubExpr(),
7065
std::forward<Args>(AA)...);

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,10 +3014,6 @@ namespace {
30143014
llvm_unreachable("Already type-checked");
30153015
}
30163016

3017-
Expr *visitCallerDefaultArgumentExpr(CallerDefaultArgumentExpr *expr) {
3018-
llvm_unreachable("Already type-checked");
3019-
}
3020-
30213017
Expr *visitApplyExpr(ApplyExpr *expr) {
30223018
auto *calleeLoc = CalleeLocators[expr];
30233019
assert(calleeLoc);

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,10 +2510,6 @@ namespace {
25102510
return expr->getType();
25112511
}
25122512

2513-
Type visitCallerDefaultArgumentExpr(CallerDefaultArgumentExpr *expr) {
2514-
return expr->getType();
2515-
}
2516-
25172513
Type visitApplyExpr(ApplyExpr *expr) {
25182514
auto fnExpr = expr->getFn();
25192515

@@ -3454,8 +3450,7 @@ namespace {
34543450
}
34553451

34563452
bool isSyntheticArgumentExpr(const Expr *expr) {
3457-
if (isa<DefaultArgumentExpr>(expr) ||
3458-
isa<CallerDefaultArgumentExpr>(expr))
3453+
if (isa<DefaultArgumentExpr>(expr))
34593454
return true;
34603455

34613456
if (auto *varargExpr = dyn_cast<VarargExpansionExpr>(expr))
@@ -3909,8 +3904,7 @@ swift::getOriginalArgumentList(Expr *expr) {
39093904
OriginalArgumentList result;
39103905

39113906
auto add = [&](Expr *arg, Identifier label, SourceLoc labelLoc) {
3912-
if (isa<DefaultArgumentExpr>(arg) ||
3913-
isa<CallerDefaultArgumentExpr>(arg)) {
3907+
if (isa<DefaultArgumentExpr>(arg)) {
39143908
return;
39153909
}
39163910

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,8 +1785,7 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
17851785
auto I = argumentLabelIDs.begin();
17861786

17871787
auto updateLabelsForArg = [&](Expr *expr) -> bool {
1788-
if (isa<DefaultArgumentExpr>(expr) ||
1789-
isa<CallerDefaultArgumentExpr>(expr)) {
1788+
if (isa<DefaultArgumentExpr>(expr)) {
17901789
// Defaulted: remove param label of it.
17911790
if (I == argumentLabelIDs.end())
17921791
return true;

lib/Sema/TypeCheckError.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,7 @@ class ApplyClassifier {
679679
Classification classifyRethrowsArgument(Expr *arg, Type paramType) {
680680
arg = arg->getValueProvidingExpr();
681681

682-
if (isa<DefaultArgumentExpr>(arg) ||
683-
isa<CallerDefaultArgumentExpr>(arg)) {
682+
if (isa<DefaultArgumentExpr>(arg)) {
684683
return classifyArgumentByType(arg->getType(),
685684
PotentialReason::forDefaultArgument());
686685
}

0 commit comments

Comments
 (0)