Skip to content

Commit 2d915f6

Browse files
committed
[Constraint solver] Remove expression from the constructor.
Rather than setting up the constraint solver with a single expression (that gets recorded for parents/depths), record each expression that goes through constraint generation.
1 parent 9b9aa23 commit 2d915f6

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,6 +3754,8 @@ namespace {
37543754
} // end anonymous namespace
37553755

37563756
Expr *ConstraintSystem::generateConstraints(Expr *expr, DeclContext *dc) {
3757+
InputExprs.insert(expr);
3758+
37573759
// Remove implicit conversions from the expression.
37583760
expr = expr->walk(SanitizeExpr(*this));
37593761

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ bool ConstraintSystem::Candidate::solve(
574574
};
575575

576576
// Allocate new constraint system for sub-expression.
577-
ConstraintSystem cs(DC, None, E);
577+
ConstraintSystem cs(DC, None);
578578
cs.baseCS = &BaseCS;
579579

580580
// Set up expression type checker timer for the candidate.

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,11 @@ ExpressionTimer::~ExpressionTimer() {
7575

7676

7777
ConstraintSystem::ConstraintSystem(DeclContext *dc,
78-
ConstraintSystemOptions options,
79-
Expr *expr)
78+
ConstraintSystemOptions options)
8079
: Context(dc->getASTContext()), DC(dc), Options(options),
8180
Arena(dc->getASTContext(), Allocator),
8281
CG(*new ConstraintGraph(*this))
8382
{
84-
if (expr) {
85-
InputExprs.insert(expr);
86-
}
87-
8883
assert(DC && "context required");
8984
}
9085

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,8 +1664,7 @@ class ConstraintSystem {
16641664
};
16651665

16661666
ConstraintSystem(DeclContext *dc,
1667-
ConstraintSystemOptions options,
1668-
Expr *expr = nullptr);
1667+
ConstraintSystemOptions options);
16691668
~ConstraintSystem();
16701669

16711670
/// Retrieve the type checker associated with this constraint system.

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2198,7 +2198,7 @@ Type TypeChecker::typeCheckExpressionImpl(Expr *&expr, DeclContext *dc,
21982198
if (options.contains(TypeCheckExprFlags::SubExpressionDiagnostics))
21992199
csOptions |= ConstraintSystemFlags::SubExpressionDiagnostics;
22002200

2201-
ConstraintSystem cs(dc, csOptions, expr);
2201+
ConstraintSystem cs(dc, csOptions);
22022202
cs.baseCS = baseCS;
22032203

22042204
// Verify that a purpose was specified if a convertType was. Note that it is

0 commit comments

Comments
 (0)