Skip to content

Commit 3aeecd1

Browse files
author
Amritpan Kaur
committed
[Constraint] Add indentations to conj/disjunction printing.
And fix indent for AST printed for conjunctions. This indents conj/disjuctions when they are printed as added/removed constraints.
1 parent 7576562 commit 3aeecd1

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

include/swift/Sema/ConstraintSystem.h

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

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)