Skip to content

Commit 13f05f0

Browse files
authored
Merge pull request #4799 from rudkx/type-checker-perf-swift-3.0-branch
Pull in some type checker performance improvements
2 parents 5dd5d82 + 07424a2 commit 13f05f0

File tree

13 files changed

+727
-115
lines changed

13 files changed

+727
-115
lines changed

include/swift/AST/Expr.h

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,11 @@ class OverloadSetRefExpr : public Expr {
14211421

14221422
public:
14231423
ArrayRef<ValueDecl*> getDecls() const { return Decls; }
1424-
1424+
1425+
void setDecls(ArrayRef<ValueDecl *> domain) {
1426+
Decls = domain;
1427+
}
1428+
14251429
/// getBaseType - Determine the type of the base object provided for the
14261430
/// given overload set, which is only non-null when dealing with an overloaded
14271431
/// member reference.
@@ -4295,29 +4299,6 @@ class AssignExpr : public Expr {
42954299
}
42964300
};
42974301

4298-
/// \brief An expression that describes the use of a default value, which may
4299-
/// come from the default argument of a function type or member initializer.
4300-
///
4301-
/// This expression is synthesized by type checking and cannot be written
4302-
/// directly by the user.
4303-
class DefaultValueExpr : public Expr {
4304-
Expr *subExpr;
4305-
4306-
public:
4307-
explicit DefaultValueExpr(Expr *subExpr)
4308-
: Expr(ExprKind::DefaultValue, /*Implicit=*/true, subExpr->getType()),
4309-
subExpr(subExpr) { }
4310-
4311-
Expr *getSubExpr() const { return subExpr; }
4312-
void setSubExpr(Expr *sub) { subExpr = sub; }
4313-
4314-
SourceRange getSourceRange() const { return SourceRange(); }
4315-
4316-
static bool classof(const Expr *E) {
4317-
return E->getKind() == ExprKind::DefaultValue;
4318-
}
4319-
};
4320-
43214302
/// \brief A pattern production that has been parsed but hasn't been resolved
43224303
/// into a complete pattern. Name binding converts these into standalone pattern
43234304
/// nodes or raises an error if a pattern production appears in an invalid

include/swift/AST/ExprNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ UNCHECKED_EXPR(Arrow, Expr)
154154
EXPR(If, Expr)
155155
EXPR(EnumIsCase, Expr)
156156
EXPR(Assign, Expr)
157-
EXPR(DefaultValue, Expr)
158157
EXPR(CodeCompletion, Expr)
159158
UNCHECKED_EXPR(UnresolvedPattern, Expr)
160159
EXPR(EditorPlaceholder, Expr)

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,11 +2212,6 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
22122212
printRec(E->getElseExpr());
22132213
OS << ')';
22142214
}
2215-
void visitDefaultValueExpr(DefaultValueExpr *E) {
2216-
printCommon(E, "default_value_expr") << ' ';
2217-
printRec(E->getSubExpr());
2218-
OS << ')';
2219-
}
22202215
void visitAssignExpr(AssignExpr *E) {
22212216
OS.indent(Indent) << "(assign_expr\n";
22222217
printRec(E->getDest());

lib/AST/ASTWalker.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,14 +800,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
800800
return E;
801801
}
802802

