Skip to content

Commit e07f49d

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

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
@@ -343,8 +343,21 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocat
343343
Out << "]]";
344344
}
345345
Out << ":\n";
346-
347-
interleave(getNestedConstraints(),
346+
347+
// Sort constraints by favored, unmarked, disabled
348+
// for printing only.
349+
std::vector<Constraint *> sortedConstraints(getNestedConstraints().begin(),
350+
getNestedConstraints().end());
351+
llvm::sort(sortedConstraints,
352+
[](const Constraint *lhs, const Constraint *rhs) {
353+
if (lhs->isFavored() != rhs->isFavored())
354+
return lhs->isFavored();
355+
if (lhs->isDisabled() != rhs->isDisabled())
356+
return rhs->isDisabled();
357+
return false;
358+
});
359+
360+
interleave(sortedConstraints,
348361
[&](Constraint *constraint) {
349362
if (constraint->isDisabled())
350363
Out << "> [disabled] ";

0 commit comments

Comments
 (0)