Skip to content

Commit 2efcf25

Browse files
author
Amritpan Kaur
committed
[CSSolver] Print constraint simplification and outcome.
1 parent 826adfd commit 2efcf25

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,24 +345,51 @@ bool ConstraintSystem::simplify() {
345345
auto *constraint = &ActiveConstraints.front();
346346
deactivateConstraint(constraint);
347347

348+
if (isDebugMode()) {
349+
auto &log = llvm::errs();
350+
log.indent(solverState->getCurrentIndent());
351+
log << "(considering -> ";
352+
constraint->print(log, &getASTContext().SourceMgr);
353+
log << "\n";
354+
}
355+
348356
// Simplify this constraint.
349357
switch (simplifyConstraint(*constraint)) {
350358
case SolutionKind::Error:
351359
retireFailedConstraint(constraint);
360+
if (isDebugMode()) {
361+
auto &log = llvm::errs();
362+
log.indent(solverState->getCurrentIndent() + 2) << "(outcome: error)\n";
363+
}
352364
break;
353365

354366
case SolutionKind::Solved:
355367
if (solverState)
356368
++solverState->NumSimplifiedConstraints;
357369
retireConstraint(constraint);
370+
if (isDebugMode()) {
371+
auto &log = llvm::errs();
372+
log.indent(solverState->getCurrentIndent() + 2)
373+
<< "(outcome: simplified)\n";
374+
}
358375
break;
359376

360377
case SolutionKind::Unsolved:
361378
if (solverState)
362379
++solverState->NumUnsimplifiedConstraints;
380+
if (isDebugMode()) {
381+
auto &log = llvm::errs();
382+
log.indent(solverState->getCurrentIndent() + 2)
383+
<< "(outcome: unsolved)\n";
384+
}
363385
break;
364386
}
365387

388+
if (isDebugMode()) {
389+
auto &log = llvm::errs();
390+
log.indent(solverState->getCurrentIndent()) << ")\n";
391+
}
392+
366393
// Check whether a constraint failed. If so, we're done.
367394
if (failedConstraint) {
368395
return true;

0 commit comments

Comments
 (0)