Skip to content

Commit 1a609f0

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 b1454df commit 1a609f0

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-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) << "(added constraint: ";
4427+
log.indent(solverState->getCurrentIndent() + 4) << "(added constraint: ";
44284428
constraint->print(log, &getASTContext().SourceMgr,
44294429
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
<< "(removed constraint: ";
44474447
constraint->print(log, &getASTContext().SourceMgr,
44484448
solverState->getCurrentIndent() + 4);

lib/Sema/CSSolver.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,14 @@ bool ConstraintSystem::simplify() {
351351
log << "(considering -> ";
352352
constraint->print(log, &getASTContext().SourceMgr);
353353
log << "\n";
354+
355+
// {Dis, Con}junction are returned unsolved in \c simplifyConstraint() and
356+
// handled separately in their functions.
357+
if (constraint->getKind() != ConstraintKind::Disjunction &&
358+
constraint->getKind() != ConstraintKind::Conjunction) {
359+
log.indent(solverState->getCurrentIndent() + 2)
360+
<< "(simplification result:\n";
361+
}
354362
}
355363

356364
// Simplify this constraint.
@@ -359,6 +367,7 @@ bool ConstraintSystem::simplify() {
359367
retireFailedConstraint(constraint);
360368
if (isDebugMode()) {
361369
auto &log = llvm::errs();
370+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
362371
log.indent(solverState->getCurrentIndent() + 2) << "(outcome: error)\n";
363372
}
364373
break;
@@ -369,6 +378,7 @@ bool ConstraintSystem::simplify() {
369378
retireConstraint(constraint);
370379
if (isDebugMode()) {
371380
auto &log = llvm::errs();
381+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
372382
log.indent(solverState->getCurrentIndent() + 2)
373383
<< "(outcome: simplified)\n";
374384
}
@@ -379,6 +389,7 @@ bool ConstraintSystem::simplify() {
379389
++solverState->NumUnsimplifiedConstraints;
380390
if (isDebugMode()) {
381391
auto &log = llvm::errs();
392+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
382393
log.indent(solverState->getCurrentIndent() + 2)
383394
<< "(outcome: unsolved)\n";
384395
}

0 commit comments

Comments
 (0)