mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Constraint graph] Handle orphaned constraints within connected components
Move the logic for creating connected components of orphaned constraints into the connected-components algorithm code, rather than making it a special part of SplitterStep.
This commit is contained in:
@@ -540,6 +540,8 @@ namespace {
|
||||
|
||||
// Assign each type variable to its appropriate component.
|
||||
SmallVector<Component, 1> components;
|
||||
components.reserve(
|
||||
validComponents.size() + cg.getOrphanedConstraints().size());
|
||||
llvm::SmallDenseMap<TypeVariableType *, unsigned> componentIdxMap;
|
||||
for (auto typeVar : typeVars) {
|
||||
// Find the representative. If we aren't creating a type variable
|
||||
@@ -577,6 +579,12 @@ namespace {
|
||||
components[componentIdxMap[rep]].constraints.push_back(&constraint);
|
||||
}
|
||||
|
||||
// Gather orphaned constraints; each gets its own component.
|
||||
for (auto orphaned : cg.getOrphanedConstraints()) {
|
||||
components.push_back({ });
|
||||
components.back().constraints.push_back(orphaned);
|
||||
}
|
||||
|
||||
return components;
|
||||
}
|
||||
|
||||
@@ -635,7 +643,6 @@ ConstraintGraph::computeConnectedComponents(
|
||||
// Perform connected components via a union-find algorithm on all of the
|
||||
// constraints adjacent to these type variables.
|
||||
ConnectedComponents cc(*this, typeVars);
|
||||
|
||||
return cc.getComponents();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user