Skip to content

Commit 3d4ba19

Browse files
author
Amritpan Kaur
committed
[Constraint] Sort constraint printing by favored, unmarked, and disabled in that order for printing only.
1 parent 05270c9 commit 3d4ba19

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/Sema/Constraint.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,21 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocat
344344
Out << "]]";
345345
}
346346
Out << ":\n";
347-
348-
interleave(getNestedConstraints(),
347+
348+
// Sort constraints by favored, unmarked, disabled
349+
// for printing only.
350+
std::vector<Constraint *> sortedConstraints(getNestedConstraints().begin(),
351+
getNestedConstraints().end());
352+
llvm::sort(sortedConstraints,
353+
[](const Constraint *lhs, const Constraint *rhs) {
354+
if (lhs->isFavored() != rhs->isFavored())
355+
return lhs->isFavored();
356+
if (lhs->isDisabled() != rhs->isDisabled())
357+
return rhs->isDisabled();
358+
return false;
359+
});
360+
361+
interleave(sortedConstraints,
349362
[&](Constraint *constraint) {
350363
if (constraint->isDisabled())
351364
Out << "> [disabled] ";

0 commit comments

Comments
 (0)