Skip to content

Commit 3f03712

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 d8943c3 commit 3f03712

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

include/swift/Sema/ConstraintSystem.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -4421,7 +4421,7 @@ class ConstraintSystem {
44214421

44224422
if (isDebugMode()) {
44234423
auto &log = llvm::errs();
4424-
log.indent(solverState ? solverState->getCurrentIndent() : 0)
4424+
log.indent(solverState ? solverState->getCurrentIndent() + 4 : 0)
44254425
<< "(failed constraint ";
44264426
constraint->print(log, &getASTContext().SourceMgr);
44274427
log << ")\n";
@@ -4446,7 +4446,7 @@ class ConstraintSystem {
44464446

44474447
if (isDebugMode() && getPhase() == ConstraintSystemPhase::Solving) {
44484448
auto &log = llvm::errs();
4449-
log.indent(solverState->getCurrentIndent() + 2) << "(added constraint: ";
4449+
log.indent(solverState->getCurrentIndent() + 4) << "(added constraint: ";
44504450
constraint->print(log, &getASTContext().SourceMgr,
44514451
solverState->getCurrentIndent() + 4);
44524452
log << ")\n";
@@ -4464,7 +4464,7 @@ class ConstraintSystem {
44644464

44654465
if (isDebugMode() && getPhase() == ConstraintSystemPhase::Solving) {
44664466
auto &log = llvm::errs();
4467-
log.indent(solverState->getCurrentIndent() + 2)
4467+
log.indent(solverState->getCurrentIndent() + 4)
44684468
<< "(removed constraint: ";
44694469
constraint->print(log, &getASTContext().SourceMgr,
44704470
solverState->getCurrentIndent() + 4);

lib/Sema/CSSolver.cpp

+11
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 by solver steps.
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)