Skip to content

Commit 2ddeef7

Browse files
committed
[ConstraintSystem] Remove ExprCleaner and its uses
1 parent f9c6ed5 commit 2ddeef7

File tree

4 files changed

+0
-58
lines changed

4 files changed

+0
-58
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3827,8 +3827,6 @@ static bool diagnoseImplicitSelfErrors(Expr *fnExpr, Expr *argExpr,
38273827
// Swift Standard Library called 'max' which does accept two arguments,
38283828
// so user might have called that by mistake without realizing that
38293829
// compiler would add implicit 'self.' prefix to the call of 'max'.
3830-
ExprCleaner cleanup(argExpr);
3831-
38323830
auto argType = CS.getType(argExpr);
38333831
// If argument wasn't properly type-checked, let's retry without changing AST.
38343832
if (!argType || argType->hasUnresolvedType() || argType->hasTypeVariable() ||
@@ -7010,8 +7008,6 @@ bool FailureDiagnosis::diagnoseClosureExpr(
70107008
// but it's not always reset.
70117009

70127010
if (expectedResultType && !CE->hasExplicitResultType()) {
7013-
ExprCleaner cleaner(CE);
7014-
70157011
auto closure = CE->getSingleExpressionBody();
70167012
ConcreteDeclRef decl = nullptr;
70177013
// Let's try to compute result type without mutating AST and

lib/Sema/CSSolver.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,6 @@ bool ConstraintSystem::Candidate::solve(
837837
// Set up expression type checker timer for the candidate.
838838
cs.Timer.emplace(E, cs);
839839

840-
// Cleanup after constraint system generation/solving,
841-
// because it would assign types to expressions, which
842-
// might interfere with solving higher-level expressions.
843-
ExprCleaner cleaner(E);
844-
845840
// Generate constraints for the new system.
846841
if (auto generatedExpr = cs.generateConstraints(E)) {
847842
E = generatedExpr;

lib/Sema/ConstraintSystem.h

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,52 +3484,6 @@ ForcedCheckedCastExpr *findForcedDowncast(ASTContext &ctx, Expr *expr);
34843484
// Note: this may update the provided expr pointer.
34853485
void eraseOpenedExistentials(constraints::ConstraintSystem &CS, Expr *&expr);
34863486

3487-
3488-
/// ExprCleaner - This class is used by shrink to ensure that in
3489-
/// no situation will an expr node be left with a dangling type variable stuck
3490-
/// to it. Often type checking will create new AST nodes and replace old ones
3491-
/// (e.g. by turning an UnresolvedDotExpr into a MemberRefExpr). These nodes
3492-
/// might be left with pointers into the temporary constraint system through
3493-
/// their type variables, and we don't want pointers into the original AST to
3494-
/// dereference these now-dangling types.
3495-
class ExprCleaner {
3496-
llvm::SmallVector<VarDecl*, 4> Vars;
3497-
public:
3498-
3499-
ExprCleaner(Expr *E) {
3500-
struct ExprCleanerImpl : public ASTWalker {
3501-
ExprCleaner *TS;
3502-
ExprCleanerImpl(ExprCleaner *TS) : TS(TS) {}
3503-
3504-
bool walkToDeclPre(Decl *D) override {
3505-
if (auto VD = dyn_cast<VarDecl>(D))
3506-
TS->Vars.push_back(VD);
3507-
3508-
return true;
3509-
}
3510-
3511-
// Don't walk into statements. This handles the BraceStmt in
3512-
// non-single-expr closures, so we don't walk into their body.
3513-
std::pair<bool, Stmt *> walkToStmtPre(Stmt *S) override {
3514-
return { false, S };
3515-
}
3516-
};
3517-
3518-
E->walk(ExprCleanerImpl(this));
3519-
}
3520-
3521-
~ExprCleaner() {
3522-
// Check each of the expression nodes to verify that there are no type
3523-
// variables hanging out. If so, just nuke the type.
3524-
for (auto VD : Vars) {
3525-
if (VD->hasType() && VD->getType()->hasTypeVariable()) {
3526-
VD->setType(Type());
3527-
VD->setInterfaceType(Type());
3528-
}
3529-
}
3530-
}
3531-
};
3532-
35333487
// Count the number of overload sets present
35343488
// in the expression and all of the children.
35353489
class OverloadSetCounter : public ASTWalker {

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,6 @@ Type TypeChecker::typeCheckExpression(Expr *&expr, DeclContext *dc,
20052005
ConstraintSystem cs(*this, dc, csOptions);
20062006
cs.baseCS = baseCS;
20072007
CleanupIllFormedExpressionRAII cleanup(expr);
2008-
ExprCleaner cleanup2(expr);
20092008

20102009
// Verify that a purpose was specified if a convertType was. Note that it is
20112010
// ok to have a purpose without a convertType (which is used for call
@@ -2203,8 +2202,6 @@ void TypeChecker::getPossibleTypesOfExpressionWithoutApplying(
22032202
ExprTypeCheckListener *listener) {
22042203
PrettyStackTraceExpr stackTrace(Context, "type-checking", expr);
22052204

2206-
ExprCleaner cleaner(expr);
2207-
22082205
// Construct a constraint system from this expression.
22092206
ConstraintSystemOptions options;
22102207
options |= ConstraintSystemFlags::ReturnAllDiscoveredSolutions;

0 commit comments

Comments
 (0)