Skip to content

Commit b1454df

Browse files
author
Amritpan Kaur
committed
[Constraint] Add indentations to conj/disjunction printing.
This indents added/removed conj/disjunction constraints and AST printed with conjunctions.
1 parent d9aba53 commit b1454df

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4425,7 +4425,8 @@ class ConstraintSystem {
44254425
if (isDebugMode() && getPhase() == ConstraintSystemPhase::Solving) {
44264426
auto &log = llvm::errs();
44274427
log.indent(solverState->getCurrentIndent() + 2) << "(added constraint: ";
4428-
constraint->print(log, &getASTContext().SourceMgr);
4428+
constraint->print(log, &getASTContext().SourceMgr,
4429+
solverState->getCurrentIndent() + 4);
44294430
log << ")\n";
44304431
}
44314432

@@ -4443,7 +4444,8 @@ class ConstraintSystem {
44434444
auto &log = llvm::errs();
44444445
log.indent(solverState->getCurrentIndent() + 2)
44454446
<< "(removed constraint: ";
4446-
constraint->print(log, &getASTContext().SourceMgr);
4447+
constraint->print(log, &getASTContext().SourceMgr,
4448+
solverState->getCurrentIndent() + 4);
44474449
log << ")\n";
44484450
}
44494451

lib/Sema/Constraint.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -357,18 +357,21 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, unsigned inden
357357
return false;
358358
});
359359

360-
interleave(sortedConstraints,
361-
[&](Constraint *constraint) {
362-
if (constraint->isDisabled())
363-
Out << "> [disabled] ";
364-
else if (constraint->isFavored())
365-
Out << "> [favored] ";
366-
else
367-
Out << "> ";
368-
constraint->print(Out, sm,
369-
/*skipLocator=*/constraint->getLocator() == Locator);
370-
},
371-
[&] { Out << "\n"; });
360+
interleave(
361+
sortedConstraints,
362+
[&](Constraint *constraint) {
363+
Out.indent(indent);
364+
if (constraint->isDisabled())
365+
Out << "> [disabled] ";
366+
else if (constraint->isFavored())
367+
Out << "> [favored] ";
368+
else
369+
Out << "> ";
370+
constraint->print(Out, sm, indent,
371+
/*skipLocator=*/constraint->getLocator() ==
372+
Locator);
373+
},
374+
[&] { Out << "\n"; });
372375
return;
373376
}
374377

0 commit comments

Comments
 (0)