Skip to content

Commit e0c5875

Browse files
author
Amritpan Kaur
committed
[ConstraintSystem] Nest simplification result inside new block.
Nest failed, added, and removed constraints inside block called `simplification result`.
1 parent 17601da commit e0c5875

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4399,7 +4399,7 @@ class ConstraintSystem {
43994399

44004400
if (isDebugMode()) {
44014401
auto &log = llvm::errs();
4402-
log.indent(solverState ? solverState->getCurrentIndent() : 0)
4402+
log.indent(solverState ? solverState->getCurrentIndent() + 4 : 0)
44034403
<< "(failed constraint ";
44044404
constraint->print(log, &getASTContext().SourceMgr);
44054405
log << ")\n";
@@ -4424,7 +4424,7 @@ class ConstraintSystem {
44244424

44254425
if (isDebugMode() && getPhase() == ConstraintSystemPhase::Solving) {
44264426
auto &log = llvm::errs();
4427-
log.indent(solverState->getCurrentIndent() + 2);
4427+
log.indent(solverState->getCurrentIndent() + 4);
44284428
log << "(added constraint: ";
44294429
constraint->print(log, &getASTContext().SourceMgr, solverState->getCurrentIndent() + 4);
44304430
log << ")\n";
@@ -4442,7 +4442,7 @@ class ConstraintSystem {
44424442

44434443
if (isDebugMode() && getPhase() == ConstraintSystemPhase::Solving) {
44444444
auto &log = llvm::errs();
4445-
log.indent(solverState->getCurrentIndent() + 2);
4445+
log.indent(solverState->getCurrentIndent() + 4);
44464446
log << "(removed constraint: ";
44474447
constraint->print(log, &getASTContext().SourceMgr);
44484448
log << ")\n";

lib/Sema/CSSolver.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,12 @@ bool ConstraintSystem::simplify() {
351351
log << "(considering -> ";
352352
constraint->print(log, &getASTContext().SourceMgr);
353353
log << "\n";
354+
355+
if (constraint->getKind() != ConstraintKind::Disjunction &&
356+
constraint->getKind() != ConstraintKind::Conjunction) {
357+
log.indent(solverState->getCurrentIndent() + 2)
358+
<< "(simplification result:\n";
359+
}
354360
}
355361

356362
// Simplify this constraint.
@@ -359,6 +365,7 @@ bool ConstraintSystem::simplify() {
359365
retireFailedConstraint(constraint);
360366
if (isDebugMode()) {
361367
auto &log = llvm::errs();
368+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
362369
log.indent(solverState->getCurrentIndent() + 2) << "(outcome: error)\n";
363370
}
364371
break;
@@ -369,6 +376,7 @@ bool ConstraintSystem::simplify() {
369376
retireConstraint(constraint);
370377
if (isDebugMode()) {
371378
auto &log = llvm::errs();
379+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
372380
log.indent(solverState->getCurrentIndent() + 2)
373381
<< "(outcome: simplified)\n";
374382
}
@@ -379,6 +387,7 @@ bool ConstraintSystem::simplify() {
379387
++solverState->NumUnsimplifiedConstraints;
380388
if (isDebugMode()) {
381389
auto &log = llvm::errs();
390+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
382391
log.indent(solverState->getCurrentIndent() + 2)
383392
<< "(outcome: unsolved)\n";
384393
}

0 commit comments

Comments
 (0)