Skip to content

Commit 0973224

Browse files
committed
[ConstraintSystem] Sort type variables when dumping a constraint system
This makes it easier to find type variables when `-debug-constraints` is passed.
1 parent b3d9b87 commit 0973224

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,13 @@ void ConstraintSystem::print(raw_ostream &out) const {
14061406
}
14071407

14081408
out << "Type Variables:\n";
1409-
for (auto tv : getTypeVariables()) {
1409+
std::vector<TypeVariableType *> typeVariables(getTypeVariables().begin(),
1410+
getTypeVariables().end());
1411+
llvm::sort(typeVariables,
1412+
[](const TypeVariableType *lhs, const TypeVariableType *rhs) {
1413+
return lhs->getID() < rhs->getID();
1414+
});
1415+
for (auto tv : typeVariables) {
14101416
out.indent(2);
14111417
Type(tv).print(out, PO);
14121418
if (tv->getImpl().canBindToLValue())

0 commit comments

Comments
 (0)