803-
Expr *visitDefaultValueExpr(DefaultValueExpr *E) {
804-
Expr *sub = doIt(E->getSubExpr());
805-
if (!sub) return nullptr;
806-
807-
E->setSubExpr(sub);
808-
return E;
809-
}
810-
811803
Expr *visitUnresolvedPatternExpr(UnresolvedPatternExpr *E) {
812804
Pattern *sub = doIt(E->getSubPattern());
813805
if (!sub) return nullptr;

lib/AST/Expr.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ Expr *Expr::getSemanticsProvidingExpr() {
178178
if (TryExpr *TE = dyn_cast<TryExpr>(this))
179179
return TE->getSubExpr()->getSemanticsProvidingExpr();
180180

181-
if (DefaultValueExpr *DE = dyn_cast<DefaultValueExpr>(this))
182-
return DE->getSubExpr()->getSemanticsProvidingExpr();
183-
184181
return this;
185182
}
186183

@@ -343,7 +340,6 @@ void Expr::propagateLValueAccessKind(AccessKind accessKind,
343340
NON_LVALUE_EXPR(OptionalEvaluation)
344341
NON_LVALUE_EXPR(If)
345342
NON_LVALUE_EXPR(Assign)
346-
NON_LVALUE_EXPR(DefaultValue)
347343
NON_LVALUE_EXPR(CodeCompletion)
348344
NON_LVALUE_EXPR(ObjCSelector)
349345
NON_LVALUE_EXPR(ObjCKeyPath)
@@ -485,7 +481,6 @@ ConcreteDeclRef Expr::getReferencedDecl() const {
485481
NO_REFERENCE(If);
486482
NO_REFERENCE(EnumIsCase);
487483
NO_REFERENCE(Assign);
488-
NO_REFERENCE(DefaultValue);
489484
NO_REFERENCE(CodeCompletion);
490485
NO_REFERENCE(UnresolvedPattern);
491486
NO_REFERENCE(EditorPlaceholder);
@@ -784,7 +779,6 @@ bool Expr::canAppendCallParentheses() const {
784779
case ExprKind::Arrow:
785780
case ExprKind::If:
786781
case ExprKind::Assign:
787-
case ExprKind::DefaultValue:
788782
case ExprKind::UnresolvedPattern:
789783
case ExprKind::EditorPlaceholder:
790784
return false;

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ namespace {
214214
SGFContext C);
215215
RValue visitIfExpr(IfExpr *E, SGFContext C);
216216

217-
RValue visitDefaultValueExpr(DefaultValueExpr *E, SGFContext C);
218217
RValue visitAssignExpr(AssignExpr *E, SGFContext C);
219218
RValue visitEnumIsCaseExpr(EnumIsCaseExpr *E, SGFContext C);
220219

@@ -2581,10 +2580,6 @@ RValue RValueEmitter::visitIfExpr(IfExpr *E, SGFContext C) {
25812580
}
25822581
}
25832582

2584-
RValue RValueEmitter::visitDefaultValueExpr(DefaultValueExpr *E, SGFContext C) {
2585-
return visit(E->getSubExpr(), C);
2586-
}
2587-
25882583
RValue SILGenFunction::emitEmptyTupleRValue(SILLocation loc,
25892584
SGFContext C) {
25902585
return RValue(CanType(TupleType::getEmpty(F.getASTContext())));

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,10 +2869,6 @@ namespace {
28692869
llvm_unreachable("Already type-checked");
28702870
}
28712871

2872-
Expr *visitDefaultValueExpr(DefaultValueExpr *expr) {
2873-
llvm_unreachable("Already type-checked");
2874-
}
2875-
28762872
Expr *visitApplyExpr(ApplyExpr *expr) {
28772873
return finishApply(expr, expr->getType(),
28782874
ConstraintLocatorBuilder(
@@ -6456,10 +6452,6 @@ namespace {
64566452
}
64576453

64586454
std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
6459-
// For a default-value expression, do nothing.
6460-
if (isa<DefaultValueExpr>(expr))
6461-
return { false, expr };
6462-
64636455
// For closures, update the parameter types and check the body.
64646456
if (auto closure = dyn_cast<ClosureExpr>(expr)) {
64656457
Rewriter.simplifyExprType(expr);

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,11 +2310,6 @@ namespace {
23102310
return expr->getType();
23112311
}
23122312

2313-
Type visitDefaultValueExpr(DefaultValueExpr *expr) {
2314-
expr->setType(expr->getSubExpr()->getType());
2315-
return expr->getType();
2316-
}
2317-
23182313
Type visitApplyExpr(ApplyExpr *expr) {
23192314
Type outputTy;
23202315

@@ -2757,11 +2752,6 @@ namespace {
27572752
public:
27582753
SanitizeExpr(TypeChecker &tc) : TC(tc) { }
27592754

2760-
std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
2761-
// Don't recurse into default-value expressions.
2762-
return { !isa<DefaultValueExpr>(expr), expr };
2763-
}
2764-
27652755
Expr *walkToExprPost(Expr *expr) override {
27662756
if (auto implicit = dyn_cast<ImplicitConversionExpr>(expr)) {
27672757
// Skip implicit conversions completely.
@@ -2841,12 +2831,6 @@ namespace {
28412831
return { true, expr };
28422832
}
28432833

2844-
// We don't visit default value expressions; they've already been
2845-
// type-checked.
2846-
if (isa<DefaultValueExpr>(expr)) {
2847-
return { false, expr };
2848-
}
2849-
28502834
// Don't visit CoerceExpr with an empty sub expression. They may occur
28512835
// if the body of a closure was not visited while pre-checking because
28522836
// of an error in the closure's signature

0 commit comments

Comments
 (0)