Skip to content

Commit b6bac0b

Browse files
committed
[Linked expression analyzer] Stop tracking anonymous closure params.
A given instance of an anonymous closure parameter will always have the same type (or type variable). This wasn't true when the linked expression analyzer was implemented, but it is guaranteed now.
1 parent 5eb40fb commit b6bac0b

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ namespace {
9191

9292
llvm::SmallVector<BinaryExpr *, 4> binaryExprs;
9393

94-
// TODO: manage as a set of lists, to speed up addition of binding
95-
// constraints.
96-
llvm::SmallVector<DeclRefExpr *, 16> anonClosureParams;
97-
9894
LinkedTypeInfo() {
9995
haveIntLiteral = false;
10096
haveFloatLiteral = false;
@@ -249,10 +245,7 @@ namespace {
249245

250246
if (auto DRE = dyn_cast<DeclRefExpr>(expr)) {
251247
if (auto varDecl = dyn_cast<VarDecl>(DRE->getDecl())) {
252-
if (isa<ParamDecl>(varDecl) &&
253-
cast<ParamDecl>(varDecl)->isAnonClosureParam()) {
254-
LTI.anonClosureParams.push_back(DRE);
255-
} else if (CS.hasType(DRE)) {
248+
if (CS.hasType(DRE)) {
256249
LTI.collectedTypes.insert(CS.getType(DRE).getPointer());
257250
}
258251
return { false, expr };
@@ -346,24 +339,6 @@ namespace {
346339

347340
expr->walk(LinkedExprAnalyzer(lti, CS));
348341

349-
// Link anonymous closure params of the same index.
350-
// TODO: As stated above, we should bucket these whilst collecting the
351-
// exprs to avoid quadratic behavior.
352-
for (auto acp1 : lti.anonClosureParams) {
353-
for (auto acp2 : lti.anonClosureParams) {
354-
if (acp1 == acp2)
355-
continue;
356-
357-
if (acp1->getDecl()->getBaseName() == acp2->getDecl()->getBaseName()) {
358-
359-
auto tyvar1 = CS.getType(acp1)->getAs<TypeVariableType>();
360-
auto tyvar2 = CS.getType(acp2)->getAs<TypeVariableType>();
361-
362-
mergeRepresentativeEquivalenceClasses(CS, tyvar1, tyvar2);
363-
}
364-
}
365-
}
366-
367342
auto mergeTypeVariables = [&](ArrayRef<TypeVariableType *> typeVars) {
368343
if (typeVars.size() < 2)
369344
return;

0 commit comments

Comments
 (0)